[Gluster-devel] [PATCH 2/2] glusterfsd: fix GCC warning on read/write
Liu Yuan
namei.unix at gmail.com
Tue Nov 13 11:39:12 UTC 2012
From: Liu Yuan <tailai.ly at taobao.com>
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 at taobao.com>
---
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
More information about the Gluster-devel
mailing list