projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1842 from rubenk/declare-loop-variable-in-for-loop-controlling...
[collectd.git]
/
src
/
utils_db_query.c
diff --git
a/src/utils_db_query.c
b/src/utils_db_query.c
index
e576f94
..
26ebbf3
100644
(file)
--- a/
src/utils_db_query.c
+++ b/
src/utils_db_query.c
@@
-126,7
+126,6
@@
static int udb_config_add_string (char ***ret_array, /* {{{ */
{
char **array;
size_t array_len;
{
char **array;
size_t array_len;
- int i;
if (ci->values_num < 1)
{
if (ci->values_num < 1)
{
@@
-135,7
+134,7
@@
static int udb_config_add_string (char ***ret_array, /* {{{ */
return (-1);
}
return (-1);
}
- for (i = 0; i < ci->values_num; i++)
+ for (i
nt i
= 0; i < ci->values_num; i++)
{
if (ci->values[i].type != OCONFIG_TYPE_STRING)
{
{
if (ci->values[i].type != OCONFIG_TYPE_STRING)
{
@@
-155,7
+154,7
@@
static int udb_config_add_string (char ***ret_array, /* {{{ */
}
*ret_array = array;
}
*ret_array = array;
- for (i = 0; i < ci->values_num; i++)
+ for (i
nt i
= 0; i < ci->values_num; i++)
{
array[array_len] = strdup (ci->values[i].value.string);
if (array[array_len] == NULL)
{
array[array_len] = strdup (ci->values[i].value.string);
if (array[array_len] == NULL)
@@
-200,7
+199,6
@@
static int udb_result_submit (udb_result_t *r, /* {{{ */
udb_query_t const *q, udb_query_preparation_area_t *q_area)
{
value_list_t vl = VALUE_LIST_INIT;
udb_query_t const *q, udb_query_preparation_area_t *q_area)
{
value_list_t vl = VALUE_LIST_INIT;
- size_t i;
int status;
assert (r != NULL);
int status;
assert (r != NULL);
@@
-216,7
+214,7
@@
static int udb_result_submit (udb_result_t *r, /* {{{ */
}
vl.values_len = r_area->ds->ds_num;
}
vl.values_len = r_area->ds->ds_num;
- for (i = 0; i < r->values_num; i++)
+ for (
size_t
i = 0; i < r->values_num; i++)
{
char *value_str = r_area->values_buffer[i];
{
char *value_str = r_area->values_buffer[i];
@@
-286,7
+284,7
@@
static int udb_result_submit (udb_result_t *r, /* {{{ */
return (-ENOMEM);
}
return (-ENOMEM);
}
- for (i = 0; i < r->metadata_num; i++)
+ for (
size_t
i = 0; i < r->metadata_num; i++)
{
status = meta_data_add_string (vl.meta, r->metadata[i],
r_area->metadata_buffer[i]);
{
status = meta_data_add_string (vl.meta, r->metadata[i],
r_area->metadata_buffer[i]);
@@
-332,17
+330,15
@@
static int udb_result_handle_result (udb_result_t *r, /* {{{ */
udb_result_preparation_area_t *r_area,
udb_query_t const *q, char **column_values)
{
udb_result_preparation_area_t *r_area,
udb_query_t const *q, char **column_values)
{
- size_t i;
-
assert (r && q_area && r_area);
assert (r && q_area && r_area);
- for (i = 0; i < r->instances_num; i++)
+ for (
size_t
i = 0; i < r->instances_num; i++)
r_area->instances_buffer[i] = column_values[r_area->instances_pos[i]];
r_area->instances_buffer[i] = column_values[r_area->instances_pos[i]];
- for (i = 0; i < r->values_num; i++)
+ for (
size_t
i = 0; i < r->values_num; i++)
r_area->values_buffer[i] = column_values[r_area->values_pos[i]];
r_area->values_buffer[i] = column_values[r_area->values_pos[i]];
- for (i = 0; i < r->metadata_num; i++)
+ for (
size_t
i = 0; i < r->metadata_num; i++)
r_area->metadata_buffer[i] = column_values[r_area->metadata_pos[i]];
if (q->plugin_instance_from)
r_area->metadata_buffer[i] = column_values[r_area->metadata_pos[i]];
if (q->plugin_instance_from)
@@
-355,8
+351,6
@@
static int udb_result_prepare_result (udb_result_t const *r, /* {{{ */
udb_result_preparation_area_t *prep_area,
char **column_names, size_t column_num)
{
udb_result_preparation_area_t *prep_area,
char **column_names, size_t column_num)
{
- size_t i;
-
if ((r == NULL) || (prep_area == NULL))
return (-EINVAL);
if ((r == NULL) || (prep_area == NULL))
return (-EINVAL);
@@
-453,7
+447,7
@@
static int udb_result_prepare_result (udb_result_t const *r, /* {{{ */
/* }}} */
/* Determine the position of the plugin instance column {{{ */
/* }}} */
/* Determine the position of the plugin instance column {{{ */
- for (i = 0; i < r->instances_num; i++)
+ for (
size_t
i = 0; i < r->instances_num; i++)
{
size_t j;
{
size_t j;
@@
-477,7
+471,7
@@
static int udb_result_prepare_result (udb_result_t const *r, /* {{{ */
/* Determine the position of the value columns {{{ */
/* Determine the position of the value columns {{{ */
- for (i = 0; i < r->values_num; i++)
+ for (
size_t
i = 0; i < r->values_num; i++)
{
size_t j;
{
size_t j;
@@
-500,7
+494,7
@@
static int udb_result_prepare_result (udb_result_t const *r, /* {{{ */
} /* }}} for (i = 0; i < r->values_num; i++) */
/* Determine the position of the metadata columns {{{ */
} /* }}} for (i = 0; i < r->values_num; i++) */
/* Determine the position of the metadata columns {{{ */
- for (i = 0; i < r->metadata_num; i++)
+ for (
size_t
i = 0; i < r->metadata_num; i++)
{
size_t j;
{
size_t j;
@@
-528,23
+522,21
@@
static int udb_result_prepare_result (udb_result_t const *r, /* {{{ */
static void udb_result_free (udb_result_t *r) /* {{{ */
{
static void udb_result_free (udb_result_t *r) /* {{{ */
{
- size_t i;
-
if (r == NULL)
return;
sfree (r->type);
sfree (r->instance_prefix);
if (r == NULL)
return;
sfree (r->type);
sfree (r->instance_prefix);
- for (i = 0; i < r->instances_num; i++)
+ for (
size_t
i = 0; i < r->instances_num; i++)
sfree (r->instances[i]);
sfree (r->instances);
sfree (r->instances[i]);
sfree (r->instances);
- for (i = 0; i < r->values_num; i++)
+ for (
size_t
i = 0; i < r->values_num; i++)
sfree (r->values[i]);
sfree (r->values);
sfree (r->values[i]);
sfree (r->values);
- for (i = 0; i < r->metadata_num; i++)
+ for (
size_t
i = 0; i < r->metadata_num; i++)
sfree (r->metadata[i]);
sfree (r->metadata);
sfree (r->metadata[i]);
sfree (r->metadata);
@@
-558,7
+550,6
@@
static int udb_result_create (const char *query_name, /* {{{ */
{
udb_result_t *r;
int status;
{
udb_result_t *r;
int status;
- int i;
if (ci->values_num != 0)
{
if (ci->values_num != 0)
{
@@
-582,7
+573,7
@@
static int udb_result_create (const char *query_name, /* {{{ */
/* Fill the `udb_result_t' structure.. */
status = 0;
/* Fill the `udb_result_t' structure.. */
status = 0;
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
{
oconfig_item_t *child = ci->children + i;
@@
-680,7
+671,6
@@
int udb_query_create (udb_query_t ***ret_query_list, /* {{{ */
udb_query_t *q;
int status;
udb_query_t *q;
int status;
- int i;
if ((ret_query_list == NULL) || (ret_query_list_len == NULL))
return (-EINVAL);
if ((ret_query_list == NULL) || (ret_query_list_len == NULL))
return (-EINVAL);
@@
-715,7
+705,7
@@
int udb_query_create (udb_query_t ***ret_query_list, /* {{{ */
}
/* Fill the `udb_query_t' structure.. */
}
/* Fill the `udb_query_t' structure.. */
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
{
oconfig_item_t *child = ci->children + i;
@@
-802,12
+792,10
@@
int udb_query_create (udb_query_t ***ret_query_list, /* {{{ */
void udb_query_free (udb_query_t **query_list, size_t query_list_len) /* {{{ */
{
void udb_query_free (udb_query_t **query_list, size_t query_list_len) /* {{{ */
{
- size_t i;
-
if (query_list == NULL)
return;
if (query_list == NULL)
return;
- for (i = 0; i < query_list_len; i++)
+ for (
size_t
i = 0; i < query_list_len; i++)
udb_query_free_one (query_list[i]);
sfree (query_list);
udb_query_free_one (query_list[i]);
sfree (query_list);
@@
-817,7
+805,6
@@
int udb_query_pick_from_list_by_name (const char *name, /* {{{ */
udb_query_t **src_list, size_t src_list_len,
udb_query_t ***dst_list, size_t *dst_list_len)
{
udb_query_t **src_list, size_t src_list_len,
udb_query_t ***dst_list, size_t *dst_list_len)
{
- size_t i;
int num_added;
if ((name == NULL) || (src_list == NULL) || (dst_list == NULL)
int num_added;
if ((name == NULL) || (src_list == NULL) || (dst_list == NULL)
@@
-829,7
+816,7
@@
int udb_query_pick_from_list_by_name (const char *name, /* {{{ */
}
num_added = 0;
}
num_added = 0;
- for (i = 0; i < src_list_len; i++)
+ for (
size_t
i = 0; i < src_list_len; i++)
{
udb_query_t **tmp_list;
size_t tmp_list_len;
{
udb_query_t **tmp_list;
size_t tmp_list_len;
@@
-990,9
+977,7
@@
int udb_query_handle_result (udb_query_t const *q, /* {{{ */
#if defined(COLLECT_DEBUG) && COLLECT_DEBUG /* {{{ */
do
{
#if defined(COLLECT_DEBUG) && COLLECT_DEBUG /* {{{ */
do
{
- size_t i;
-
- for (i = 0; i < prep_area->column_num; i++)
+ for (size_t i = 0; i < prep_area->column_num; i++)
{
DEBUG ("db query utils: udb_query_handle_result (%s, %s): "
"column[%zu] = %s;",
{
DEBUG ("db query utils: udb_query_handle_result (%s, %s): "
"column[%zu] = %s;",
@@
-1053,9
+1038,7
@@
int udb_query_prepare_result (udb_query_t const *q, /* {{{ */
#if defined(COLLECT_DEBUG) && COLLECT_DEBUG
do
{
#if defined(COLLECT_DEBUG) && COLLECT_DEBUG
do
{
- size_t i;
-
- for (i = 0; i < column_num; i++)
+ for (size_t i = 0; i < column_num; i++)
{
DEBUG ("db query utils: udb_query_prepare_result: "
"query = %s; column[%zu] = %s;",
{
DEBUG ("db query utils: udb_query_prepare_result: "
"query = %s; column[%zu] = %s;",