From 97836fae360422baf9c62dd0eb0de6e7b2cfab09 Mon Sep 17 00:00:00 2001 From: Christian Göttsche Date: Mon, 27 May 2024 21:32:37 +0200 Subject: Reorder calloc(3) arguments Please GCC: In file included from /usr/include/php/20220829/Zend/zend.h:30, from /usr/include/php/20220829/main/php.h:31, from /usr/include/php/20220829/main/SAPI.h:20, from src/php_snuffleupagus.h:37, from src/sp_ifilter.c:1: src/sp_pcre_compat.h: In function 'sp_regexp_compile': src/sp_pcre_compat.h:38:36: warning: '__zend_calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 38 | sp_regexp *ret = pecalloc(sizeof(sp_regexp), 1, 1); | ^~~~~~~~~ /usr/include/php/20220829/Zend/zend_alloc.h:199:72: note: in definition of macro 'pecalloc' 199 | #define pecalloc(nmemb, size, persistent) ((persistent)?__zend_calloc((nmemb), (size)):ecalloc((nmemb), (size))) | ^~~~~ src/sp_pcre_compat.h:38:36: note: earlier argument should specify number of elements, later size of each element 38 | sp_regexp *ret = pecalloc(sizeof(sp_regexp), 1, 1); | ^~~~~~~~~ /usr/include/php/20220829/Zend/zend_alloc.h:199:72: note: in definition of macro 'pecalloc' 199 | #define pecalloc(nmemb, size, persistent) ((persistent)?__zend_calloc((nmemb), (size)):ecalloc((nmemb), (size))) | ^~~~~ --- src/sp_config.c | 2 +- src/sp_config_keywords.c | 6 +++--- src/sp_list.c | 4 ++-- src/sp_pcre_compat.h | 2 +- src/sp_tree.c | 2 +- src/sp_var_parser.c | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sp_config.c b/src/sp_config.c index 60c379a..2d2631a 100644 --- a/src/sp_config.c +++ b/src/sp_config.c @@ -217,7 +217,7 @@ SP_PARSEKW_FN(parse_cidr) { CHECK_DUPLICATE_KEYWORD(retval); SP_PARSE_ARG(value); - sp_cidr *cidr = pecalloc(sizeof(sp_cidr), 1, 1); + sp_cidr *cidr = pecalloc(1, sizeof(sp_cidr), 1); if (0 != get_ip_and_cidr(ZSTR_VAL(value), cidr)) { pefree(cidr, 1); diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c index 6733503..bf54428 100644 --- a/src/sp_config_keywords.c +++ b/src/sp_config_keywords.c @@ -201,7 +201,7 @@ SP_PARSE_FN(parse_wrapper_whitelist) { SP_PARSE_FN(parse_cookie) { zend_string *samesite = NULL; - sp_cookie *cookie = pecalloc(sizeof(sp_cookie), 1, 1); + sp_cookie *cookie = pecalloc(1, sizeof(sp_cookie), 1); sp_config_keyword config_keywords[] = { {parse_str, SP_TOKEN_NAME, &(cookie->name)}, @@ -302,7 +302,7 @@ SP_PARSE_FN(parse_disabled_functions) { int ret = SP_PARSER_ERROR; bool enable = false, disable = false, allow = false, drop = false; zend_string *var = NULL, *param = NULL; - sp_disabled_function *df = pecalloc(sizeof(*df), 1, 1); + sp_disabled_function *df = pecalloc(1, sizeof(*df), 1); df->pos = -1; sp_config_keyword config_keywords[] = { @@ -507,7 +507,7 @@ SP_PARSE_FN(parse_ini_protection) { } SP_PARSE_FN(parse_ini_entry) { - sp_ini_entry *entry = pecalloc(sizeof(sp_ini_entry), 1, 1); + sp_ini_entry *entry = pecalloc(1, sizeof(sp_ini_entry), 1); bool rw = false, ro = false; sp_config_keyword config_keywords[] = { diff --git a/src/sp_list.c b/src/sp_list.c index ab752f7..6a41fb4 100644 --- a/src/sp_list.c +++ b/src/sp_list.c @@ -53,7 +53,7 @@ sp_list_node *sp_list_sort(sp_list_node *pList, } sp_list_node *sp_list_insert(sp_list_node *list, void *data) { - sp_list_node *new = pecalloc(sizeof(*new), 1, 1); + sp_list_node *new = pecalloc(1, sizeof(*new), 1); sp_list_node *origin = list; new->data = data; new->next = NULL; @@ -70,7 +70,7 @@ sp_list_node *sp_list_insert(sp_list_node *list, void *data) { } sp_list_node *sp_list_prepend(sp_list_node *list, void *data) { - sp_list_node *new = pecalloc(sizeof(*new), 1, 1); + sp_list_node *new = pecalloc(1, sizeof(*new), 1); new->next = list; new->data = data; return new; diff --git a/src/sp_pcre_compat.h b/src/sp_pcre_compat.h index 6e9d91a..5770df0 100644 --- a/src/sp_pcre_compat.h +++ b/src/sp_pcre_compat.h @@ -35,7 +35,7 @@ typedef struct { static inline sp_regexp* sp_regexp_compile(zend_string *zstr) { sp_pcre *re = sp_pcre_compile(ZSTR_VAL(zstr)); if (!re) { return NULL; } - sp_regexp *ret = pecalloc(sizeof(sp_regexp), 1, 1); + sp_regexp *ret = pecalloc(1, sizeof(sp_regexp), 1); ret->re = re; ret->pattern = zstr; return ret; diff --git a/src/sp_tree.c b/src/sp_tree.c index 55b6ff4..32394e1 100644 --- a/src/sp_tree.c +++ b/src/sp_tree.c @@ -12,7 +12,7 @@ void sp_tree_free(sp_tree *tree) { } sp_tree *sp_tree_new() { - sp_tree *new = pecalloc(sizeof(sp_tree), 1, 1); + sp_tree *new = pecalloc(1, sizeof(sp_tree), 1); new->next = new->idx = NULL; new->value = NULL; new->type = UNDEFINED; diff --git a/src/sp_var_parser.c b/src/sp_var_parser.c index e7ff766..81d696f 100644 --- a/src/sp_var_parser.c +++ b/src/sp_var_parser.c @@ -7,7 +7,7 @@ static sp_list_node *parse_str_tokens(const char *str, while ((cur_str = strchr(cur_str, token.text_repr[0]))) { if (0 == strncmp(cur_str, token.text_repr, strlen(token.text_repr))) { - sp_conf_token *token_elm = pecalloc(sizeof(sp_conf_token), 1, 1); + sp_conf_token *token_elm = pecalloc(1, sizeof(sp_conf_token), 1); token_elm->pos = cur_str - str; token_elm->text_repr = token.text_repr; token_elm->type = token.type; @@ -51,7 +51,7 @@ static int create_var(sp_tree *tree, const char *restrict value, if (tree->next == NULL && tree->type == UNDEFINED) { var_node = tree; } else { - var_node = pecalloc(sizeof(sp_tree), 1, 1); + var_node = pecalloc(1, sizeof(sp_tree), 1); free_node_on_error = true; } -- cgit v1.3