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.
diff --git a/src/proto_http.c b/src/proto_http.c
index 0b20011..dc3fed5 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -8785,7 +8785,7 @@
int cur_arg;
char *error;
- rule = (struct act_rule*)calloc(1, sizeof(struct act_rule));
+ rule = calloc(1, sizeof(struct act_rule));
if (!rule) {
Alert("parsing [%s:%d]: out of memory.\n", file, linenum);
goto out_err;
@@ -9723,7 +9723,7 @@
return NULL;
}
- rule = (struct redirect_rule *)calloc(1, sizeof(*rule));
+ rule = calloc(1, sizeof(*rule));
rule->cond = cond;
LIST_INIT(&rule->rdr_fmt);