From 417c64b9a8c4815a54f9bbef37f4438ee5c2f4fc Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sat, 5 Oct 2019 07:00:57 +0900 Subject: ext/json/parser/parser.rl: Use "signed" char to contain negative values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit char is not always signed. In fact, it is unsigned in arm. https://rubyci.org/logs/rubyci.s3.amazonaws.com/scw-9d6766/ruby-master/log/20191004T181708Z.log.html.gz ``` compiling parser.c parser.rl: In function ‘unescape_unicode’: parser.rl:50:5: warning: comparison is always false due to limited range of data type [-Wtype-limits] if (b < 0) return UNI_REPLACEMENT_CHAR; ^ ``` --- ext/json/parser/parser.c | 4 ++-- ext/json/parser/parser.rl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'ext/json/parser') diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c index fb10491d14..cb91a2e559 100644 --- a/ext/json/parser/parser.c +++ b/ext/json/parser/parser.c @@ -28,7 +28,7 @@ enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...) /* unicode */ -static const char digit_values[256] = { +static const signed char digit_values[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, @@ -47,7 +47,7 @@ static const char digit_values[256] = { static UTF32 unescape_unicode(const unsigned char *p) { - char b; + signed char b; UTF32 result = 0; b = digit_values[p[0]]; if (b < 0) return UNI_REPLACEMENT_CHAR; diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl index b33860c755..e634f44b80 100644 --- a/ext/json/parser/parser.rl +++ b/ext/json/parser/parser.rl @@ -25,7 +25,7 @@ enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...) /* unicode */ -static const char digit_values[256] = { +static const signed char digit_values[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, @@ -44,7 +44,7 @@ static const char digit_values[256] = { static UTF32 unescape_unicode(const unsigned char *p) { - char b; + signed char b; UTF32 result = 0; b = digit_values[p[0]]; if (b < 0) return UNI_REPLACEMENT_CHAR; -- cgit v1.2.3