diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-11-06 19:56:34 +0900 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2024-11-06 23:31:30 +0100 |
commit | 29d76d8c8b9e45f51a2fa6819b3854f2423239b0 () | |
tree | fe7189c1ee7e25053f68ef092fceae7de607c125 /ext/json | |
parent | 6cea370b23b4adee92d5c43be9637cb24769f7d1 (diff) |
[ruby/json] Fix right shift warnings
Ignoring `CHAR_BITS` > 8 platform, as far as `ch` indexes `escape_table` that is hard-coded as 256 elements. ``` ../../../../src/ext/json/generator/generator.c(121): warning C4333: '>>': right shift by too large amount, data loss ../../../../src/ext/json/generator/generator.c(122): warning C4333: '>>': right shift by too large amount, data loss ../../../../src/ext/json/generator/generator.c(243): warning C4333: '>>': right shift by too large amount, data loss ../../../../src/ext/json/generator/generator.c(244): warning C4333: '>>': right shift by too large amount, data loss ../../../../src/ext/json/generator/generator.c(291): warning C4333: '>>': right shift by too large amount, data loss ../../../../src/ext/json/generator/generator.c(292): warning C4333: '>>': right shift by too large amount, data loss ``` https://.com/ruby/json/commit/fb82373612
-rw-r--r-- | ext/json/generator/generator.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -118,8 +118,8 @@ static void convert_UTF8_to_JSON(FBuffer *out_buffer, VALUE str, const char esca case '\r': fbuffer_append(out_buffer, "\\r", 2); break; case '\t': fbuffer_append(out_buffer, "\\t", 2); break; default: { - scratch[2] = hexdig[ch >> 12]; - scratch[3] = hexdig[(ch >> 8) & 0xf]; scratch[4] = hexdig[(ch >> 4) & 0xf]; scratch[5] = hexdig[ch & 0xf]; fbuffer_append(out_buffer, scratch, 6); @@ -240,8 +240,8 @@ static void convert_ASCII_to_JSON(FBuffer *out_buffer, VALUE str, const char esc case '\r': fbuffer_append(out_buffer, "\\r", 2); break; case '\t': fbuffer_append(out_buffer, "\\t", 2); break; default: - scratch[2] = hexdig[ch >> 12]; - scratch[3] = hexdig[(ch >> 8) & 0xf]; scratch[4] = hexdig[(ch >> 4) & 0xf]; scratch[5] = hexdig[ch & 0xf]; fbuffer_append(out_buffer, scratch, 6); @@ -288,8 +288,8 @@ static void convert_UTF8_to_ASCII_only_JSON(FBuffer *out_buffer, VALUE str, cons case '\r': fbuffer_append(out_buffer, "\\r", 2); break; case '\t': fbuffer_append(out_buffer, "\\t", 2); break; default: { - scratch[2] = hexdig[ch >> 12]; - scratch[3] = hexdig[(ch >> 8) & 0xf]; scratch[4] = hexdig[(ch >> 4) & 0xf]; scratch[5] = hexdig[ch & 0xf]; fbuffer_append(out_buffer, scratch, 6); |