folly: Bits: restore type of bitOffset_ to shorter "unsigned int"
authorJim Meyering <meyering@fb.com>
Sat, 10 Jan 2015 06:28:00 +0000 (22:28 -0800)
committerwoo <woo@fb.com>
Mon, 2 Feb 2015 21:11:24 +0000 (13:11 -0800)
commit98c4cba4a6bc766a361680664176901bb13d8697
tree688fd5502e0d0fbfc97fe16063b9db23239dc5d0
parent7887ef2afa255fc67160146ac212bbd55cc75900
folly: Bits: restore type of bitOffset_ to shorter "unsigned int"

Summary:
My initial change to avoid the -Wsign-compare error neglected
the fact that the difference of two unsigned types is also
unsigned. That broke some unicorn tests, as seen in D1776343,
which worked around the problem by changing the type of
bitOffset_ like this: s/unsigned int/size_t.

The real problem lay in the distance_to function, which computed
the signed difference of two bitOffset_ values.
To work properly with the narrower unsigned type,
we could either first widen each operand to ssize_t
before computing their parenthesized difference, or
(as Philip suggested and I prefer), just drop the
parentheses and let the signedness of the preceding
operands ensure that each successive intermediate
result is also signed.

Test Plan:
Choose one of the failing tests, and ensure it now passes:

fbconfig -r unicorn/diskindex4/test:doc_map_test
fbmake runtests

Also run all unicorn tests, for good measure (still waiting):
fbconfig -r unicorn && fbmake runtests

Reviewed By: philipp@fb.com, andrei.alexandrescu@fb.com

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

FB internal diff: D1776624

Tasks: 5941250

Signature: t1:1776624:1420872874:b1ea8a3f23f21269aa65cbe1647e86a8f622a710

Blame Revision: D1770613
folly/Bits.h