From 35a2168c323a30317156eb5b5d5a56b4811dd9af Mon Sep 17 00:00:00 2001 From: Alexander Goncharov Date: Sun, 26 May 2024 03:41:15 +0300 Subject: [PATCH] add gcc-14 -Werror=calloc-transposed-args compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Change-Id: Icb9842fbc2fa6ad4cd9dc9384c19fd3741eadb2e Reviewed-on: https://review.coreboot.org/c/flashrom/+/82657 Reviewed-by: Peter Marheine Tested-by: build bot (Jenkins) Reviewed-by: Robert Marko Reviewed-by: Elyes Haouas Reviewed-by: Anastasia Klimchuk --- s25f.c | 2 +- spi25_statusreg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/s25f.c b/s25f.c index dd15efcdb..b0f2438d1 100644 --- a/s25f.c +++ b/s25f.c @@ -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; diff --git a/spi25_statusreg.c b/spi25_statusreg.c index 98988af63..ceb2c7796 100644 --- a/spi25_statusreg.c +++ b/spi25_statusreg.c @@ -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;