Skip to content

Commit 1389a36

Browse files
committed
sprintf.c: Fix -Wmaybe-uninitialized warnings in rb_str_format
Initialize `c` and `encidx` to 0. They are assigned inside `if (n >= 0)` and the following `if (n <= 0)` calls rb_raise, but the compiler cannot see through the noreturn guarantee.
1 parent 6a5a261 commit 1389a36

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

sprintf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
440440
{
441441
VALUE val = GETARG();
442442
VALUE tmp;
443-
unsigned int c;
444-
int n, encidx;
443+
unsigned int c = 0;
444+
int n, encidx = 0;
445445

446446
tmp = rb_check_string_type(val);
447447
if (!NIL_P(tmp)) {

0 commit comments

Comments
 (0)