From 01c0ca3b6cce1e0aab66dd64d021820507e5d9be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Csaba=20Osztrogon=C3=A1c?= Date: Mon, 19 Oct 2020 14:29:13 +0200 Subject: [PATCH] Fix sign-compare compiler warning in js-scanner-util.c (#4293) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found by mingw32-gcc (MinGW.org GCC Build-2) 9.2.0. comparison of integer expressions of different signedness: 'intptr_t' {aka 'int'} and 'unsigned int' [-Werror=sign-compare] JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu --- jerry-core/parser/js/js-scanner-util.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jerry-core/parser/js/js-scanner-util.c b/jerry-core/parser/js/js-scanner-util.c index 60d9dc872..4d0d213e1 100644 --- a/jerry-core/parser/js/js-scanner-util.c +++ b/jerry-core/parser/js/js-scanner-util.c @@ -758,11 +758,11 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */ intptr_t diff = (intptr_t) (literal_p->char_p - prev_source_p); - if (diff >= 1 && diff <= UINT8_MAX) + if (diff >= 1 && diff <= (intptr_t) UINT8_MAX) { compressed_size += 2 + 1; } - else if (diff >= -UINT8_MAX && diff <= (intptr_t) UINT16_MAX) + else if (diff >= -(intptr_t) UINT8_MAX && diff <= (intptr_t) UINT16_MAX) { compressed_size += 2 + 2; } @@ -1066,11 +1066,11 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */ intptr_t diff = (intptr_t) (literal_p->char_p - prev_source_p); - if (diff >= 1 && diff <= UINT8_MAX) + if (diff >= 1 && diff <= (intptr_t) UINT8_MAX) { data_p[-1] = (uint8_t) diff; } - else if (diff >= -UINT8_MAX && diff <= (intptr_t) UINT16_MAX) + else if (diff >= -(intptr_t) UINT8_MAX && diff <= (intptr_t) UINT16_MAX) { if (diff < 0) { @@ -2226,7 +2226,7 @@ scanner_check_variables (parser_context_t *context_p) /**< context */ { int32_t diff = ((int32_t) data_p[2]) | ((int32_t) data_p[3]) << 8; - if (diff <= UINT8_MAX) + if (diff <= (intptr_t) UINT8_MAX) { diff = -diff; } @@ -2463,7 +2463,7 @@ scanner_create_variables (parser_context_t *context_p, /**< context */ { int32_t diff = ((int32_t) data_p[2]) | ((int32_t) data_p[3]) << 8; - if (diff <= UINT8_MAX) + if (diff <= (intptr_t) UINT8_MAX) { diff = -diff; }