Skip to content

Commit

Permalink
Fix order of calloc() args
Browse files Browse the repository at this point in the history
Most of these were done upstream in:
    2023-10-18 Use calloc arguments that correspond with the...
    libarchive 2edd8819501023bc909869b7b652b55edfa7342e
Note that libarchive renamed archive_read_support_compression_* to
archive_read_support_filter_*.

The remaining two cases of fixed "calloc(sizeof" were in code which had
been deleted upstream.

Reported by:	gcc-15
  • Loading branch information
gperciva committed Feb 11, 2025
1 parent 0e2b94b commit 48e6c44
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libarchive/archive_read_support_compression_bzip2.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ bzip2_reader_init(struct archive_read_filter *self)
self->code = ARCHIVE_COMPRESSION_BZIP2;
self->name = "bzip2";

state = (struct private_data *)calloc(sizeof(*state), 1);
state = (struct private_data *)calloc(1, sizeof(*state));
out_block = (unsigned char *)malloc(out_block_size);
if (state == NULL || out_block == NULL) {
archive_set_error(&self->archive->archive, ENOMEM,
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_read_support_compression_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ compress_bidder_init(struct archive_read_filter *self)
self->code = ARCHIVE_COMPRESSION_COMPRESS;
self->name = "compress (.Z)";

state = (struct private_data *)calloc(sizeof(*state), 1);
state = (struct private_data *)calloc(1, sizeof(*state));
out_block = malloc(out_block_size);
if (state == NULL || out_block == NULL) {
free(out_block);
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_read_support_compression_gzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ gzip_bidder_init(struct archive_read_filter *self)
self->code = ARCHIVE_COMPRESSION_GZIP;
self->name = "gzip";

state = (struct private_data *)calloc(sizeof(*state), 1);
state = (struct private_data *)calloc(1, sizeof(*state));
out_block = (unsigned char *)malloc(out_block_size);
if (state == NULL || out_block == NULL) {
free(out_block);
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_read_support_compression_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ archive_read_support_compression_program_signature(struct archive *_a,
/*
* Allocate our private state.
*/
state = (struct program_bidder *)calloc(sizeof (*state), 1);
state = (struct program_bidder *)calloc(1, sizeof (*state));
if (state == NULL)
goto memerr;
state->cmd = strdup(cmd);
Expand Down
4 changes: 2 additions & 2 deletions libarchive/archive_read_support_compression_xz.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ xz_lzma_bidder_init(struct archive_read_filter *self)
struct private_data *state;
int ret;

state = (struct private_data *)calloc(sizeof(*state), 1);
state = (struct private_data *)calloc(1, sizeof(*state));
out_block = (unsigned char *)malloc(out_block_size);
if (state == NULL || out_block == NULL) {
archive_set_error(&self->archive->archive, ENOMEM,
Expand Down Expand Up @@ -456,7 +456,7 @@ lzma_bidder_init(struct archive_read_filter *self)
self->code = ARCHIVE_COMPRESSION_LZMA;
self->name = "lzma";

state = (struct private_data *)calloc(sizeof(*state), 1);
state = (struct private_data *)calloc(1, sizeof(*state));
out_block = (unsigned char *)malloc(out_block_size);
if (state == NULL || out_block == NULL) {
archive_set_error(&self->archive->archive, ENOMEM,
Expand Down

0 comments on commit 48e6c44

Please sign in to comment.