diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-06 13:52:44 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-06 13:52:44 +0000 |
commit | 99526d0f4efbda4c809c33b4e387110996c32aba (patch) | |
tree | 9370d6eca48fe1b5eefd5a9353ee706e2fe480ee | |
parent | 7f41aa5f09619e84260e7310ecbc6212dc42c181 (diff) | |
download | ruby-99526d0f4efbda4c809c33b4e387110996c32aba.tar.gz |
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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | io.c | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -4678,12 +4678,9 @@ rb_io_binmode(VALUE io) 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) 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 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) 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) 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) 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; |