mirror of
http://git.haproxy.org/git/haproxy.git
synced 2026-02-18 02:56:47 +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
@@ -155,7 +155,7 @@ REGPRM1 static int _do_init(struct poller *p)
|
||||
goto fail_fd;
|
||||
|
||||
/* we can have up to two events per fd (*/
|
||||
kev = (struct kevent*)calloc(1, sizeof(struct kevent) * 2 * global.maxsock);
|
||||
kev = calloc(1, sizeof(struct kevent) * 2 * global.maxsock);
|
||||
if (kev == NULL)
|
||||
goto fail_kev;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user