From e1b65011835cf2881f932cd9545f12100be57c47 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 5 Jan 2024 13:03:33 +0900 Subject: [PATCH] mruby-io: fix local variable initialization redundancy --- mrbgems/mruby-io/src/io.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mrbgems/mruby-io/src/io.c b/mrbgems/mruby-io/src/io.c index 8d04ed3af..265716cdf 100644 --- a/mrbgems/mruby-io/src/io.c +++ b/mrbgems/mruby-io/src/io.c @@ -1220,26 +1220,22 @@ time2timeval(mrb_state *mrb, mrb_value time) static mrb_value io_s_pipe(mrb_state *mrb, mrb_value klass) { - mrb_value r = mrb_nil_value(); - mrb_value w = mrb_nil_value(); - struct mrb_io *fptr_r; - struct mrb_io *fptr_w; int pipes[2]; if (io_pipe(mrb, pipes) == -1) { mrb_sys_fail(mrb, "pipe"); } - r = mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type)); - fptr_r = io_alloc(mrb); + mrb_value r = mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type)); + struct mrb_io *fptr_r = io_alloc(mrb); fptr_r->fd = pipes[0]; fptr_r->readable = 1; DATA_TYPE(r) = &mrb_io_type; DATA_PTR(r) = fptr_r; io_init_buf(mrb, fptr_r); - w = mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type)); - fptr_w = io_alloc(mrb); + mrb_value w = mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type)); + struct mrb_io *fptr_w = io_alloc(mrb); fptr_w->fd = pipes[1]; fptr_w->writable = 1; fptr_w->sync = 1;