Skip to content

Commit 3c645fa

Browse files
authored
build: fix char signed vs unsigned warning (#23675)
char defaults to signed on most x86 platforms, but unsigned on arm64. When targeting linux arm64 this produced a warning because character was always >= 0. This change circumvents this warning without changing behavior even though it seems pretty unreasonable to have a character less than 0 in this use case. Theoretically we could disable a warning flag instead but that differs between clang and gcc. Fixes #23569 Signed-off-by: Keith Smiley <[email protected]> Signed-off-by: Keith Smiley <[email protected]>
1 parent cfc2c3e commit 3c645fa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

source/common/common/json_escape_string.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class JsonEscaper {
6464
position += 2;
6565
break;
6666
default:
67-
if (character >= 0x00 && character <= 0x1f) {
67+
if (character == 0x00 || (character > 0x00 && character <= 0x1f)) {
6868
// Print character as unicode hex.
6969
sprintf(&result[position + 1], "u%04x", static_cast<int>(character));
7070
position += 6;
@@ -107,7 +107,7 @@ class JsonEscaper {
107107
}
108108

109109
default: {
110-
if (character >= 0x00 && character <= 0x1f) {
110+
if (character == 0x00 || (character > 0x00 && character <= 0x1f)) {
111111
// From character (1 byte) to unicode hex (6 bytes).
112112
result += 5;
113113
}

0 commit comments

Comments
 (0)