From 28a30be5ecd6018949a221b34d58bcb6a861b130 Mon Sep 17 00:00:00 2001 From: Steve Karg Date: Sun, 9 Nov 2025 13:26:35 -0600 Subject: [PATCH] =?UTF-8?q?Fixed=20compiler=20=20warning:=20=E2=80=98callo?= =?UTF-8?q?c=E2=80=99=20sizes=20specified=20with=20=E2=80=98sizeof?= =?UTF-8?q?=E2=80=99=20in=20the=20earlier=20argument=20and=20not=20in=20th?= =?UTF-8?q?e=20later=20argument=20[-Wcalloc-transposed-args]=20(#1133)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed compiler warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args] * Fixed compile error found in pipeline build. * Fixed pre-commit --- apps/router/main.c | 12 ++++++------ src/bacnet/bacapp.c | 2 +- test/bacnet/bacdest/src/main.c | 2 +- test/bacnet/datalink/bvlc-sc/src/main.c | 2 +- test/bacnet/datalink/mock/src/main.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/router/main.c b/apps/router/main.c index b697156a..d8167da9 100644 --- a/apps/router/main.c +++ b/apps/router/main.c @@ -234,13 +234,13 @@ bool read_config(const char *filepath) /* create new list node to store port information */ if (head == NULL) { - head = (ROUTER_PORT *)calloc(sizeof(ROUTER_PORT), 1); + head = (ROUTER_PORT *)calloc(1, sizeof(ROUTER_PORT)); head->next = NULL; current = head; } else { ROUTER_PORT *tmp = current; current = current->next; - current = (ROUTER_PORT *)calloc(sizeof(ROUTER_PORT), 1); + current = (ROUTER_PORT *)calloc(1, sizeof(ROUTER_PORT)); current->next = NULL; tmp->next = current; } @@ -254,7 +254,7 @@ bool read_config(const char *filepath) result = config_setting_lookup_string(port, "device", &iface); if (result) { current->iface = - (char *)calloc(sizeof(char), strlen(iface) + 1); + (char *)calloc(strlen(iface) + 1, sizeof(char)); strcpy(current->iface, iface); /* check if interface is valid */ @@ -297,7 +297,7 @@ bool read_config(const char *filepath) result = config_setting_lookup_string(port, "device", &iface); if (result) { current->iface = - (char *)calloc(sizeof(char), strlen(iface) + 1); + (char *)calloc(strlen(iface) + 1, sizeof(char)); strcpy(current->iface, iface); /* check if interface is valid */ @@ -438,13 +438,13 @@ bool parse_cmd(int argc, char *argv[]) /* create new list node to store port information */ if (head == NULL) { - head = (ROUTER_PORT *)calloc(sizeof(ROUTER_PORT), 1); + head = (ROUTER_PORT *)calloc(1, sizeof(ROUTER_PORT)); head->next = NULL; current = head; } else { ROUTER_PORT *tmp = current; current = current->next; - current = (ROUTER_PORT *)calloc(sizeof(ROUTER_PORT), 1); + current = (ROUTER_PORT *)calloc(1, sizeof(ROUTER_PORT)); current->next = NULL; tmp->next = current; } diff --git a/src/bacnet/bacapp.c b/src/bacnet/bacapp.c index 8661761d..5c0316ed 100644 --- a/src/bacnet/bacapp.c +++ b/src/bacnet/bacapp.c @@ -4072,7 +4072,7 @@ bool bacapp_print_value( char str[str_len + 1]; #else char *str; - str = calloc(sizeof(char), str_len + 1); + str = calloc(str_len + 1, sizeof(char)); if (!str) { return false; } diff --git a/test/bacnet/bacdest/src/main.c b/test/bacnet/bacdest/src/main.c index afbfe6ef..b074f966 100644 --- a/test/bacnet/bacdest/src/main.c +++ b/test/bacnet/bacdest/src/main.c @@ -148,7 +148,7 @@ static void test_BACnetDestination_ASCII(void) /* get the length */ null_len = bacnet_destination_to_ascii(&test_destination, NULL, 0); if (null_len > 0) { - test_ascii = calloc(null_len, 1); + test_ascii = calloc(null_len, sizeof(char)); if (test_ascii) { test_len = bacnet_destination_to_ascii( &test_destination, test_ascii, null_len); diff --git a/test/bacnet/datalink/bvlc-sc/src/main.c b/test/bacnet/datalink/bvlc-sc/src/main.c index 0a5085e5..8b7806ae 100644 --- a/test/bacnet/datalink/bvlc-sc/src/main.c +++ b/test/bacnet/datalink/bvlc-sc/src/main.c @@ -5,7 +5,7 @@ * @date May 2022 * @copyright SPDX-License-Identifier: MIT */ -#include /* For calloc() */ +#include #include #include diff --git a/test/bacnet/datalink/mock/src/main.c b/test/bacnet/datalink/mock/src/main.c index 1060f7e8..37572775 100644 --- a/test/bacnet/datalink/mock/src/main.c +++ b/test/bacnet/datalink/mock/src/main.c @@ -6,7 +6,7 @@ * @date 2020 * @copyright SPDX-License-Identifier: MIT */ -#include /* For calloc() */ +#include #include #include #include "bacnet/apdu.h"