Properly detect a read error.
authorPeter Pentchev <roam@ringlet.net>
Sun, 22 Aug 2021 11:51:11 +0000 (14:51 +0300)
committerPeter Pentchev <roam@ringlet.net>
Sun, 22 Aug 2021 11:51:11 +0000 (14:51 +0300)
Spotted by: cppcheck

src/lib/io.c

index 5925d513743ab06be944b6a627b1f0387e95bb78..b91b7ca4f3cc64deacd0c3136186deb77557eaf7 100644 (file)
@@ -115,11 +115,13 @@ int chunks_from_temp(zckCtx *zck) {
     char *data = zmalloc(BUF_SIZE);
 
     while((read_count = read(zck->temp_fd, data, BUF_SIZE)) > 0) {
-        if(read_count == -1 || !write_data(zck, zck->fd, data, read_count)) {
+        if(!write_data(zck, zck->fd, data, read_count)) {
             free(data);
             return false;
         }
     }
     free(data);
+    if(read_count == -1)
+        return false;
     return true;
 }