Skip to content

Commit

Permalink
fix: use correct order of calloc parameters
Browse files Browse the repository at this point in the history
This fixes a error if compiled with gcc-14. gcc-14 enables the
compile option `-Werror=calloc-transposed-args`.

No functional change as 1*sizeof(x) is the same as sizeof(x)*1.

Found with Bug#1074932: efibootguard: ftbfs with GCC-14.

Signed-off-by: Quirin Gylstorff <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
gylstorffq authored and jan-kiszka committed Jul 3, 2024
1 parent d408904 commit b3464bd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/ebgpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static void read_GPT_entries(int fd, uint64_t table_LBA, uint32_t num,
}
VERBOSE(stdout, "%u: %s\n", i, GUID_to_str(e.type_GUID));

tmpp = calloc(sizeof(PedPartition), 1);
tmpp = calloc(1,sizeof(PedPartition));
if (!tmpp) {
VERBOSE(stderr, "Out of memory\n");
return;
Expand Down Expand Up @@ -234,7 +234,7 @@ static void scanLogicalVolumes(int fd, off64_t extended_start_LBA,
partition, lognum + 1);
continue;
}
partition->next = calloc(sizeof(PedPartition), 1);
partition->next = calloc(1,sizeof(PedPartition));
if (!partition->next) {
goto scl_out_of_mem;
}
Expand Down Expand Up @@ -313,7 +313,7 @@ static bool check_partition_table(PedDevice *dev)
efihdr.partitions, dev);
break;
}
tmp = calloc(sizeof(PedPartition), 1);
tmp = calloc(1,sizeof(PedPartition));
if (!tmp) {
goto cpt_out_of_mem;
}
Expand Down Expand Up @@ -449,7 +449,7 @@ void ped_device_probe_all(char *rootdev)
}
}
/* This is a block device, so add it to the list*/
PedDevice *dev = calloc(sizeof(PedDevice), 1);
PedDevice *dev = calloc(1,sizeof(PedDevice));
if (!dev) {
continue;
}
Expand Down

0 comments on commit b3464bd

Please sign in to comment.