From: Peter Pentchev Date: Sun, 22 Aug 2021 11:51:11 +0000 (+0300) Subject: Properly detect a read error. X-Git-Tag: archive/raspbian/1.2.1+ds1-1+rpi1^2~7^2~1^2~23^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=07ce3eb6c3e388ba5063585ba9f22dd26e340975;p=zchunk.git Properly detect a read error. Spotted by: cppcheck --- diff --git a/src/lib/io.c b/src/lib/io.c index 5925d51..b91b7ca 100644 --- a/src/lib/io.c +++ b/src/lib/io.c @@ -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; }