From 0b913c650dae1c744a378a8e153ce2fcb8fe7c6a Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 10 Apr 2012 16:48:28 +0200 Subject: [PATCH] Check write(2) return value to avoid warnings, because in this context failing write is not critical. --- src/redis.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/redis.c b/src/redis.c index ea5525dcfb8..eaa41a5dfe6 100644 --- a/src/redis.c +++ b/src/redis.c @@ -318,14 +318,15 @@ void redisLogFromHandler(int level, const char *msg) { STDOUT_FILENO; if (fd == -1) return; ll2string(buf,sizeof(buf),getpid()); - write(fd,"[",1); - write(fd,buf,strlen(buf)); - write(fd," | signal handler] (",20); + if (write(fd,"[",1) == -1) goto err; + if (write(fd,buf,strlen(buf)) == -1) goto err; + if (write(fd," | signal handler] (",20) == -1) goto err; ll2string(buf,sizeof(buf),time(NULL)); - write(fd,buf,strlen(buf)); - write(fd,") ",2); - write(fd,msg,strlen(msg)); - write(fd,"\n",1); + if (write(fd,buf,strlen(buf)) == -1) goto err; + if (write(fd,") ",2) == -1) goto err; + if (write(fd,msg,strlen(msg)) == -1) goto err; + if (write(fd,"\n",1) == -1) goto err; +err: if (server.logfile) close(fd); }