]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virfile: Resolve Coverity DEADCODE
authorJohn Ferlan <jferlan@redhat.com>
Thu, 4 Sep 2014 18:46:34 +0000 (14:46 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 11 Sep 2014 12:03:37 +0000 (08:03 -0400)
Adjust the parentheses in/for the waitpid loops; otherwise, Coverity
points out:

(1) Event assignment:   Assigning: "waitret" = "waitpid(pid, &status, 0) == -1"
(2) Event between:      At condition "waitret == -1", the value of "waitret"
                        must be between 0 and 1.
(3) Event dead_error_condition:     The condition "waitret == -1" cannot
                        be true.
(4) Event dead_error_begin:     Execution cannot reach this statement:
                        "ret = -*__errno_location();".

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/util/virfile.c

index cfb6cc10246a1926bd7a381153c6cd75ec94c444..7c506c9a78374cd047f168e4190ca1f85b86d2fa 100644 (file)
@@ -2072,8 +2072,7 @@ virFileOpenForked(const char *path, int openflags, mode_t mode,
     }
 
     /* wait for child to complete, and retrieve its exit code */
-    while ((waitret = waitpid(pid, &status, 0) == -1)
-           && (errno == EINTR));
+    while ((waitret = waitpid(pid, &status, 0)) == -1 && errno == EINTR);
     if (waitret == -1) {
         ret = -errno;
         virReportSystemError(errno,
@@ -2290,7 +2289,7 @@ virDirCreate(const char *path,
     if (pid) { /* parent */
         /* wait for child to complete, and retrieve its exit code */
         VIR_FREE(groups);
-        while ((waitret = waitpid(pid, &status, 0) == -1)  && (errno == EINTR));
+        while ((waitret = waitpid(pid, &status, 0)) == -1 && errno == EINTR);
         if (waitret == -1) {
             ret = -errno;
             virReportSystemError(errno,