summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2026-03-31 17:18:42 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2026-03-31 17:24:01 -0700
commit1389a36b51542f08cb031bd192d35122a0a70c07 (patch)
tree5f2102e07e72e7b13d169a3edf39ac94d6814772 /sprintf.c
parent6a5a2612fd6b0b8b707e0285d1a172e01469078c (diff)
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.
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sprintf.c b/sprintf.c
index de88a9f4b3..234aff76f5 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -440,8 +440,8 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
{
VALUE val = GETARG();
VALUE tmp;
- unsigned int c;
- int n, encidx;
+ unsigned int c = 0;
+ int n, encidx = 0;
tmp = rb_check_string_type(val);
if (!NIL_P(tmp)) {