]> git.saurik.com Git - redis.git/commitdiff
Check write(2) return value to avoid warnings, because in this context failing write...
authorantirez <antirez@gmail.com>
Tue, 10 Apr 2012 14:48:28 +0000 (16:48 +0200)
committerantirez <antirez@gmail.com>
Tue, 10 Apr 2012 18:02:33 +0000 (20:02 +0200)
src/redis.c

index 43487bc8ee31d41c0b8fa39da9815c3ab8b96c33..bfac279f490cb459b140983b56d005a1552dda0b 100644 (file)
@@ -316,14 +316,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);
 }