folly/FBString.h: avoid -Wsign-compare error
authorJim Meyering <meyering@fb.com>
Wed, 7 Jan 2015 16:02:21 +0000 (08:02 -0800)
committerViswanath Sivakumar <viswanath@fb.com>
Tue, 13 Jan 2015 19:01:05 +0000 (11:01 -0800)
commit5b12bbfc1b90dbcbd034d3e74bf77b01f818b906
treee40759cfb1b2725e438c8955ea6fdfd7c09886d0
parent0b215436b803dc4cf8e4521791cb67aff401e546
folly/FBString.h: avoid -Wsign-compare error

Summary:
* folly/FBString.h (operator>>): Since istream.width() is signed,
handle the case of a negative width. This avoids risk that "n"
will be less than 0 when compared against unsigned "extracted".
However, to suppress the following warning, we must also explicitly
convert "n" to size_t before comparing:

folly/FBString.h:2326:22: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]

Test Plan:
Run this and note there are fewer errors than before:
fbconfig --platform-all=gcc-4.9-glibc-2.20 -r folly && fbmake dbgo

Reviewed By: andrei.alexandrescu@fb.com

Subscribers: trunkagent, net-systems@, njormrod, folly-diffs@

FB internal diff: D1770460

Tasks: 5941250

Signature: t1:1770460:1420679684:b262eb31e6511b6311bebf0fbc29099471648b36
folly/FBString.h