Skip to content

Commit

Permalink
Fix -Wsign-compare on String#initialize
Browse files Browse the repository at this point in the history
../string.c:1886:57: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘long int’ [-Wsign-compare]
 1886 |                 if (STR_EMBED_P(str)) RUBY_ASSERT(osize <= str_embed_capa(str));
      |                                                         ^~
  • Loading branch information
k0kubun committed Feb 23, 2024
1 parent 38bf622 commit d5080f6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion string.c
Expand Up @@ -1883,7 +1883,7 @@ rb_str_init(int argc, VALUE *argv, VALUE str)
const char *const old_ptr = RSTRING_PTR(str);
const size_t osize = RSTRING_LEN(str) + TERM_LEN(str);
char *new_ptr = ALLOC_N(char, size);
if (STR_EMBED_P(str)) RUBY_ASSERT(osize <= str_embed_capa(str));
if (STR_EMBED_P(str)) RUBY_ASSERT((long)osize <= str_embed_capa(str));
memcpy(new_ptr, old_ptr, osize < size ? osize : size);
FL_UNSET_RAW(str, STR_SHARED|STR_NOFREE);
RSTRING(str)->as.heap.ptr = new_ptr;
Expand Down

0 comments on commit d5080f6

Please sign in to comment.