Blame SOURCES/kvm-virtiofsd-Fix-fuse_daemonize-ignored-return-values.patch

902636
From 9f726593bc3acbc247876dcc4d79fbf046958003 Mon Sep 17 00:00:00 2001
902636
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
902636
Date: Mon, 27 Jan 2020 19:00:49 +0100
902636
Subject: [PATCH 018/116] virtiofsd: Fix fuse_daemonize ignored return values
902636
MIME-Version: 1.0
902636
Content-Type: text/plain; charset=UTF-8
902636
Content-Transfer-Encoding: 8bit
902636
902636
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
Message-id: <20200127190227.40942-15-dgilbert@redhat.com>
902636
Patchwork-id: 93469
902636
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 014/112] virtiofsd: Fix fuse_daemonize ignored return values
902636
Bugzilla: 1694164
902636
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
902636
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
902636
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
902636
902636
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
902636
902636
QEMU's compiler enables warnings/errors for ignored values
902636
and the (void) trick used in the fuse code isn't enough.
902636
Turn all the return values into a return value on the function.
902636
902636
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
902636
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
902636
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
902636
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
(cherry picked from commit 30d8e49760712d65697ea517c53671bd1d214fc7)
902636
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
902636
---
902636
 tools/virtiofsd/helper.c | 33 ++++++++++++++++++++++-----------
902636
 1 file changed, 22 insertions(+), 11 deletions(-)
902636
902636
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
902636
index 5e6f205..d9227d7 100644
902636
--- a/tools/virtiofsd/helper.c
902636
+++ b/tools/virtiofsd/helper.c
902636
@@ -10,12 +10,10 @@
902636
  * See the file COPYING.LIB.
902636
  */
902636
 
902636
-#include "config.h"
902636
 #include "fuse_i.h"
902636
 #include "fuse_lowlevel.h"
902636
 #include "fuse_misc.h"
902636
 #include "fuse_opt.h"
902636
-#include "mount_util.h"
902636
 
902636
 #include <errno.h>
902636
 #include <limits.h>
902636
@@ -171,6 +169,7 @@ int fuse_parse_cmdline(struct fuse_args *args, struct fuse_cmdline_opts *opts)
902636
 
902636
 int fuse_daemonize(int foreground)
902636
 {
902636
+    int ret = 0, rett;
902636
     if (!foreground) {
902636
         int nullfd;
902636
         int waiter[2];
902636
@@ -192,8 +191,8 @@ int fuse_daemonize(int foreground)
902636
         case 0:
902636
             break;
902636
         default:
902636
-            (void)read(waiter[0], &completed, sizeof(completed));
902636
-            _exit(0);
902636
+            _exit(read(waiter[0], &completed,
902636
+                       sizeof(completed) != sizeof(completed)));
902636
         }
902636
 
902636
         if (setsid() == -1) {
902636
@@ -201,13 +200,22 @@ int fuse_daemonize(int foreground)
902636
             return -1;
902636
         }
902636
 
902636
-        (void)chdir("/");
902636
+        ret = chdir("/");
902636
 
902636
         nullfd = open("/dev/null", O_RDWR, 0);
902636
         if (nullfd != -1) {
902636
-            (void)dup2(nullfd, 0);
902636
-            (void)dup2(nullfd, 1);
902636
-            (void)dup2(nullfd, 2);
902636
+            rett = dup2(nullfd, 0);
902636
+            if (!ret) {
902636
+                ret = rett;
902636
+            }
902636
+            rett = dup2(nullfd, 1);
902636
+            if (!ret) {
902636
+                ret = rett;
902636
+            }
902636
+            rett = dup2(nullfd, 2);
902636
+            if (!ret) {
902636
+                ret = rett;
902636
+            }
902636
             if (nullfd > 2) {
902636
                 close(nullfd);
902636
             }
902636
@@ -215,13 +223,16 @@ int fuse_daemonize(int foreground)
902636
 
902636
         /* Propagate completion of daemon initialization */
902636
         completed = 1;
902636
-        (void)write(waiter[1], &completed, sizeof(completed));
902636
+        rett = write(waiter[1], &completed, sizeof(completed));
902636
+        if (!ret) {
902636
+            ret = rett;
902636
+        }
902636
         close(waiter[0]);
902636
         close(waiter[1]);
902636
     } else {
902636
-        (void)chdir("/");
902636
+        ret = chdir("/");
902636
     }
902636
-    return 0;
902636
+    return ret;
902636
 }
902636
 
902636
 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
902636
-- 
902636
1.8.3.1
902636