folly: ubsan: cast to unsigned to avoid negative-left-shift
authorLucian Grijincu <lucian@fb.com>
Tue, 10 May 2016 04:16:26 +0000 (21:16 -0700)
committerFacebook Github Bot 4 <facebook-github-bot-4-bot@fb.com>
Tue, 10 May 2016 04:20:25 +0000 (21:20 -0700)
commit6c4dfb8a63e86a819e08d1122e9dc0843ace0879
tree9c709f5492c35f3368cfe2cce32c7ca5c411d19c
parentc03fd9b73f75e78d631c9ce14d9ea3fd4d4909af
folly: ubsan: cast to unsigned to avoid negative-left-shift

Summary:
The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
  bits are filled with zeros.

  If E1 has a signed type and non-negative value, and E1 × 2E2 is
  representable in the result type, then that is the resulting value;
  otherwise, the behavior is undefined.

The code assumed the signed left shift worked like an unsigned left
shift, so make that explicit.

Reviewed By: meyering

Differential Revision: D3280325

fbshipit-source-id: 178b95ee36b7a1126a79bb825c2ad2ffa6fa9464
folly/Varint.h