Fixed compiler warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args] (#1133)
* 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
This commit is contained in:
+6
-6
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @date May 2022
|
||||
* @copyright SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include <stdlib.h> /* For calloc() */
|
||||
#include <stdlib.h>
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/datalink/bsc/bvlc-sc.h>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* @date 2020
|
||||
* @copyright SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include <stdlib.h> /* For calloc() */
|
||||
#include <stdlib.h>
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/datalink/datalink.h>
|
||||
#include "bacnet/apdu.h"
|
||||
|
||||
Reference in New Issue
Block a user