tests: fix warnings
authorGwanglim Lee <gl77.lee@samsung.com>
Fri, 27 May 2016 04:47:37 +0000 (13:47 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 16 Feb 2023 09:53:02 +0000 (18:53 +0900)
add checking values for read and write.
correct order of declaration for struct wl_closure.

Change-Id: I99e40210e387562ed2dbd050b7219e35d303c668

tests/test-runner.c

index d07dab1..3af7d68 100644 (file)
@@ -254,6 +254,7 @@ is_debugger_attached(void)
        int rc;
        pid_t pid;
        int pipefd[2];
+       int num;
 
        if (pipe(pipefd) == -1) {
                perror("pipe");
@@ -272,7 +273,9 @@ is_debugger_attached(void)
 
                /* Wait until parent is ready */
                close(pipefd[1]);  /* Close unused write end */
-               read(pipefd[0], &buf, 1);
+               num = read(pipefd[0], &buf, 1);
+               if (num < 0)
+                       _exit(1);
                close(pipefd[0]);
                if (buf == '-')
                        _exit(1);
@@ -295,10 +298,14 @@ is_debugger_attached(void)
                         * Then flag the error state to the client by sending '-'.
                         */
                        perror("prctl");
-                       write(pipefd[1], "-", 1);
+                       num = write(pipefd[1], "-", 1);
+                       if (num < 0)
+                               _exit(1);
                } else {
                        /* Signal to client that parent is ready by passing '+' */
-                       write(pipefd[1], "+", 1);
+                       num = write(pipefd[1], "+", 1);
+                       if (num < 0)
+                               _exit(1);
                }
                close(pipefd[1]);