[PATCH 2/2] glusterfsd: fix GCC warning on read/write

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Liu Yuan <tailai.ly@xxxxxxxxxx>

With GCC 4.6.3, following warning is reported

ignoring return value of ‘read’, declared with attribute warn_unused_result...

This check the retval of read and if wrong, directly exit(1) and for write error,
log it.

Signed-off-by: Liu Yuan <tailai.ly@xxxxxxxxxx>
---
 glusterfsd/src/glusterfsd.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index 1015a13..c9e2e3d 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -1046,7 +1046,10 @@ emancipate (glusterfs_ctx_t *ctx, int ret)
 {
         /* break free from the parent */
         if (ctx->daemon_pipe[1] != -1) {
-                write (ctx->daemon_pipe[1], (void *) &ret, sizeof (ret));
+                if (write (ctx->daemon_pipe[1], (void *) &ret, sizeof (ret))
+                    != sizeof (ret))
+                        gf_log("glusterfsd", GF_LOG_ERROR,
+                               "emancipate write failed\n");
                 close (ctx->daemon_pipe[1]);
                 ctx->daemon_pipe[1] = -1;
         }
@@ -1706,7 +1709,9 @@ daemonize (glusterfs_ctx_t *ctx)
                 }
 
                 err = 1;
-                read (ctx->daemon_pipe[0], (void *)&err, sizeof (err));
+                ret = read (ctx->daemon_pipe[0], (void *)&err, sizeof (err));
+                if (ret != sizeof (err))
+                        _exit (1);
                 _exit (err);
         }
 
-- 
1.7.9.5




[Index of Archives]     [Gluster Users]     [Ceph Users]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux