ruby-changes:31078
From: nobu <ko1@a...>
Date: Sun, 6 Oct 2013 22:52:59 +0900 (JST)
Subject: [ruby-changes:31078] nobu:r43157 (trunk): io.c: suppress false uninitialized-variable warning
nobu 2013-10-06 22:52:44 +0900 (Sun, 06 Oct 2013) New Revision: 43157 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43157 Log: io.c: suppress false uninitialized-variable warning * io.c (io_ascii8bit_binmode): split from rb_io_ascii8bit_binmode() to call with rb_io_t* directly. * io.c (copy_stream_body): move src_io and dst_io into each blocks where those are only used. Modified files: trunk/io.c Index: io.c =================================================================== --- io.c (revision 43156) +++ io.c (revision 43157) @@ -4678,12 +4678,9 @@ rb_io_binmode(VALUE io) https://github.com/ruby/ruby/blob/trunk/io.c#L4678 return io; } -VALUE -rb_io_ascii8bit_binmode(VALUE io) +static void +io_ascii8bit_binmode(rb_io_t *fptr) { - rb_io_t *fptr; - - GetOpenFile(io, fptr); if (fptr->readconv) { rb_econv_close(fptr->readconv); fptr->readconv = NULL; @@ -4701,6 +4698,15 @@ rb_io_ascii8bit_binmode(VALUE io) https://github.com/ruby/ruby/blob/trunk/io.c#L4698 fptr->encs.ecflags = 0; fptr->encs.ecopts = Qnil; clear_codeconv(fptr); +} + +VALUE +rb_io_ascii8bit_binmode(VALUE io) +{ + rb_io_t *fptr; + + GetOpenFile(io, fptr); + io_ascii8bit_binmode(fptr); return io; } @@ -10259,7 +10265,6 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/io.c#L10265 copy_stream_body(VALUE arg) { struct copy_stream_struct *stp = (struct copy_stream_struct *)arg; - VALUE src_io, dst_io; rb_io_t *src_fptr = 0, *dst_fptr = 0; int src_fd, dst_fd; const int common_oflags = 0 @@ -10279,8 +10284,8 @@ copy_stream_body(VALUE arg) https://github.com/ruby/ruby/blob/trunk/io.c#L10284 src_fd = -1; } else { - src_io = RB_TYPE_P(stp->src, T_FILE) ? stp->src : Qnil; - if (NIL_P(src_io)) { + VALUE src_io = stp->src; + if (!RB_TYPE_P(src_io, T_FILE)) { VALUE args[2]; const int oflags = O_RDONLY|common_oflags; FilePathValue(stp->src); @@ -10303,8 +10308,8 @@ copy_stream_body(VALUE arg) https://github.com/ruby/ruby/blob/trunk/io.c#L10308 dst_fd = -1; } else { - dst_io = RB_TYPE_P(stp->dst, T_FILE) ? stp->dst : Qnil; - if (NIL_P(dst_io)) { + VALUE dst_io = stp->dst; + if (!RB_TYPE_P(stp->dst, T_FILE)) { VALUE args[3]; const int oflags = O_WRONLY|O_CREAT|O_TRUNC|common_oflags; FilePathValue(stp->dst); @@ -10330,7 +10335,7 @@ copy_stream_body(VALUE arg) https://github.com/ruby/ruby/blob/trunk/io.c#L10335 SET_BINARY_MODE_WITH_SEEK_CUR(src_fptr); #endif if (dst_fptr) - rb_io_ascii8bit_binmode(dst_io); + io_ascii8bit_binmode(dst_fptr); if (stp->src_offset == (off_t)-1 && src_fptr && src_fptr->rbuf.len) { size_t len = src_fptr->rbuf.len; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/