render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
9119d9
From 19510519252e120e5eecc47029abce0b99754566 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <19510519252e120e5eecc47029abce0b99754566@dist-git>
9119d9
From: John Ferlan <jferlan@redhat.com>
9119d9
Date: Mon, 15 Sep 2014 15:13:48 -0400
9119d9
Subject: [PATCH] virfile: Resolve Coverity DEADCODE
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1141209
9119d9
9119d9
Adjust the parentheses in/for the waitpid loops; otherwise, Coverity
9119d9
points out:
9119d9
9119d9
(1) Event assignment:   Assigning: "waitret" = "waitpid(pid, &status, 0) == -1"
9119d9
(2) Event between:      At condition "waitret == -1", the value of "waitret"
9119d9
                        must be between 0 and 1.
9119d9
(3) Event dead_error_condition:     The condition "waitret == -1" cannot
9119d9
                        be true.
9119d9
(4) Event dead_error_begin:     Execution cannot reach this statement:
9119d9
                        "ret = -*__errno_location();".
9119d9
9119d9
Signed-off-by: John Ferlan <jferlan@redhat.com>
9119d9
(cherry picked from commit 6825bdad13aff56b1388fa17582595776cf25b52)
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/util/virfile.c | 5 ++---
9119d9
 1 file changed, 2 insertions(+), 3 deletions(-)
9119d9
9119d9
diff --git a/src/util/virfile.c b/src/util/virfile.c
9119d9
index b6f5e3f..fdbb7e3 100644
9119d9
--- a/src/util/virfile.c
9119d9
+++ b/src/util/virfile.c
9119d9
@@ -2073,8 +2073,7 @@ virFileOpenForked(const char *path, int openflags, mode_t mode,
9119d9
     }
9119d9
 
9119d9
     /* wait for child to complete, and retrieve its exit code */
9119d9
-    while ((waitret = waitpid(pid, &status, 0) == -1)
9119d9
-           && (errno == EINTR));
9119d9
+    while ((waitret = waitpid(pid, &status, 0)) == -1 && errno == EINTR);
9119d9
     if (waitret == -1) {
9119d9
         ret = -errno;
9119d9
         virReportSystemError(errno,
9119d9
@@ -2291,7 +2290,7 @@ virDirCreate(const char *path,
9119d9
     if (pid) { /* parent */
9119d9
         /* wait for child to complete, and retrieve its exit code */
9119d9
         VIR_FREE(groups);
9119d9
-        while ((waitret = waitpid(pid, &status, 0) == -1)  && (errno == EINTR));
9119d9
+        while ((waitret = waitpid(pid, &status, 0)) == -1 && errno == EINTR);
9119d9
         if (waitret == -1) {
9119d9
             ret = -errno;
9119d9
             virReportSystemError(errno,
9119d9
-- 
9119d9
2.1.0
9119d9