diff --git a/lib/zip_add_entry.c b/lib/zip_add_entry.c index bf12dd541..24e564867 100644 --- a/lib/zip_add_entry.c +++ b/lib/zip_add_entry.c @@ -64,7 +64,7 @@ _zip_add_entry(zip_t *za) { return -1; } rentries = (zip_entry_t *)realloc(za->entry, sizeof(struct zip_entry) * (size_t)nalloc); - if (!rentries) { + if (rentries == NULL) { zip_error_set(&za->error, ZIP_ER_MEMORY, 0); return -1; } diff --git a/lib/zip_dirent.c b/lib/zip_dirent.c index f5f23cb3a..41d4e7e96 100644 --- a/lib/zip_dirent.c +++ b/lib/zip_dirent.c @@ -51,8 +51,9 @@ void _zip_cdir_free(zip_cdir_t *cd) { zip_uint64_t i; - if (!cd) + if (cd == NULL) { return; + } for (i = 0; i < cd->nentry; i++) _zip_entry_finalize(cd->entry + i); @@ -139,6 +140,7 @@ _zip_cdir_write(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivor zip_entry_t *entry = za->entry + filelist[i].idx; if (_zip_dirent_write(za, entry->changes ? entry->changes : entry->orig, ZIP_FL_CENTRAL) < 0) { + za->write_crc = NULL; return -1; } } @@ -446,7 +448,7 @@ _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, boo if (filename_len) { zde->filename = _zip_read_string(buffer, src, filename_len, 1, error); - if (!zde->filename) { + if (zde->filename == NULL) { if (zip_error_code_zip(error) == ZIP_ER_EOF) { zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_VARIABLE_SIZE_OVERFLOW); } @@ -490,7 +492,7 @@ _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, boo if (comment_len) { zde->comment = _zip_read_string(buffer, src, comment_len, 0, error); - if (!zde->comment) { + if (zde->comment == NULL) { if (!from_buffer) { _zip_buffer_free(buffer); } diff --git a/lib/zip_fread.c b/lib/zip_fread.c index 5b7da46ae..53c8002a7 100644 --- a/lib/zip_fread.c +++ b/lib/zip_fread.c @@ -39,11 +39,13 @@ ZIP_EXTERN zip_int64_t zip_fread(zip_file_t *zf, void *outbuf, zip_uint64_t toread) { zip_int64_t n; - if (!zf) + if (zf == NULL) { return -1; + } - if (zf->error.zip_err != 0) + if (zf->error.zip_err != 0) { return -1; + } if (toread > ZIP_INT64_MAX) { zip_error_set(&zf->error, ZIP_ER_INVAL, 0); diff --git a/lib/zip_fseek.c b/lib/zip_fseek.c index e68ffd367..c21bbab15 100644 --- a/lib/zip_fseek.c +++ b/lib/zip_fseek.c @@ -36,11 +36,13 @@ ZIP_EXTERN zip_int8_t zip_fseek(zip_file_t *zf, zip_int64_t offset, int whence) { - if (!zf) + if (zf == NULL) { return -1; + } - if (zf->error.zip_err != 0) + if (zf->error.zip_err != 0) { return -1; + } if (zip_source_seek(zf->src, offset, whence) < 0) { zip_error_set_from_source(&zf->error, zf->src); @@ -53,7 +55,7 @@ zip_fseek(zip_file_t *zf, zip_int64_t offset, int whence) { ZIP_EXTERN int zip_file_is_seekable(zip_file_t *zfile) { - if (!zfile) { + if (zfile == NULL) { return -1; } diff --git a/lib/zip_ftell.c b/lib/zip_ftell.c index bf3b03d34..f5109ad5a 100644 --- a/lib/zip_ftell.c +++ b/lib/zip_ftell.c @@ -38,11 +38,13 @@ ZIP_EXTERN zip_int64_t zip_ftell(zip_file_t *zf) { zip_int64_t res; - if (!zf) + if (zf == NULL) { return -1; + } - if (zf->error.zip_err != 0) + if (zf->error.zip_err != 0) { return -1; + } res = zip_source_tell(zf->src); if (res < 0) { diff --git a/lib/zip_io_util.c b/lib/zip_io_util.c index 9fcd10b4b..ce8beb518 100644 --- a/lib/zip_io_util.c +++ b/lib/zip_io_util.c @@ -70,7 +70,7 @@ _zip_read_data(zip_buffer_t *buffer, zip_source_t *src, size_t length, bool nulp } r = (zip_uint8_t *)malloc(length + (nulp ? 1 : 0)); - if (!r) { + if (r == NULL) { zip_error_set(error, ZIP_ER_MEMORY, 0); return NULL; } diff --git a/lib/zip_memdup.c b/lib/zip_memdup.c index 75d72c616..cec701354 100644 --- a/lib/zip_memdup.c +++ b/lib/zip_memdup.c @@ -45,7 +45,7 @@ _zip_memdup(const void *mem, size_t len, zip_error_t *error) { return NULL; ret = malloc(len); - if (!ret) { + if (ret == NULL) { zip_error_set(error, ZIP_ER_MEMORY, 0); return NULL; } diff --git a/lib/zip_new.c b/lib/zip_new.c index 4f69c8a2f..1371698f5 100644 --- a/lib/zip_new.c +++ b/lib/zip_new.c @@ -46,7 +46,7 @@ _zip_new(zip_error_t *error) { zip_t *za; za = (zip_t *)malloc(sizeof(struct zip)); - if (!za) { + if (za == NULL) { zip_error_set(error, ZIP_ER_MEMORY, 0); return NULL; } diff --git a/lib/zip_source_file.h b/lib/zip_source_file.h index cca9fd2b5..c9ce57c25 100644 --- a/lib/zip_source_file.h +++ b/lib/zip_source_file.h @@ -1,3 +1,6 @@ +#ifndef _HAD_ZIP_SOURCE_FILE_H +#define _HAD_ZIP_SOURCE_FILE_H + /* zip_source_file.h -- header for common file operations Copyright (C) 2020-2022 Dieter Baron and Thomas Klausner @@ -88,3 +91,5 @@ struct zip_source_file_operations { }; zip_source_t *zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zip_int64_t len, const zip_stat_t *st, zip_source_file_operations_t *ops, void *ops_userdata, zip_error_t *error); + +#endif /* _HAD_ZIP_SOURCE_FILE_H */ diff --git a/lib/zipint.h b/lib/zipint.h index d7724a3d8..0c4b3fea0 100644 --- a/lib/zipint.h +++ b/lib/zipint.h @@ -673,4 +673,4 @@ int _zip_unchange(zip_t *, zip_uint64_t, int); void _zip_unchange_data(zip_entry_t *); int _zip_write(zip_t *za, const void *data, zip_uint64_t length); -#endif /* zipint.h */ +#endif /* _HAD_ZIPINT_H */