1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

add gcc-14 -Werror=calloc-transposed-args compatibility

gcc-14 added a new `-Wcalloc-transposed-args` warning. Documentation
says:

```
Warn about calls to allocation functions decorated with attribute
alloc_size with two arguments, which use sizeof operator as the earlier
size argument and don’t use it as the later size argument. This is a
coding style warning. The first argument to calloc is documented to be
number of elements in array, while the second argument is size of each
element, so calloc (n, sizeof (int)) is preferred over
calloc (sizeof (int), n).
```

Let's fix the existing occurrences.

Found-by: gcc v14.1.1 20240507
Signed-off-by: Alexander Goncharov <chat@joursoir.net>
Change-Id: Icb9842fbc2fa6ad4cd9dc9384c19fd3741eadb2e
Reviewed-on: https://review.coreboot.org/c/flashrom/+/82657
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Robert Marko <robimarko@gmail.com>
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
Alexander Goncharov 2024-05-26 03:41:15 +03:00
parent 8e30a6d8f7
commit 35a2168c32
2 changed files with 2 additions and 2 deletions

2
s25f.c
View File

@ -291,7 +291,7 @@ int s25fs_block_erase_d8(struct flashctx *flash, unsigned int addr, unsigned int
s25fs_read_cr(flash, CR3NV_ADDR));
/* Restore CR3V when flashrom exits */
uint8_t *data = calloc(sizeof(uint8_t), 1);
uint8_t *data = calloc(1, sizeof(uint8_t));
if (!data) {
msg_cerr("Out of memory!\n");
return 1;

View File

@ -310,7 +310,7 @@ static int spi_disable_blockprotect_generic(struct flashctx *flash, uint8_t bp_m
}
/* Restore status register content upon exit in finalize_flash_access(). */
uint8_t *data = calloc(sizeof(uint8_t), 1);
uint8_t *data = calloc(1, sizeof(uint8_t));
if (!data) {
msg_cerr("Out of memory!\n");
return 1;