diff options
| author | Christian Göttsche | 2024-05-27 21:32:37 +0200 |
|---|---|---|
| committer | jvoisin | 2024-06-06 16:27:13 +0200 |
| commit | 97836fae360422baf9c62dd0eb0de6e7b2cfab09 (patch) | |
| tree | 99227ae43068915635b045ce2de8c26e1da2ac5f /src | |
| parent | f8824a79ff69a2246a61e6381f0bc1e377e16a90 (diff) | |
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)))
| ^~~~~
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp_config.c | 2 | ||||
| -rw-r--r-- | src/sp_config_keywords.c | 6 | ||||
| -rw-r--r-- | src/sp_list.c | 4 | ||||
| -rw-r--r-- | src/sp_pcre_compat.h | 2 | ||||
| -rw-r--r-- | src/sp_tree.c | 2 | ||||
| -rw-r--r-- | 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) { | |||
| 217 | CHECK_DUPLICATE_KEYWORD(retval); | 217 | CHECK_DUPLICATE_KEYWORD(retval); |
| 218 | SP_PARSE_ARG(value); | 218 | SP_PARSE_ARG(value); |
| 219 | 219 | ||
| 220 | sp_cidr *cidr = pecalloc(sizeof(sp_cidr), 1, 1); | 220 | sp_cidr *cidr = pecalloc(1, sizeof(sp_cidr), 1); |
| 221 | 221 | ||
| 222 | if (0 != get_ip_and_cidr(ZSTR_VAL(value), cidr)) { | 222 | if (0 != get_ip_and_cidr(ZSTR_VAL(value), cidr)) { |
| 223 | pefree(cidr, 1); | 223 | 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) { | |||
| 201 | 201 | ||
| 202 | SP_PARSE_FN(parse_cookie) { | 202 | SP_PARSE_FN(parse_cookie) { |
| 203 | zend_string *samesite = NULL; | 203 | zend_string *samesite = NULL; |
| 204 | sp_cookie *cookie = pecalloc(sizeof(sp_cookie), 1, 1); | 204 | sp_cookie *cookie = pecalloc(1, sizeof(sp_cookie), 1); |
| 205 | 205 | ||
| 206 | sp_config_keyword config_keywords[] = { | 206 | sp_config_keyword config_keywords[] = { |
| 207 | {parse_str, SP_TOKEN_NAME, &(cookie->name)}, | 207 | {parse_str, SP_TOKEN_NAME, &(cookie->name)}, |
| @@ -302,7 +302,7 @@ SP_PARSE_FN(parse_disabled_functions) { | |||
| 302 | int ret = SP_PARSER_ERROR; | 302 | int ret = SP_PARSER_ERROR; |
| 303 | bool enable = false, disable = false, allow = false, drop = false; | 303 | bool enable = false, disable = false, allow = false, drop = false; |
| 304 | zend_string *var = NULL, *param = NULL; | 304 | zend_string *var = NULL, *param = NULL; |
| 305 | sp_disabled_function *df = pecalloc(sizeof(*df), 1, 1); | 305 | sp_disabled_function *df = pecalloc(1, sizeof(*df), 1); |
| 306 | df->pos = -1; | 306 | df->pos = -1; |
| 307 | 307 | ||
| 308 | sp_config_keyword config_keywords[] = { | 308 | sp_config_keyword config_keywords[] = { |
| @@ -507,7 +507,7 @@ SP_PARSE_FN(parse_ini_protection) { | |||
| 507 | } | 507 | } |
| 508 | 508 | ||
| 509 | SP_PARSE_FN(parse_ini_entry) { | 509 | SP_PARSE_FN(parse_ini_entry) { |
| 510 | sp_ini_entry *entry = pecalloc(sizeof(sp_ini_entry), 1, 1); | 510 | sp_ini_entry *entry = pecalloc(1, sizeof(sp_ini_entry), 1); |
| 511 | bool rw = false, ro = false; | 511 | bool rw = false, ro = false; |
| 512 | 512 | ||
| 513 | sp_config_keyword config_keywords[] = { | 513 | 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, | |||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | sp_list_node *sp_list_insert(sp_list_node *list, void *data) { | 55 | sp_list_node *sp_list_insert(sp_list_node *list, void *data) { |
| 56 | sp_list_node *new = pecalloc(sizeof(*new), 1, 1); | 56 | sp_list_node *new = pecalloc(1, sizeof(*new), 1); |
| 57 | sp_list_node *origin = list; | 57 | sp_list_node *origin = list; |
| 58 | new->data = data; | 58 | new->data = data; |
| 59 | new->next = NULL; | 59 | new->next = NULL; |
| @@ -70,7 +70,7 @@ sp_list_node *sp_list_insert(sp_list_node *list, void *data) { | |||
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | sp_list_node *sp_list_prepend(sp_list_node *list, void *data) { | 72 | sp_list_node *sp_list_prepend(sp_list_node *list, void *data) { |
| 73 | sp_list_node *new = pecalloc(sizeof(*new), 1, 1); | 73 | sp_list_node *new = pecalloc(1, sizeof(*new), 1); |
| 74 | new->next = list; | 74 | new->next = list; |
| 75 | new->data = data; | 75 | new->data = data; |
| 76 | return new; | 76 | 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 { | |||
| 35 | static inline sp_regexp* sp_regexp_compile(zend_string *zstr) { | 35 | static inline sp_regexp* sp_regexp_compile(zend_string *zstr) { |
| 36 | sp_pcre *re = sp_pcre_compile(ZSTR_VAL(zstr)); | 36 | sp_pcre *re = sp_pcre_compile(ZSTR_VAL(zstr)); |
| 37 | if (!re) { return NULL; } | 37 | if (!re) { return NULL; } |
| 38 | sp_regexp *ret = pecalloc(sizeof(sp_regexp), 1, 1); | 38 | sp_regexp *ret = pecalloc(1, sizeof(sp_regexp), 1); |
| 39 | ret->re = re; | 39 | ret->re = re; |
| 40 | ret->pattern = zstr; | 40 | ret->pattern = zstr; |
| 41 | return ret; | 41 | 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) { | |||
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | sp_tree *sp_tree_new() { | 14 | sp_tree *sp_tree_new() { |
| 15 | sp_tree *new = pecalloc(sizeof(sp_tree), 1, 1); | 15 | sp_tree *new = pecalloc(1, sizeof(sp_tree), 1); |
| 16 | new->next = new->idx = NULL; | 16 | new->next = new->idx = NULL; |
| 17 | new->value = NULL; | 17 | new->value = NULL; |
| 18 | new->type = UNDEFINED; | 18 | 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, | |||
| 7 | 7 | ||
| 8 | while ((cur_str = strchr(cur_str, token.text_repr[0]))) { | 8 | while ((cur_str = strchr(cur_str, token.text_repr[0]))) { |
| 9 | if (0 == strncmp(cur_str, token.text_repr, strlen(token.text_repr))) { | 9 | if (0 == strncmp(cur_str, token.text_repr, strlen(token.text_repr))) { |
| 10 | sp_conf_token *token_elm = pecalloc(sizeof(sp_conf_token), 1, 1); | 10 | sp_conf_token *token_elm = pecalloc(1, sizeof(sp_conf_token), 1); |
| 11 | token_elm->pos = cur_str - str; | 11 | token_elm->pos = cur_str - str; |
| 12 | token_elm->text_repr = token.text_repr; | 12 | token_elm->text_repr = token.text_repr; |
| 13 | token_elm->type = token.type; | 13 | token_elm->type = token.type; |
| @@ -51,7 +51,7 @@ static int create_var(sp_tree *tree, const char *restrict value, | |||
| 51 | if (tree->next == NULL && tree->type == UNDEFINED) { | 51 | if (tree->next == NULL && tree->type == UNDEFINED) { |
| 52 | var_node = tree; | 52 | var_node = tree; |
| 53 | } else { | 53 | } else { |
| 54 | var_node = pecalloc(sizeof(sp_tree), 1, 1); | 54 | var_node = pecalloc(1, sizeof(sp_tree), 1); |
| 55 | free_node_on_error = true; | 55 | free_node_on_error = true; |
| 56 | } | 56 | } |
| 57 | 57 | ||
