folly: fix many -Wsign-compare warning/errors reported by gcc-4.9
authorJim Meyering <meyering@fb.com>
Tue, 6 Jan 2015 17:33:03 +0000 (09:33 -0800)
committerViswanath Sivakumar <viswanath@fb.com>
Tue, 13 Jan 2015 19:01:05 +0000 (11:01 -0800)
commit377e3f4cb4f599e01a897cf761d05c3ffa25b511
treeedf52d70b59103e01780095c63a6604ed95f3a57
parent7f0c4bda69ff762d7d611cf95ba1153b5f1e446b
folly: fix many -Wsign-compare warning/errors reported by gcc-4.9

Summary:
With the upgrade to gcc-4.9 fbcode's default is to enable
-Wsign-compare by default.  That exposes nontrivial technical debt.
This is part of that clean-up.  Some of these changes fix the problem
where there's an "int" for-loop index, yet an unsigned limit.
The fix is to use an unsigned type when the limit is also unsigned.
I usually choose size_t because of the general recommendation (when
writing portable code) to avoid size-tied types like uint32_t and
uint64_t unless you have a very good reason to require them.

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

Also, run this, compiling and running tests with gcc-4.8.1.
Verify that there are no more failures than without this patch:
fbmake opt -k && fbmake runtests_opt
Here's the tail of that process, (same with and without the patch):
Summary (total time 47.45s):
PASS: 1949
FAIL: 1
SKIP: 0
FATAL: 9
TIMEOUT: 0

Reviewed By: hans@fb.com

Subscribers: trunkagent, fugalh, njormrod, folly-diffs@

FB internal diff: D1766722

Tasks: 5941250

Signature: t1:1766722:1420762240:a8545648ddb4fd0b2adf0d3147a84409c0f706a8
folly/Arena.h
folly/FBVector.h
folly/MPMCQueue.h
folly/stats/TimeseriesHistogram-defs.h
folly/test/MPMCQueueTest.cpp
folly/wangle/concurrent/PriorityLifoSemMPMCQueue.h