[Libguestfs] [PATCH 13/13] daemon: Keep Coverity happy by ignoring some return values.

Richard W.M. Jones rjones at redhat.com
Thu Jun 9 10:17:12 UTC 2011


---
 daemon/command.c  |   18 +++++++++++++-----
 daemon/guestfsd.c |    2 +-
 daemon/swap.c     |    4 +++-
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/daemon/command.c b/daemon/command.c
index 5a194a4..ef23695 100644
--- a/daemon/command.c
+++ b/daemon/command.c
@@ -26,6 +26,14 @@
 #include "daemon.h"
 #include "actions.h"
 
+#include "ignore-value.h"
+
+static inline void
+umount_ignore_fail (const char *path)
+{
+  ignore_value (command (NULL, NULL, "umount", path, NULL));
+}
+
 char *
 do_command (char *const *argv)
 {
@@ -88,11 +96,11 @@ do_command (char *const *argv)
   r = commandv (&out, &err, (const char * const *) argv);
   CHROOT_OUT;
 
-  if (sys_ok) command (NULL, NULL, "umount", sysroot_sys, NULL);
-  if (selinux_ok) command (NULL, NULL, "umount", sysroot_selinux, NULL);
-  if (proc_ok) command (NULL, NULL, "umount", sysroot_proc, NULL);
-  if (dev_pts_ok) command (NULL, NULL, "umount", sysroot_dev_pts, NULL);
-  if (dev_ok) command (NULL, NULL, "umount", sysroot_dev, NULL);
+  if (sys_ok) umount_ignore_fail (sysroot_sys);
+  if (selinux_ok) umount_ignore_fail (sysroot_selinux);
+  if (proc_ok) umount_ignore_fail (sysroot_proc);
+  if (dev_pts_ok) umount_ignore_fail (sysroot_dev_pts);
+  if (dev_ok) umount_ignore_fail (sysroot_dev);
 
   free (sysroot_dev);
   free (sysroot_dev_pts);
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 116a6b9..eb1e82b 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -689,7 +689,7 @@ commandrvf (char **stdoutput, char **stderror, int flags,
       close (stdin_fd[1]);
     } else {
       /* Set stdin to /dev/null (ignore failure) */
-      open ("/dev/null", O_RDONLY);
+      ignore_value (open ("/dev/null", O_RDONLY));
     }
     close (so_fd[0]);
     close (se_fd[0]);
diff --git a/daemon/swap.c b/daemon/swap.c
index 9077814..99fb563 100644
--- a/daemon/swap.c
+++ b/daemon/swap.c
@@ -28,6 +28,8 @@
 #include "actions.h"
 #include "optgroups.h"
 
+#include "ignore-value.h"
+
 /* Confirmed this is true for Linux swap partitions from the Linux sources. */
 #define SWAP_LABEL_MAX 16
 
@@ -42,7 +44,7 @@ optgroup_linuxfsuuid_available (void)
   int av;
 
   /* Ignore return code - mkswap --help *will* fail. */
-  command (NULL, &err, "mkswap", "--help", NULL);
+  ignore_value (command (NULL, &err, "mkswap", "--help", NULL));
 
   av = strstr (err, "-U") != NULL;
   free (err);
-- 
1.7.5.1




More information about the Libguestfs mailing list