Skip to content

Commit

Permalink
Fix MSVC truncation of constant value
Browse files Browse the repository at this point in the history
Summary:
This warning:
```
thrift\lib\cpp2\protocol\compactprotocol.h(47): warning C4309: 'static_cast': truncation of constant value
thrift\lib\cpp2\protocol\compactprotocol.h(48): warning C4309: 'static_cast': truncation of constant value
```
happens when `static_cast`ing a number >= 128 into a negative 8-bit value. Fix it using an unrestricted cast.

For clarity, removing the unnecesssary cast on 0x02 just above it.

Reviewed By: yfeldblum

Differential Revision: D17789349

fbshipit-source-id: aebd3688ae9592783fea892a9a04e24b16c38f51
  • Loading branch information
jdonald authored and facebook-github-bot committed Oct 8, 2019
1 parent 7d4808e commit c00ff8b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions thrift/lib/cpp2/protocol/CompactProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ using folly::io::QueueAppender;
namespace detail {
namespace compact {

static const int8_t COMPACT_PROTOCOL_VERSION = static_cast<int8_t>(0x02);
static const int8_t COMPACT_PROTOCOL_VERSION = 0x02;
static const int32_t VERSION_2 = 0x82020000;
static const int8_t PROTOCOL_ID = static_cast<int8_t>(0x82);
static const int8_t TYPE_MASK = static_cast<int8_t>(0xE0);
static const int8_t PROTOCOL_ID = int8_t(0x82);
static const int8_t TYPE_MASK = int8_t(0xE0);
static const int32_t TYPE_SHIFT_AMOUNT = 5;

// Simple stack with an inline buffer for built-in types
Expand Down

0 comments on commit c00ff8b

Please sign in to comment.