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/51d.c b/src/51d.c
index 212d9b8..f6e4979 100644
--- a/src/51d.c
+++ b/src/51d.c
@@ -179,7 +179,7 @@
*/
static void _51d_retrieve_cache_entry(struct sample *smp, struct lru64 *lru)
{
- struct chunk *cache_entry = (struct chunk*)lru->data;
+ struct chunk *cache_entry = lru->data;
smp->data.u.str.str = cache_entry->str;
smp->data.u.str.len = cache_entry->len;
}
@@ -493,7 +493,7 @@
{
int index = 0;
global._51degrees.header_count = fiftyoneDegreesGetHttpHeaderCount();
- global._51degrees.device_offsets.firstOffset = (fiftyoneDegreesDeviceOffset*)malloc(
+ global._51degrees.device_offsets.firstOffset = malloc(
global._51degrees.header_count * sizeof(fiftyoneDegreesDeviceOffset));
global._51degrees.header_names = malloc(global._51degrees.header_count * sizeof(struct chunk));
global._51degrees.header_offsets = malloc(global._51degrees.header_count * sizeof(int32_t));