summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2020-05-14 00:44:35 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-25 16:51:04 +0900
commit14fadad26a6e3a6ce5fa4e0286b2ce4336052177 (patch)
tree91703bc622b6649c21bdea9f996ae1a2247bd711
parent0baa541081e0ceaf2f8af283d40462654557ea16 (diff)
downloadjson-14fadad26a6e3a6ce5fa4e0286b2ce4336052177.tar.gz
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)`. ruby/ruby@8bd27c547c3260ce72dc5edbab248bb858c84cf2
-rw-r--r--Rakefile1
-rw-r--r--ext/json/ext/parser/parser.c4
2 files changed, 3 insertions, 2 deletions
diff --git a/Rakefile b/Rakefile
index 2b68818..0945a67 100644
--- a/Rakefile
+++ b/Rakefile
@@ -331,6 +331,7 @@ else
end
src = File.read("parser.c").gsub(/[ \t]+$/, '')
src.gsub!(/^static const int (JSON_.*=.*);$/, 'enum {\1};')
+ src.gsub!(/0 <= \(\*p\) && \(\*p\) <= 31/, "0 <= (signed char)(*p) && (*p) <= 31")
src[0, 0] = "/* This file is automatically generated from parser.rl by using ragel */"
File.open("parser.c", "w") {|f| f.print src}
end
diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c
index 0f98cf9..e4a3056 100644
--- a/ext/json/ext/parser/parser.c
+++ b/ext/json/ext/parser/parser.c
@@ -1563,7 +1563,7 @@ case 2:
case 34: goto tr2;
case 92: goto st3;
}
- if ( 0 <= (*p) && (*p) <= 31 )
+ if ( 0 <= (signed char)(*p) && (*p) <= 31 )
goto st0;
goto st2;
tr2:
@@ -1593,7 +1593,7 @@ st3:
case 3:
if ( (*p) == 117 )
goto st4;
- if ( 0 <= (*p) && (*p) <= 31 )
+ if ( 0 <= (signed char)(*p) && (*p) <= 31 )
goto st0;
goto st2;
st4: