[前][次][番号順一覧][スレッド一覧]

ruby-changes:35046

From: nobu <ko1@a...>
Date: Sun, 10 Aug 2014 13:48:16 +0900 (JST)
Subject: [ruby-changes:35046] nobu:r47128 (trunk): goruby.c: suppress warning

nobu	2014-08-10 13:48:10 +0900 (Sun, 10 Aug 2014)

  New Revision: 47128

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47128

  Log:
    goruby.c: suppress warning
    
    * goruby.c (goruby_options): check the result of `write(2)` to
      suppress unused-result warning.

  Modified files:
    trunk/goruby.c
Index: goruby.c
===================================================================
--- goruby.c	(revision 47127)
+++ goruby.c	(revision 47128)
@@ -32,12 +32,14 @@ goruby_options(int argc, char **argv) https://github.com/ruby/ruby/blob/trunk/goruby.c#L32
     void *ret;
 
     if ((isatty(0) && isatty(1) && isatty(2)) && (pipe(rw) == 0)) {
+	ssize_t n;
 	infd = dup(0);
+	if (infd < 0) return NULL;
 	dup2(rw[0], 0);
 	close(rw[0]);
-	write(rw[1], cmd, sizeof(cmd) - 1);
+	n = write(rw[1], cmd, sizeof(cmd) - 1);
 	close(rw[1]);
-	ret = ruby_options(argc, argv);
+	ret = n > 0 ? ruby_options(argc, argv) : NULL;
 	dup2(infd, 0);
 	close(infd);
 	return ret;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]