mirror of
https://github.com/curl/curl.git
synced 2026-08-26 19:43:32 +03:00
misc: fix -Walloc-size warnings
GCC 14 introduces a new -Walloc-size included in -Wextra which gives:
```
src/tool_operate.c: In function ‘add_per_transfer’:
src/tool_operate.c:213:5: warning: allocation of insufficient size ‘1’ for type ‘struct per_transfer’ with size ‘480’ [-Walloc-size]
213 | p = calloc(sizeof(struct per_transfer), 1);
| ^
src/var.c: In function ‘addvariable’:
src/var.c:361:5: warning: allocation of insufficient size ‘1’ for type ‘struct var’ with size ‘32’ [-Walloc-size]
361 | p = calloc(sizeof(struct var), 1);
| ^
```
The calloc prototype is:
```
void *calloc(size_t nmemb, size_t size);
```
So, just swap the number of members and size arguments to match the
prototype, as we're initialising 1 struct of size `sizeof(struct
...)`. GCC then sees we're not doing anything wrong.
Closes #12292
This commit is contained in:
parent
d06643812c
commit
bc8509a748
30 changed files with 40 additions and 40 deletions
|
|
@ -211,7 +211,7 @@ static curl_off_t all_pers;
|
|||
static CURLcode add_per_transfer(struct per_transfer **per)
|
||||
{
|
||||
struct per_transfer *p;
|
||||
p = calloc(sizeof(struct per_transfer), 1);
|
||||
p = calloc(1, sizeof(struct per_transfer));
|
||||
if(!p)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
if(!transfers)
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ static ParameterError addvariable(struct GlobalConfig *global,
|
|||
if(check)
|
||||
notef(global, "Overwriting variable '%s'", check->name);
|
||||
|
||||
p = calloc(sizeof(struct var), 1);
|
||||
p = calloc(1, sizeof(struct var));
|
||||
if(!p)
|
||||
return PARAM_NO_MEM;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue