[Groonga-commit] groonga/groonga at 91d02ab [master] Handle the return value of write to suppress a warning

Back to archive index

Susumu Yata null+****@clear*****
Fri Feb 9 13:12:45 JST 2018


Susumu Yata	2018-02-09 13:12:45 +0900 (Fri, 09 Feb 2018)

  New Revision: 91d02ab340b81beab797f53736de7d2099f0b2c6
  https://github.com/groonga/groonga/commit/91d02ab340b81beab797f53736de7d2099f0b2c6

  Message:
    Handle the return value of write to suppress a warning
    
    This change suppresses the following warning (gcc):
      groonga.c: In function ‘send_ready_notify’:
      groonga.c:806:5: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
           write(ready_notify_pipe[PIPE_WRITE],
           ^

  Modified files:
    src/groonga.c

  Modified: src/groonga.c (+15 -4)
===================================================================
--- src/groonga.c    2018-02-09 12:49:28 +0900 (919c45b2f)
+++ src/groonga.c    2018-02-09 13:12:45 +0900 (0a6a2e1f7)
@@ -797,16 +797,27 @@ close_ready_notify_pipe(void)
   reset_ready_notify_pipe();
 }
 
-static void
+/* FIXME: callers ignore the return value of send_ready_notify. */
+static grn_bool
 send_ready_notify(void)
 {
   if (ready_notify_pipe[PIPE_WRITE] > 0) {
     const char *ready_notify_message = "ready";
-    write(ready_notify_pipe[PIPE_WRITE],
-          ready_notify_message,
-          strlen(ready_notify_message));
+    const size_t ready_notify_message_len = strlen(ready_notify_message);
+    size_t n = 0;
+    do {
+      ssize_t m = write(ready_notify_pipe[PIPE_WRITE],
+                        ready_notify_message + n,
+                        ready_notify_message_len - n);
+      if (m == -1) {
+        close_ready_notify_pipe();
+        return GRN_FALSE;
+      }
+      n += m;
+    } while (n < ready_notify_message_len);
   }
   close_ready_notify_pipe();
+  return GRN_TRUE;
 }
 
 static void
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180209/3a80a7c9/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index