diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2019-10-05 07:00:57 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2019-10-05 07:00:57 +0900 |
commit | 417c64b9a8c4815a54f9bbef37f4438ee5c2f4fc (patch) | |
tree | 57785b0ccb6676e9daae2e9e4102d8ff0fdbd172 /ext/json | |
parent | 5717e55e9a7790c938afa694a9bf558c0e54bb83 (diff) | |
download | ruby-417c64b9a8c4815a54f9bbef37f4438ee5c2f4fc.tar.gz |
ext/json/parser/parser.rl: Use "signed" char to contain negative values
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;
^
```
Diffstat (limited to 'ext/json')
-rw-r--r-- | ext/json/parser/parser.c | 4 | ||||
-rw-r--r-- | ext/json/parser/parser.rl | 4 |
2 files changed, 4 insertions, 4 deletions
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; |