From c8d167c5af263b6f56b39275fd5b281bdaf48b02 Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Sat, 23 Apr 2016 13:35:09 +0200 Subject: [PATCH] realloc: remove unnecessary casts of return value --- src/apache.c | 2 +- src/ascent.c | 2 +- src/bind.c | 4 ++-- src/collectd-nagios.c | 2 +- src/curl.c | 2 +- src/curl_xml.c | 2 +- src/daemon/configfile.c | 6 +++--- src/daemon/filter_chain.c | 2 +- src/daemon/utils_cache.c | 2 +- src/daemon/utils_tail_match.c | 2 +- src/dbi.c | 4 ++-- src/filecount.c | 2 +- src/iptables.c | 2 +- src/java.c | 6 +++--- src/liboconfig/scanner.l | 2 +- src/match_value.c | 2 +- src/netlink.c | 2 +- src/notify_email.c | 2 +- src/ntpd.c | 2 +- src/oracle.c | 2 +- src/perl.c | 4 ++-- src/postgresql.c | 6 +++--- src/powerdns.c | 4 ++-- src/rrdtool.c | 4 ++-- src/snmp.c | 2 +- src/table.c | 4 ++-- src/tail.c | 2 +- src/target_scale.c | 2 +- src/utils_db_query.c | 6 +++--- 29 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/apache.c b/src/apache.c index baa6081a..3d25c350 100644 --- a/src/apache.c +++ b/src/apache.c @@ -105,7 +105,7 @@ static size_t apache_curl_callback (void *buf, size_t size, size_t nmemb, { char *temp; - temp = (char *) realloc (st->apache_buffer, + temp = realloc (st->apache_buffer, st->apache_buffer_fill + len + 1); if (temp == NULL) { diff --git a/src/ascent.c b/src/ascent.c index d38e8591..74f714a8 100644 --- a/src/ascent.c +++ b/src/ascent.c @@ -161,7 +161,7 @@ static size_t ascent_curl_callback (void *buf, size_t size, size_t nmemb, /* {{{ { char *temp; - temp = (char *) realloc (ascent_buffer, + temp = realloc (ascent_buffer, ascent_buffer_fill + len + 1); if (temp == NULL) { diff --git a/src/bind.c b/src/bind.c index f2cd1677..a546ff97 100644 --- a/src/bind.c +++ b/src/bind.c @@ -1613,7 +1613,7 @@ static int bind_config_add_view_zone (cb_view_t *view, /* {{{ */ return (-1); } - tmp = (char **) realloc (view->zones, + tmp = realloc (view->zones, sizeof (char *) * (view->zones_num + 1)); if (tmp == NULL) { @@ -1644,7 +1644,7 @@ static int bind_config_add_view (oconfig_item_t *ci) /* {{{ */ return (-1); } - tmp = (cb_view_t *) realloc (views, sizeof (*views) * (views_num + 1)); + tmp = realloc (views, sizeof (*views) * (views_num + 1)); if (tmp == NULL) { ERROR ("bind plugin: realloc failed."); diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c index 712c24fa..fe56d5d3 100644 --- a/src/collectd-nagios.c +++ b/src/collectd-nagios.c @@ -694,7 +694,7 @@ int main (int argc, char **argv) case 'd': { char **tmp; - tmp = (char **) realloc (match_ds_g, + tmp = realloc (match_ds_g, (match_ds_num_g + 1) * sizeof (char *)); if (tmp == NULL) diff --git a/src/curl.c b/src/curl.c index 4bb58e2c..ea03ce22 100644 --- a/src/curl.c +++ b/src/curl.c @@ -108,7 +108,7 @@ static size_t cc_curl_callback (void *buf, /* {{{ */ size_t temp_size; temp_size = wp->buffer_fill + len + 1; - temp = (char *) realloc (wp->buffer, temp_size); + temp = realloc (wp->buffer, temp_size); if (temp == NULL) { ERROR ("curl plugin: realloc failed."); diff --git a/src/curl_xml.c b/src/curl_xml.c index 58cb42db..fa2f0ca4 100644 --- a/src/curl_xml.c +++ b/src/curl_xml.c @@ -121,7 +121,7 @@ static size_t cx_curl_callback (void *buf, /* {{{ */ { char *temp; - temp = (char *) realloc (db->buffer, + temp = realloc (db->buffer, db->buffer_fill + len + 1); if (temp == NULL) { diff --git a/src/daemon/configfile.c b/src/daemon/configfile.c index 1d81a652..70ada80a 100644 --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@ -514,7 +514,7 @@ static int cf_ci_replace_child (oconfig_item_t *dst, oconfig_item_t *src, return (0); } - temp = (oconfig_item_t *) realloc (dst->children, + temp = realloc (dst->children, sizeof (oconfig_item_t) * (dst->children_num + src->children_num - 1)); if (temp == NULL) @@ -562,7 +562,7 @@ static int cf_ci_append_children (oconfig_item_t *dst, oconfig_item_t *src) if ((src == NULL) || (src->children_num == 0)) return (0); - temp = (oconfig_item_t *) realloc (dst->children, + temp = realloc (dst->children, sizeof (oconfig_item_t) * (dst->children_num + src->children_num)); if (temp == NULL) @@ -749,7 +749,7 @@ static oconfig_item_t *cf_read_dir (const char *dir, } ++filenames_num; - tmp = (char **) realloc (filenames, + tmp = realloc (filenames, filenames_num * sizeof (*filenames)); if (tmp == NULL) { ERROR ("configfile: realloc failed."); diff --git a/src/daemon/filter_chain.c b/src/daemon/filter_chain.c index f4e343c1..a622af96 100644 --- a/src/daemon/filter_chain.c +++ b/src/daemon/filter_chain.c @@ -655,7 +655,7 @@ static int fc_bit_write_create (const oconfig_item_t *ci, /* {{{ */ } plugin = child->values[j].value.string; - temp = (fc_writer_t *) realloc (plugin_list, (plugin_list_len + 2) + temp = realloc (plugin_list, (plugin_list_len + 2) * (sizeof (*plugin_list))); if (temp == NULL) { diff --git a/src/daemon/utils_cache.c b/src/daemon/utils_cache.c index b5b059c0..9328d7ad 100644 --- a/src/daemon/utils_cache.c +++ b/src/daemon/utils_cache.c @@ -263,7 +263,7 @@ int uc_check_timeout (void) continue; /* If entry has not been updated, add to `keys' array */ - tmp = (char **) realloc ((void *) keys, + tmp = realloc ((void *) keys, (keys_len + 1) * sizeof (char *)); if (tmp == NULL) { diff --git a/src/daemon/utils_tail_match.c b/src/daemon/utils_tail_match.c index 1e5da95e..1aeb814a 100644 --- a/src/daemon/utils_tail_match.c +++ b/src/daemon/utils_tail_match.c @@ -179,7 +179,7 @@ int tail_match_add_match (cu_tail_match_t *obj, cu_match_t *match, { cu_tail_match_match_t *temp; - temp = (cu_tail_match_match_t *) realloc (obj->matches, + temp = realloc (obj->matches, sizeof (cu_tail_match_match_t) * (obj->matches_num + 1)); if (temp == NULL) return (-1); diff --git a/src/dbi.c b/src/dbi.c index 655581e8..36e0d169 100644 --- a/src/dbi.c +++ b/src/dbi.c @@ -240,7 +240,7 @@ static int cdbi_config_add_database_driver_option (cdbi_database_t *db, /* {{{ * return (-1); } - option = (cdbi_driver_option_t *) realloc (db->driver_options, + option = realloc (db->driver_options, sizeof (*option) * (db->driver_options_num + 1)); if (option == NULL) { @@ -386,7 +386,7 @@ static int cdbi_config_add_database (oconfig_item_t *ci) /* {{{ */ { cdbi_database_t **temp; - temp = (cdbi_database_t **) realloc (databases, + temp = realloc (databases, sizeof (*databases) * (databases_num + 1)); if (temp == NULL) { diff --git a/src/filecount.c b/src/filecount.c index 270e5d05..c81fdc25 100644 --- a/src/filecount.c +++ b/src/filecount.c @@ -399,7 +399,7 @@ static int fc_config_add_dir (oconfig_item_t *ci) { fc_directory_conf_t **temp; - temp = (fc_directory_conf_t **) realloc (directories, + temp = realloc (directories, sizeof (*directories) * (directories_num + 1)); if (temp == NULL) { diff --git a/src/iptables.c b/src/iptables.c index 1e35851a..0103725f 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -204,7 +204,7 @@ static int iptables_config (const char *key, const char *value) table = NULL; chain = NULL; - list = (ip_chain_t **) realloc (chain_list, (chain_num + 1) * sizeof (ip_chain_t *)); + list = realloc (chain_list, (chain_num + 1) * sizeof (ip_chain_t *)); if (list == NULL) { char errbuf[1024]; diff --git a/src/java.c b/src/java.c index 50cd6965..4187e7c3 100644 --- a/src/java.c +++ b/src/java.c @@ -1905,7 +1905,7 @@ static int cjni_callback_register (JNIEnv *jvm_env, /* {{{ */ pthread_mutex_lock (&java_callbacks_lock); - tmp = (cjni_callback_info_t *) realloc (java_callbacks, + tmp = realloc (java_callbacks, (java_callbacks_num + 1) * sizeof (*java_callbacks)); if (tmp == NULL) { @@ -2167,7 +2167,7 @@ static int cjni_config_add_jvm_arg (oconfig_item_t *ci) /* {{{ */ return (-1); } - tmp = (char **) realloc (jvm_argv, sizeof (char *) * (jvm_argc + 1)); + tmp = realloc (jvm_argv, sizeof (char *) * (jvm_argc + 1)); if (tmp == NULL) { ERROR ("java plugin: realloc failed."); @@ -2203,7 +2203,7 @@ static int cjni_config_load_plugin (oconfig_item_t *ci) /* {{{ */ if (jvm_env == NULL) return (-1); - class = (java_plugin_class_t *) realloc (java_classes_list, + class = realloc (java_classes_list, (java_classes_list_len + 1) * sizeof (*java_classes_list)); if (class == NULL) { diff --git a/src/liboconfig/scanner.l b/src/liboconfig/scanner.l index 41d66438..7a831c2a 100644 --- a/src/liboconfig/scanner.l +++ b/src/liboconfig/scanner.l @@ -146,7 +146,7 @@ static void ml_append (char *string) if (ml_free <= len) { ml_len += len - ml_free + 1; - ml_buffer = (char *)realloc (ml_buffer, ml_len); + ml_buffer = realloc (ml_buffer, ml_len); if (NULL == ml_buffer) YY_FATAL_ERROR ("out of dynamic memory in ml_append"); } diff --git a/src/match_value.c b/src/match_value.c index 64e11367..fd63ad83 100644 --- a/src/match_value.c +++ b/src/match_value.c @@ -129,7 +129,7 @@ static int mv_config_add_data_source (mv_match_t *m, /* {{{ */ /* Allocate space for the char pointers */ new_data_sources_num = m->data_sources_num + ((size_t) ci->values_num); - temp = (char **) realloc (m->data_sources, + temp = realloc (m->data_sources, new_data_sources_num * sizeof (char *)); if (temp == NULL) { diff --git a/src/netlink.c b/src/netlink.c index c8905d5c..5c3a9f00 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -244,7 +244,7 @@ static int update_iflist (struct ifinfomsg *msg, const char *dev) { char **temp; - temp = (char **) realloc (iflist, (msg->ifi_index + 1) * sizeof (char *)); + temp = realloc (iflist, (msg->ifi_index + 1) * sizeof (char *)); if (temp == NULL) { ERROR ("netlink plugin: update_iflist: realloc failed."); diff --git a/src/notify_email.c b/src/notify_email.c index 6843987c..c77b2d19 100644 --- a/src/notify_email.c +++ b/src/notify_email.c @@ -176,7 +176,7 @@ static int notify_email_config (const char *key, const char *value) { char **tmp; - tmp = (char **) realloc ((void *) recipients, (recipients_len + 1) * sizeof (char *)); + tmp = realloc (recipients, (recipients_len + 1) * sizeof (char *)); if (tmp == NULL) { ERROR ("notify_email: realloc failed."); return (-1); diff --git a/src/ntpd.c b/src/ntpd.c index 4a31e455..1071d0b3 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -663,7 +663,7 @@ static int ntpd_receive_response (int *res_items, int *res_size, */ DEBUG ("realloc (%p, %zu)", (void *) *res_data, (items_num + pkt_item_num) * res_item_size); - items = realloc ((void *) *res_data, + items = realloc (*res_data, (items_num + pkt_item_num) * res_item_size); if (items == NULL) { diff --git a/src/oracle.c b/src/oracle.c index 55139dd1..cb9b3dbf 100644 --- a/src/oracle.c +++ b/src/oracle.c @@ -299,7 +299,7 @@ static int o_config_add_database (oconfig_item_t *ci) /* {{{ */ { o_database_t **temp; - temp = (o_database_t **) realloc (databases, + temp = realloc (databases, sizeof (*databases) * (databases_num + 1)); if (temp == NULL) { diff --git a/src/perl.c b/src/perl.c index 920e7b3f..27214bb6 100644 --- a/src/perl.c +++ b/src/perl.c @@ -2382,7 +2382,7 @@ static int perl_config_enabledebugger (pTHX_ oconfig_item_t *ci) value = ci->values[0].value.string; - perl_argv = (char **)realloc (perl_argv, + perl_argv = realloc (perl_argv, (++perl_argc + 1) * sizeof (char *)); if (NULL == perl_argv) { @@ -2419,7 +2419,7 @@ static int perl_config_includedir (pTHX_ oconfig_item_t *ci) value = ci->values[0].value.string; if (NULL == aTHX) { - perl_argv = (char **)realloc (perl_argv, + perl_argv = realloc (perl_argv, (++perl_argc + 1) * sizeof (char *)); if (NULL == perl_argv) { diff --git a/src/postgresql.c b/src/postgresql.c index b4b4ca77..759560e8 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -224,7 +224,7 @@ static c_psql_database_t *c_psql_database_new (const char *name) return NULL; } - tmp = (c_psql_database_t **)realloc (databases, + tmp = realloc (databases, (databases_num + 1) * sizeof (*databases)); if (NULL == tmp) { log_err ("Out of memory."); @@ -1115,7 +1115,7 @@ static int config_add_writer (oconfig_item_t *ci, if (strcasecmp (name, src_writers[i].name) != 0) continue; - tmp = (c_psql_writer_t **)realloc (*dst_writers, + tmp = realloc (*dst_writers, sizeof (**dst_writers) * (*dst_writers_num + 1)); if (tmp == NULL) { log_err ("Out of memory."); @@ -1151,7 +1151,7 @@ static int c_psql_config_writer (oconfig_item_t *ci) return 1; } - tmp = (c_psql_writer_t *)realloc (writers, + tmp = realloc (writers, sizeof (*writers) * (writers_num + 1)); if (tmp == NULL) { log_err ("Out of memory."); diff --git a/src/powerdns.c b/src/powerdns.c index 1c41ff8d..f72bd40f 100644 --- a/src/powerdns.c +++ b/src/powerdns.c @@ -542,7 +542,7 @@ static int powerdns_get_data_stream (list_item_t *item, /* {{{ */ else if (status == 0) break; - buffer_new = (char *) realloc (buffer, buffer_size + status + 1); + buffer_new = realloc (buffer, buffer_size + status + 1); if (buffer_new == NULL) { FUNC_ERROR ("realloc"); @@ -799,7 +799,7 @@ static int powerdns_config_add_collect (list_item_t *li, /* {{{ */ return (-1); } - temp = (char **) realloc (li->fields, + temp = realloc (li->fields, sizeof (char *) * (li->fields_num + ci->values_num)); if (temp == NULL) { diff --git a/src/rrdtool.c b/src/rrdtool.c index b45f8d99..3cd6d6bb 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -588,7 +588,7 @@ static void rrd_cache_flush (cdtime_t timeout) } else /* ancient and no values -> waste of memory */ { - char **tmp = (char **) realloc ((void *) keys, + char **tmp = realloc (keys, (keys_num + 1) * sizeof (char *)); if (tmp == NULL) { @@ -756,7 +756,7 @@ static int rrd_cache_insert (const char *filename, return (-1); } - values_new = (char **) realloc ((void *) rc->values, + values_new = realloc ((void *) rc->values, (rc->values_num + 1) * sizeof (char *)); if (values_new == NULL) { diff --git a/src/snmp.c b/src/snmp.c index 8b21907a..d6fc05dc 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -520,7 +520,7 @@ static int csnmp_config_add_host_collect (host_definition_t *host, } data_list_len = host->data_list_len + ci->values_num; - data_list = (data_definition_t **) realloc (host->data_list, + data_list = realloc (host->data_list, sizeof (data_definition_t *) * data_list_len); if (data_list == NULL) return (-1); diff --git a/src/table.c b/src/table.c index aebf0bbf..38d5f03a 100644 --- a/src/table.c +++ b/src/table.c @@ -188,7 +188,7 @@ static int tbl_config_result (tbl_t *tbl, oconfig_item_t *ci) return 1; } - res = (tbl_result_t *)realloc (tbl->results, + res = realloc (tbl->results, (tbl->results_num + 1) * sizeof (*tbl->results)); if (res == NULL) { char errbuf[1024]; @@ -254,7 +254,7 @@ static int tbl_config_table (oconfig_item_t *ci) return 1; } - tbl = (tbl_t *)realloc (tables, (tables_num + 1) * sizeof (*tables)); + tbl = realloc (tables, (tables_num + 1) * sizeof (*tables)); if (NULL == tbl) { char errbuf[1024]; log_err ("realloc failed: %s.", diff --git a/src/tail.c b/src/tail.c index ffdba8ae..5402f666 100644 --- a/src/tail.c +++ b/src/tail.c @@ -279,7 +279,7 @@ static int ctail_config_add_file (oconfig_item_t *ci) { cu_tail_match_t **temp; - temp = (cu_tail_match_t **) realloc (tail_match_list, + temp = realloc (tail_match_list, sizeof (cu_tail_match_t *) * (tail_match_list_num + 1)); if (temp == NULL) { diff --git a/src/target_scale.c b/src/target_scale.c index 3ac399c9..74652ff8 100644 --- a/src/target_scale.c +++ b/src/target_scale.c @@ -328,7 +328,7 @@ static int ts_config_add_data_source(ts_data_t *data, /* {{{ */ /* Allocate space for the char pointers */ new_data_sources_num = data->data_sources_num + ((size_t) ci->values_num); - temp = (char **) realloc (data->data_sources, + temp = realloc (data->data_sources, new_data_sources_num * sizeof (char *)); if (temp == NULL) { diff --git a/src/utils_db_query.c b/src/utils_db_query.c index 74c3a81f..5c5d1d77 100644 --- a/src/utils_db_query.c +++ b/src/utils_db_query.c @@ -142,7 +142,7 @@ static int udb_config_add_string (char ***ret_array, /* {{{ */ } array_len = *ret_array_len; - array = (char **) realloc (*ret_array, + array = realloc (*ret_array, sizeof (char *) * (array_len + ci->values_num)); if (array == NULL) { @@ -750,7 +750,7 @@ int udb_query_create (udb_query_t ***ret_query_list, /* {{{ */ { udb_query_t **temp; - temp = (udb_query_t **) realloc (query_list, + temp = realloc (query_list, sizeof (*query_list) * (query_list_len + 1)); if (temp == NULL) { @@ -815,7 +815,7 @@ int udb_query_pick_from_list_by_name (const char *name, /* {{{ */ continue; tmp_list_len = *dst_list_len; - tmp_list = (udb_query_t **) realloc (*dst_list, (tmp_list_len + 1) + tmp_list = realloc (*dst_list, (tmp_list_len + 1) * sizeof (udb_query_t *)); if (tmp_list == NULL) { -- 2.11.0