folly/dynamic-inl.h: avoid -Wsign-compare error
authorJim Meyering <meyering@fb.com>
Wed, 7 Jan 2015 16:16:07 +0000 (08:16 -0800)
committerViswanath Sivakumar <viswanath@fb.com>
Tue, 13 Jan 2015 19:01:05 +0000 (11:01 -0800)
Summary:
* folly/dynamic-inl.h (format): Add an explicit
int-to-size_t cast (that is ok because we've just ensured
it is non-negative) to avoid this error from gcc-4.9:

folly/dynamic-inl.h:953: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: delong.j@fb.com

Subscribers: trunkagent, folly-diffs@

FB internal diff: D1773242

Tasks: 5941250

Signature: t1:1773242:1420822301:b1e3c065cd25728c77957ce9e1f52e884ba8693b

folly/dynamic-inl.h

index f0a580cb7e7c266c2afb83d3df725a7cdd33e614..c2d48eba36333c69585c18681c812c42cd2bb504 100644 (file)
@@ -950,7 +950,7 @@ class FormatValue<detail::DefaultValueWrapper<dynamic, V>> {
     case dynamic::ARRAY:
       {
         int key = arg.splitIntKey();
-        if (key >= 0 && key < c.size()) {
+        if (key >= 0 && size_t(key) < c.size()) {
           FormatValue<dynamic>(c.at(key)).format(arg, cb);
         } else{
           FormatValue<V>(val_.defaultValue).format(arg, cb);