From 490df884f038a43d4057ccf34803f254412a204a Mon Sep 17 00:00:00 2001 From: Rudi Heitbaum Date: Wed, 18 Feb 2026 09:33:21 +0000 Subject: [PATCH] build: fix calloc transposed args fixes: ../arraylist.c: In function 'array_list_new': ../arraylist.c:34:49: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 34 | if(!(arr->array = (void**)calloc(sizeof(void*), arr->size))) { | ^~~~ ../arraylist.c:34:49: note: earlier argument should specify number of elements, later size of each element ../json_object.c: In function 'fjson_object_new': ../json_object.c:217:78: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 217 | struct fjson_object *const jso = (struct fjson_object*)calloc(sizeof(struct fjson_object), 1); | ^~~~~~ ../json_object.c:217:78: note: earlier argument should specify number of elements, later size of each element Signed-off-by: Rudi Heitbaum --- arraylist.c | 2 +- json_object.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arraylist.c b/arraylist.c index 5d51a5b..bab903e 100644 --- a/arraylist.c +++ b/arraylist.c @@ -31,7 +31,7 @@ array_list_new(array_list_free_fn *free_fn) arr->size = ARRAY_LIST_DEFAULT_SIZE; arr->length = 0; arr->free_fn = free_fn; - if(!(arr->array = (void**)calloc(sizeof(void*), arr->size))) { + if(!(arr->array = (void**)calloc(arr->size, sizeof(void*)))) { free(arr); return NULL; } diff --git a/json_object.c b/json_object.c index 386f22e..8f79ded 100644 --- a/json_object.c +++ b/json_object.c @@ -214,7 +214,7 @@ static void fjson_object_generic_delete(struct fjson_object* jso) static struct fjson_object* fjson_object_new(const enum fjson_type o_type) { - struct fjson_object *const jso = (struct fjson_object*)calloc(sizeof(struct fjson_object), 1); + struct fjson_object *const jso = (struct fjson_object*)calloc(1, sizeof(struct fjson_object)); if (!jso) return NULL; jso->o_type = o_type;