Alexander Goncharov has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/82657?usp=email )
Change subject: add gcc-14 -Werror=calloc-transposed-args compatibility ......................................................................
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 --- M s25f.c M spi25_statusreg.c 2 files changed, 2 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/57/82657/1
diff --git a/s25f.c b/s25f.c index dd15efc..b0f2438 100644 --- a/s25f.c +++ b/s25f.c @@ -291,7 +291,7 @@ 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; diff --git a/spi25_statusreg.c b/spi25_statusreg.c index 98988af..ceb2c77 100644 --- a/spi25_statusreg.c +++ b/spi25_statusreg.c @@ -310,7 +310,7 @@ }
/* 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;