Skip to content

Commit

Permalink
Merge pull request nih-at#178 from MisterDA/fixes
Browse files Browse the repository at this point in the history
Fixes for issues reported by PVS-Studio
  • Loading branch information
0-wiz-0 authored Jun 5, 2020
2 parents ac7fb1e + 2665965 commit 34d80f5
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/zip_dirent.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, boo

zde->extra_fields = _zip_ef_remove_internal(zde->extra_fields);

return (zip_int64_t)(size + variable_size);
return (zip_int64_t)size + (zip_int64_t)variable_size;
}


Expand Down
1 change: 1 addition & 0 deletions lib/zip_source_file_stdio_named.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ _zip_stdio_op_create_temp_output_cloning(zip_source_file_context_t *ctx, zip_uin

if (fstat(fileno(ctx->f), &st) < 0) {
zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno);
free(temp);
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/zip_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ _zip_string_new(const zip_uint8_t *raw, zip_uint16_t length, zip_flags_t flags,
return NULL;
}

if ((s->raw = (zip_uint8_t *)malloc((size_t)(length + 1))) == NULL) {
if ((s->raw = (zip_uint8_t *)malloc((size_t)length + 1)) == NULL) {
free(s);
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion regress/ziptool_regress.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ zin_close(int argc, char *argv[]) {

idx = strtoull(argv[0], NULL, 10);
if (idx >= z_in_count) {
fprintf(stderr, "invalid argument '%" PRIu64 "', only %d zip sources open\n", idx, z_in_count);
fprintf(stderr, "invalid argument '%" PRIu64 "', only %u zip sources open\n", idx, z_in_count);
return -1;
}
if (zip_close(z_in[idx]) < 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/zipcmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,9 @@ entry_paranoia_checks(char *const name[2], const void *p1, const void *p2) {
header_done = 1;
}
printf("--- %s ", e1->name);
printf("comment %d\n", e1->comment_length);
printf("comment %" PRIu32 "\n", e1->comment_length);
printf("+++ %s ", e1->name);
printf("comment %d\n", e2->comment_length);
printf("comment %" PRIu32 "\n", e2->comment_length);
}
ret = 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ziptool.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ struct progress_userdata_s progress_userdata;

static void
progress_callback(zip_t *archive, double percentage, void *ud) {
printf("%.1lf%% done\n", percentage * 100);
printf("%.1f%% done\n", percentage * 100);
progress_userdata.percentage = percentage;
}

Expand Down Expand Up @@ -480,7 +480,7 @@ set_file_compression(int argc, char *argv[]) {
method = get_compression_method(argv[1]);
flags = (zip_uint32_t)strtoull(argv[2], NULL, 10);
if (zip_set_file_compression(za, idx, method, flags) < 0) {
fprintf(stderr, "can't set file compression method at index '%" PRIu64 "' to '%s', flags '%d': %s\n", idx, argv[1], flags, zip_strerror(za));
fprintf(stderr, "can't set file compression method at index '%" PRIu64 "' to '%s', flags '%" PRIu32 "': %s\n", idx, argv[1], flags, zip_strerror(za));
return -1;
}
return 0;
Expand Down

0 comments on commit 34d80f5

Please sign in to comment.