X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdbi.c;h=78ac777fbd25c99cb75af10024a3026b23365d4f;hb=4103105fb43cd72294f165b2541540b3a8a99532;hp=7dec51ad85a04a6aacbeac7e94253a988b40f53c;hpb=f14bb45d570e0b34bdd3a2a0cadfe414c3dfda40;p=collectd.git diff --git a/src/dbi.c b/src/dbi.c index 7dec51ad..78ac777f 100644 --- a/src/dbi.c +++ b/src/dbi.c @@ -25,6 +25,7 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" #include "configfile.h" @@ -148,7 +149,7 @@ static int cdbi_result_get_field (dbi_result res, /* {{{ */ else if (src_type == DBI_TYPE_STRING) { const char *value; - + value = dbi_result_get_string_idx (res, index); if (value == NULL) sstrncpy (buffer, "", buffer_size); @@ -214,7 +215,7 @@ static void cdbi_database_free (cdbi_database_t *db) /* {{{ */ * * ... * - * + * * * Driver "mysql" * Interval 120 @@ -240,7 +241,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 +387,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) { @@ -395,14 +396,13 @@ static int cdbi_config_add_database (oconfig_item_t *ci) /* {{{ */ } else { - user_data_t ud; + user_data_t ud = { 0 }; char *name = NULL; databases = temp; databases[databases_num] = db; databases_num++; - memset (&ud, 0, sizeof (ud)); ud.data = (void *) db; ud.free_func = NULL; name = ssnprintf_alloc("dbi:%s", db->name); @@ -510,7 +510,6 @@ static int cdbi_read_database_query (cdbi_database_t *db, /* {{{ */ column_names = NULL; column_values = NULL; - res = NULL; statement = udb_query_get_statement (q); assert (statement != NULL);