CLEANUP: remove unneeded casts
authorVincent Bernat <vincent@bernat.im>
Sun, 3 Apr 2016 11:48:42 +0000 (13:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 3 Apr 2016 12:17:42 +0000 (14:17 +0200)
commit3c2f2f207f9ce64ce506a174cc12e8dc7eeed2a8
tree11fcfcc6b7682e892b5cdb93ae46465a3fd59387
parentf3764b79938e175c1f6507f01b56ec33b425f754
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.
23 files changed:
src/51d.c
src/acl.c
src/cfgparse.c
src/dns.c
src/dumpstats.c
src/ev_kqueue.c
src/fd.c
src/haproxy.c
src/hlua.c
src/hlua_fcn.c
src/lb_chash.c
src/lb_map.c
src/namespace.c
src/peers.c
src/proto_http.c
src/server.c
src/shctx.c
src/ssl_sock.c
src/standard.c
src/stick_table.c
src/uri_auth.c
src/xxhash.c
tests/filltab25.c