Skip to content

Commit 244bf0a

Browse files
committed
goruby.c: suppress warning
* goruby.c (goruby_options): check the result of `write(2)` to suppress unused-result warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent ac574fe commit 244bf0a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

goruby.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ goruby_options(int argc, char **argv)
3232
void *ret;
3333

3434
if ((isatty(0) && isatty(1) && isatty(2)) && (pipe(rw) == 0)) {
35+
ssize_t n;
3536
infd = dup(0);
37+
if (infd < 0) return NULL;
3638
dup2(rw[0], 0);
3739
close(rw[0]);
38-
write(rw[1], cmd, sizeof(cmd) - 1);
40+
n = write(rw[1], cmd, sizeof(cmd) - 1);
3941
close(rw[1]);
40-
ret = ruby_options(argc, argv);
42+
ret = n > 0 ? ruby_options(argc, argv) : NULL;
4143
dup2(infd, 0);
4244
close(infd);
4345
return ret;

0 commit comments

Comments
 (0)