From: Ruben Kerkhof Date: Tue, 11 Apr 2017 14:57:57 +0000 (+0200) Subject: Tree-wide: remove last remnants of sizeof(char) X-Git-Tag: collectd-5.8.0~196 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4d3d0c9713859c9edd7cd88b5ef786e3630a846c;p=collectd.git Tree-wide: remove last remnants of sizeof(char) sizeof(char) is 1 by definition. --- diff --git a/src/daemon/common.c b/src/daemon/common.c index c45304e8..a167122c 100644 --- a/src/daemon/common.c +++ b/src/daemon/common.c @@ -150,7 +150,7 @@ char *sstrdup(const char *s) { ERROR("sstrdup: Out of memory."); exit(3); } - memcpy(r, s, sizeof(char) * sz); + memcpy(r, s, sz); return (r); } /* char *sstrdup */ diff --git a/src/oracle.c b/src/oracle.c index b52ea4ee..cdeebfef 100644 --- a/src/oracle.c +++ b/src/oracle.c @@ -471,13 +471,13 @@ static int o_read_database_query(o_database_t *db, /* {{{ */ oci_defines = NULL; ALLOC_OR_FAIL(column_names, column_num * sizeof(char *)); - ALLOC_OR_FAIL(column_names[0], column_num * DATA_MAX_NAME_LEN * sizeof(char)); + ALLOC_OR_FAIL(column_names[0], column_num * DATA_MAX_NAME_LEN); for (size_t i = 1; i < column_num; i++) column_names[i] = column_names[i - 1] + DATA_MAX_NAME_LEN; ALLOC_OR_FAIL(column_values, column_num * sizeof(char *)); ALLOC_OR_FAIL(column_values[0], - column_num * DATA_MAX_NAME_LEN * sizeof(char)); + column_num * DATA_MAX_NAME_LEN); for (size_t i = 1; i < column_num; i++) column_values[i] = column_values[i - 1] + DATA_MAX_NAME_LEN; diff --git a/src/virt.c b/src/virt.c index 140b4883..a8f378a2 100644 --- a/src/virt.c +++ b/src/virt.c @@ -2150,7 +2150,7 @@ static int ignore_device_match(ignorelist_t *il, const char *domname, if ((domname == NULL) || (devpath == NULL)) return 0; - n = sizeof(char) * (strlen(domname) + strlen(devpath) + 2); + n = strlen(domname) + strlen(devpath) + 2; name = malloc(n); if (name == NULL) { ERROR(PLUGIN_NAME " plugin: malloc failed."); diff --git a/src/write_mongodb.c b/src/write_mongodb.c index 66dc8e07..44181e93 100644 --- a/src/write_mongodb.c +++ b/src/write_mongodb.c @@ -171,7 +171,7 @@ static int wm_initialize(wm_node_t *node) /* {{{ */ uri_length = strlen(format_string) + strlen(node->user) + strlen(node->passwd) + strlen(node->host) + 5 + strlen(node->db) + 1; - if ((uri = calloc(sizeof(char), uri_length)) == NULL) { + if ((uri = calloc(1, uri_length)) == NULL) { ERROR("write_mongodb plugin: Not enough memory to assemble " "authentication string."); mongoc_client_destroy(node->client); @@ -196,7 +196,7 @@ static int wm_initialize(wm_node_t *node) /* {{{ */ } else { format_string = "mongodb://%s:%d"; uri_length = strlen(format_string) + strlen(node->host) + 5 + 1; - if ((uri = calloc(sizeof(char), uri_length)) == NULL) { + if ((uri = calloc(1, uri_length)) == NULL) { ERROR("write_mongodb plugin: Not enough memory to assemble " "authentication string."); mongoc_client_destroy(node->client); diff --git a/src/write_sensu.c b/src/write_sensu.c index c0c06347..6e6517bd 100644 --- a/src/write_sensu.c +++ b/src/write_sensu.c @@ -132,7 +132,7 @@ static int add_str_to_list(struct str_list *strs, ERROR("write_sensu plugin: Unable to alloc memory"); return -1; } - strs->strs = realloc(strs->strs, sizeof(char *) * (strs->nb_strs + 1)); + strs->strs = realloc(strs->strs, strs->nb_strs + 1); if (strs->strs == NULL) { strs->strs = old_strs_ptr; free(newstr); @@ -231,7 +231,7 @@ static char *build_json_str_list(const char *tag, char *ret_str = NULL; char *temp_str; if (list->nb_strs == 0) { - ret_str = malloc(sizeof(char)); + ret_str = malloc(1); if (ret_str == NULL) { ERROR("write_sensu plugin: Unable to alloc memory"); return NULL;