Skip to content

Commit

Permalink
tools: fix compiler warning in inspector_protocol
Browse files Browse the repository at this point in the history
error: comparison of integer expressions of different signedness:
‘int’ and ‘uint64_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 2562 |           if (!success || std::numeric_limits<int32_t>::max() <
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
 2563 |                               token_start_internal_value_) {
      |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~

PR-URL: nodejs#37573
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
RaisinTen authored and aduh95 committed Mar 4, 2021
1 parent aee3ef5 commit ffb34b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions tools/inspector_protocol/encoding/encoding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,9 @@ void CBORTokenizer::ReadNextToken(bool enter_envelope) {
// inspector_protocol, it's not a CBOR limitation), so we check
// against the signed max, so that the allowable values are
// 0, 1, 2, ... 2^31 - 1.
if (!success || std::numeric_limits<int32_t>::max() <
token_start_internal_value_) {
if (!success ||
static_cast<int64_t>(std::numeric_limits<int32_t>::max()) <
static_cast<int64_t>(token_start_internal_value_)) {
SetError(Error::CBOR_INVALID_INT32);
return;
}
Expand Down
5 changes: 3 additions & 2 deletions tools/inspector_protocol/lib/encoding_cpp.template
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,9 @@ void CBORTokenizer::ReadNextToken(bool enter_envelope) {
// inspector_protocol, it's not a CBOR limitation), so we check
// against the signed max, so that the allowable values are
// 0, 1, 2, ... 2^31 - 1.
if (!success || std::numeric_limits<int32_t>::max() <
token_start_internal_value_) {
if (!success ||
static_cast<int64_t>(std::numeric_limits<int32_t>::max()) <
static_cast<int64_t>(token_start_internal_value_)) {
SetError(Error::CBOR_INVALID_INT32);
return;
}
Expand Down

0 comments on commit ffb34b6

Please sign in to comment.