Skip to content

Commit 8bd27c5

Browse files
committed
ext/json/parser/prereq.mk: remove type-limit warning if char is unsigned
Ragel generates a code `0 <= (*p)` where `*p` is char. As char is unsigned by default on arm and RISC-V, it is warned by gcc: ``` compiling parser.c parser.c: In function ‘JSON_parse_string’: parser.c:1566:2: warning: comparison is always true due to limited range of data type [-Wtype-limits] if ( 0 <= (*p) && (*p) <= 31 ) ^ parser.c:1596:2: warning: comparison is always true due to limited range of data type [-Wtype-limits] if ( 0 <= (*p) && (*p) <= 31 ) ^ ``` This change removes the warning by substituting the condition with `0 <= (signed char)(*p)`.
1 parent 8766213 commit 8bd27c5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

ext/json/parser/parser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ case 2:
15631563
case 34: goto tr2;
15641564
case 92: goto st3;
15651565
}
1566-
if ( 0 <= (*p) && (*p) <= 31 )
1566+
if ( 0 <= (signed char)(*p) && (*p) <= 31 )
15671567
goto st0;
15681568
goto st2;
15691569
tr2:
@@ -1593,7 +1593,7 @@ case 8:
15931593
case 3:
15941594
if ( (*p) == 117 )
15951595
goto st4;
1596-
if ( 0 <= (*p) && (*p) <= 31 )
1596+
if ( 0 <= (signed char)(*p) && (*p) <= 31 )
15971597
goto st0;
15981598
goto st2;
15991599
st4:

ext/json/parser/prereq.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ RAGEL = ragel
66
$(RAGEL) -G2 $<
77
$(BASERUBY) -pli -e '$$_.sub!(/[ \t]+$$/, "")' \
88
-e '$$_.sub!(/^static const int (JSON_.*=.*);$$/, "enum {\\1};")' \
9+
-e '$$_.sub!(/0 <= \(\*p\) && \(\*p\) <= 31/, "0 <= (signed char)(*p) && (*p) <= 31")' \
910
-e '$$_ = "/* This file is automatically generated from parser.rl by using ragel */" + $$_ if $$. == 1' $@
1011

1112
parser.c:

0 commit comments

Comments
 (0)