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

ruby-changes:20298

From: nobu <ko1@a...>
Date: Fri, 1 Jul 2011 08:03:29 +0900 (JST)
Subject: [ruby-changes:20298] nobu:r32346 (trunk): * error.c, thread_pthread.c (WRITE_CONST): suppress warnings

nobu	2011-07-01 08:03:23 +0900 (Fri, 01 Jul 2011)

  New Revision: 32346

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

  Log:
    * error.c, thread_pthread.c (WRITE_CONST): suppress warnings
      `ignoring return value'.

  Modified files:
    trunk/ChangeLog
    trunk/error.c
    trunk/thread_pthread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 32345)
+++ ChangeLog	(revision 32346)
@@ -1,3 +1,8 @@
+Fri Jul  1 08:03:15 2011  Nobuyoshi Nakada  <nobu@r...>
+
+	* error.c, thread_pthread.c (WRITE_CONST): suppress warnings
+	  `ignoring return value'.
+
 Fri Jul  1 06:41:36 2011  Koichi Sasada  <ko1@a...>
 
 	* thread.c (rb_threadptr_check_signal): only wake up main thread.
@@ -9,7 +14,7 @@
 	* bootstraptest/test_fork.rb: add a test for above.
 
 	* signal.c (rb_get_next_signal): skip if signal_buff is empty.
-	 (check signal_buff.size first)
+	  (check signal_buff.size first)
 
 	* vm_core.h: remove unused variable rb_thread_t::exec_signal.
 
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 32345)
+++ thread_pthread.c	(revision 32346)
@@ -994,7 +994,7 @@
 
 #define TT_DEBUG 0
 
-#define WRITE_CONST(fd, str) write((fd),(str),sizeof(str)-1);
+#define WRITE_CONST(fd, str) (void)(write((fd),(str),sizeof(str)-1)<0)
 
 /* only use signal-safe system calls here */
 void
Index: error.c
===================================================================
--- error.c	(revision 32345)
+++ error.c	(revision 32346)
@@ -295,12 +295,14 @@
  * this is safe to call inside signal handler and timer thread
  * (which isn't a Ruby Thread object)
  */
-#define WRITE_CONST(fd,str) write((fd),(str),sizeof(str) - 1)
+#define write_or_abort(fd, str, len) (write((fd), (str), (len)) < 0 ? abort() : (void)0)
+#define WRITE_CONST(fd,str) write_or_abort((fd),(str),sizeof(str) - 1)
 
-void rb_async_bug_errno(const char *mesg, int errno_arg)
+void
+rb_async_bug_errno(const char *mesg, int errno_arg)
 {
     WRITE_CONST(2, "[ASYNC BUG] ");
-    write(2, mesg, strlen(mesg));
+    write_or_abort(2, mesg, strlen(mesg));
     WRITE_CONST(2, "\n");
 
     if (errno_arg == 0) {
@@ -311,10 +313,10 @@
 
 	if (!errno_str)
 	    errno_str = "undefined errno";
-	write(2, errno_str, strlen(errno_str));
+	write_or_abort(2, errno_str, strlen(errno_str));
     }
     WRITE_CONST(2, "\n\n");
-    write(2, ruby_description, strlen(ruby_description));
+    write_or_abort(2, ruby_description, strlen(ruby_description));
     WRITE_CONST(2, "\n\n");
     WRITE_CONST(2, REPORTBUG_MSG);
     abort();

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

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