Fix some nits reported by cppcheck.
authorPeter Pentchev <roam@ringlet.net>
Sun, 22 Aug 2021 12:15:59 +0000 (15:15 +0300)
committerPeter Pentchev <roam@debian.org>
Sun, 22 Aug 2021 12:15:59 +0000 (15:15 +0300)
Forwarded: https://github.com/zchunk/zchunk/pull/46
Last-Update: 2021-08-22

Gbp-Pq: Name cppcheck.patch

src/lib/comp/zstd/zstd.c
src/lib/io.c
test/read_single_chunk.c

index 628edc75b83df41ceb4868068829b5202ff6d678..921426fcfc489a61806e279590e8cbfa31c2a412 100644 (file)
@@ -37,7 +37,9 @@ static bool init(zckCtx *zck, zckComp *comp) {
     VALIDATE_BOOL(zck);
     ALLOCD_BOOL(zck, comp);
 
+#ifndef OLD_ZSTD
     size_t retval = 0;
+#endif
 
     comp->cctx = ZSTD_createCCtx();
 #ifndef OLD_ZSTD
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;
 }
index 3e83971731de075dfb3135ce339a8c234c6fcfbb..432cb5df3657d4d6fc1975c07e374576102b67bd 100644 (file)
@@ -69,7 +69,7 @@ int main (int argc, char *argv[]) {
         exit(1);
     }
     zckChunk *chunk1 = zck_get_chunk(zck, 1);
-    if(chunk == NULL) {
+    if(chunk1 == NULL) {
         printf("%s", zck_get_error(zck));
         zck_free(&zck);
         exit(1);