]> git.ozlabs.org Git - ccan/commitdiff
pipecmd: fix warn-unused-result warnings (-O2)
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 25 Oct 2016 04:46:07 +0000 (15:16 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 25 Oct 2016 04:46:07 +0000 (15:16 +1030)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/pipecmd/_info
ccan/pipecmd/pipecmd.c

index 4621d72fc3b94d78192a8eb33fb9bec60309a600..a560bfea05ccc4e53807dde67d0546c48b6f0246 100644 (file)
@@ -28,7 +28,8 @@
  *     char input[12];
  *
  *     if (argc == 2) {
- *             write(STDOUT_FILENO, "hello world\n", 12);
+ *             if (write(STDOUT_FILENO, "hello world\n", 12) != 12)
+ *                     exit(1);
  *             exit(0);
  *     }
  *     child = pipecmd(&outputfd, NULL, NULL, argv[0], "ignoredarg", NULL);
index e8aec15b4e7f62993489de618a445439ac06c8c7..22903bb34627b0df674f7c14b78dfe7a7907bb74 100644 (file)
@@ -122,7 +122,9 @@ pid_t pipecmdarr(int *fd_fromchild, int *fd_tochild, int *fd_errfromchild,
 
        child_errno_fail:
                err = errno;
-               write(execfail[1], &err, sizeof(err));
+               /* Gcc's warn-unused-result fail. */
+               if (write(execfail[1], &err, sizeof(err)))
+                       ;
                exit(127);
        }