[PATCH] fix: use correct order of calloc parameters

6 views
Skip to first unread message

Quirin Gylstorff

unread,
Jul 3, 2024, 10:12:24 AM7/3/24
to jan.k...@siemens.com, efibootg...@googlegroups.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

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 <quirin.g...@siemens.com>
---
tools/ebgpart.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/ebgpart.c b/tools/ebgpart.c
index 298d766..f733771 100644
--- a/tools/ebgpart.c
+++ b/tools/ebgpart.c
@@ -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;
@@ -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;
}
@@ -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;
}
@@ -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;
}
--
2.43.0

Jan Kiszka

unread,
Jul 3, 2024, 10:43:39 AM7/3/24
to Quirin Gylstorff, efibootg...@googlegroups.com
Thanks, merged. And thanks to gcc to keep us entertained :)

Jan

--
Siemens AG, Technology
Linux Expert Center

Reply all
Reply to author
Forward
0 new messages