folly/Format-inl.h: avoid -Wsign-compare error
authorJim Meyering <meyering@fb.com>
Wed, 7 Jan 2015 16:13:57 +0000 (08:13 -0800)
committerViswanath Sivakumar <viswanath@fb.com>
Tue, 13 Jan 2015 19:01:04 +0000 (11:01 -0800)
Summary:
* folly/Format-inl.h (IndexableTraitsSeq::at): Add an explicit
int-to-size_t cast (ok here, since we've just confirmed
that the value is not negative) to avoid this error from gcc-4.9:

folly/Format-inl.h:947:29: 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: tjackson@fb.com

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

FB internal diff: D1770193

Tasks: 5941250

Signature: t1:1770193:1420670569:83ac19c2ca8cd408d7c86d7dce49e2d4b418941a

folly/Format-inl.h

index fb756197f3b89aa549b6a3ce8599cba5b7401da0..b72ec861aba142d8d3007326a1982a9666a55f21 100644 (file)
@@ -944,7 +944,7 @@ struct IndexableTraitsSeq : public FormatTraitsBase {
 
   static const value_type& at(const C& c, int idx,
                               const value_type& dflt) {
-    return (idx >= 0 && idx < c.size()) ? c.at(idx) : dflt;
+    return (idx >= 0 && size_t(idx) < c.size()) ? c.at(idx) : dflt;
   }
 };