mirror of
http://git.haproxy.org/git/haproxy.git
synced 2026-02-16 04:23:19 +02:00
CLEANUP: remove unneeded casts
In C89, "void *" is automatically promoted to any pointer type. Casting the result of malloc/calloc to the type of the LHS variable is therefore unneeded. Most of this patch was built using this Coccinelle patch: @@ type T; @@ - (T *) (\(lua_touserdata\|malloc\|calloc\|SSL_get_app_data\|hlua_checkudata\|lua_newuserdata\)(...)) @@ type T; T *x; void *data; @@ x = - (T *) data @@ type T; T *x; T *data; @@ x = - (T *) data Unfortunately, either Coccinelle or I is too limited to detect situation where a complex RHS expression is of type "void *" and therefore casting is not needed. Those cases were manually examined and corrected.
This commit is contained in:
committed by
Willy Tarreau
parent
f3764b7993
commit
3c2f2f207f
@@ -711,7 +711,7 @@ void init(int argc, char **argv)
|
||||
/* now that's a cfgfile list */
|
||||
argv++; argc--;
|
||||
while (argc > 0) {
|
||||
wl = (struct wordlist *)calloc(1, sizeof(*wl));
|
||||
wl = calloc(1, sizeof(*wl));
|
||||
if (!wl) {
|
||||
Alert("Cannot load configuration file %s : out of memory.\n", *argv);
|
||||
exit(1);
|
||||
@@ -734,7 +734,7 @@ void init(int argc, char **argv)
|
||||
case 'N' : cfg_maxpconn = atol(*argv); break;
|
||||
case 'L' : strncpy(localpeer, *argv, sizeof(localpeer) - 1); break;
|
||||
case 'f' :
|
||||
wl = (struct wordlist *)calloc(1, sizeof(*wl));
|
||||
wl = calloc(1, sizeof(*wl));
|
||||
if (!wl) {
|
||||
Alert("Cannot load configuration file %s : out of memory.\n", *argv);
|
||||
exit(1);
|
||||
@@ -1101,14 +1101,12 @@ void init(int argc, char **argv)
|
||||
if (global.nbproc < 1)
|
||||
global.nbproc = 1;
|
||||
|
||||
swap_buffer = (char *)calloc(1, global.tune.bufsize);
|
||||
get_http_auth_buff = (char *)calloc(1, global.tune.bufsize);
|
||||
swap_buffer = calloc(1, global.tune.bufsize);
|
||||
get_http_auth_buff = calloc(1, global.tune.bufsize);
|
||||
static_table_key = calloc(1, sizeof(*static_table_key));
|
||||
|
||||
fdinfo = (struct fdinfo *)calloc(1,
|
||||
sizeof(struct fdinfo) * (global.maxsock));
|
||||
fdtab = (struct fdtab *)calloc(1,
|
||||
sizeof(struct fdtab) * (global.maxsock));
|
||||
fdinfo = calloc(1, sizeof(struct fdinfo) * (global.maxsock));
|
||||
fdtab = calloc(1, sizeof(struct fdtab) * (global.maxsock));
|
||||
/*
|
||||
* Note: we could register external pollers here.
|
||||
* Built-in pollers have been registered before main().
|
||||
|
||||
Reference in New Issue
Block a user