diff --git a/plugins/processor_calyptia/calyptia_logs_from_lua.c b/plugins/processor_calyptia/calyptia_logs_from_lua.c index 165772e226a..6bf4e610b6f 100644 --- a/plugins/processor_calyptia/calyptia_logs_from_lua.c +++ b/plugins/processor_calyptia/calyptia_logs_from_lua.c @@ -6,6 +6,7 @@ int calyptia_logs_from_lua(struct flb_processor_instance *ins, lua_State *L, struct flb_mp_chunk_cobj *chunk_cobj) { + int i; int logs_length, metadata_length, timestamps_length; struct flb_mp_chunk_record *record; @@ -41,7 +42,7 @@ int calyptia_logs_from_lua(struct flb_processor_instance *ins, lua_State *L, return -1; } - for (int i = 1; i <= logs_length; i++) { + for (i = 1; i <= logs_length; i++) { record = flb_mp_chunk_record_create(chunk_cobj); if (!record) { flb_plg_error(ins, "failed to create record"); diff --git a/plugins/processor_calyptia/calyptia_metrics_from_lua.c b/plugins/processor_calyptia/calyptia_metrics_from_lua.c index 059af879637..10732abef71 100644 --- a/plugins/processor_calyptia/calyptia_metrics_from_lua.c +++ b/plugins/processor_calyptia/calyptia_metrics_from_lua.c @@ -21,10 +21,11 @@ struct metrics_header { static void free_labels(char **labels, size_t label_count) { + int i; if (!labels) { return; } - for (int i = 0; i < label_count; i++) { + for (i = 0; i < label_count; i++) { if (labels[i]) { free(labels[i]); } @@ -124,13 +125,14 @@ static double *lua_to_quantile_values(struct flb_processor_instance *ins, lua_State *L, double *quantile_keys, int count) { + int i; double *quantile_values = calloc(count, sizeof(*quantile_values)); if (!quantile_values) { flb_plg_error(ins, "could not allocate memory for quantile values"); return NULL; } - for (int i = 0; i < count; i++) { + for (i = 0; i < count; i++) { lua_pushnumber(L, quantile_keys[i]); lua_gettable(L, -2); quantile_values[i] = lua_to_double(L, -1); @@ -144,13 +146,14 @@ static uint64_t *lua_to_bucket_values(struct flb_processor_instance *ins, lua_State *L, double *bucket_keys, int count) { + int i; uint64_t *values = calloc(count, sizeof(*values)); if (!values) { flb_plg_error(ins, "could not allocate memory for bucket values"); return NULL; } - for (int i = 0; i < count; i++) { + for (i = 0; i < count; i++) { lua_pushnumber(L, bucket_keys[i]); lua_gettable(L, -2); values[i] = lua_to_uint(L); @@ -163,6 +166,7 @@ static uint64_t *lua_to_bucket_values(struct flb_processor_instance *ins, static double *lua_to_quantiles_buckets(struct flb_processor_instance *ins, lua_State *L, int *count) { + int i; double *keys; *count = 0; if (lua_type(L, -1) != LUA_TTABLE) { @@ -183,7 +187,7 @@ static double *lua_to_quantiles_buckets(struct flb_processor_instance *ins, } lua_pushnil(L); // first key - int i = 0; + i = 0; while (lua_next(L, -2) != 0) { keys[i] = lua_to_double(L, -2); i++; @@ -200,6 +204,7 @@ static double *lua_to_quantile_bucket_keys(struct flb_processor_instance *ins, lua_State *L, const char *kind, int *count) { + int i; int sample_count; double *keys; @@ -214,7 +219,7 @@ static double *lua_to_quantile_bucket_keys(struct flb_processor_instance *ins, int found = 0; /* find the first sample that has quantiles */ - for (int i = 1; i <= sample_count; i++) { + for (i = 1; i <= sample_count; i++) { lua_rawgeti(L, -1, i); lua_getfield(L, -1, kind); if (lua_type(L, -1) == LUA_TTABLE) { @@ -272,6 +277,7 @@ static char **append_label(char **labels, size_t *labels_size, static char **lua_to_label_keys(struct flb_processor_instance *ins, lua_State *L, int *label_count) { + int i; int sample_count; char **label_keys; size_t label_index; @@ -295,7 +301,7 @@ static char **lua_to_label_keys(struct flb_processor_instance *ins, labels_size = 0; label_index = 0; - for (int i = 1; i <= sample_count; i++) { + for (i = 1; i <= sample_count; i++) { lua_rawgeti(L, -1, i); if (lua_type(L, -1) != LUA_TTABLE) { free_labels(label_keys, label_index); @@ -357,6 +363,8 @@ int calyptia_metrics_from_lua(struct flb_processor_instance *ins, lua_State *L, char **label_vals; int label_count; uint64_t timestamp; + int i; + int j; if (lua_type(L, -1) != LUA_TTABLE) { flb_plg_error(ins, "expected metrics array"); @@ -365,7 +373,7 @@ int calyptia_metrics_from_lua(struct flb_processor_instance *ins, lua_State *L, metric_count = lua_objlen(L, -1); - for (int i = 1; i <= metric_count; i++) { + for (i = 1; i <= metric_count; i++) { lua_rawgeti(L, -1, i); label_keys = lua_to_label_keys(ins, L, &label_count); @@ -465,7 +473,7 @@ int calyptia_metrics_from_lua(struct flb_processor_instance *ins, lua_State *L, return -1; } - for (int j = 1; j <= sample_count; j++) { + for (j = 1; j <= sample_count; j++) { label_vals = NULL; /* get sample */ diff --git a/plugins/processor_calyptia/calyptia_metrics_to_lua.c b/plugins/processor_calyptia/calyptia_metrics_to_lua.c index 557ce623889..dd59c97f307 100644 --- a/plugins/processor_calyptia/calyptia_metrics_to_lua.c +++ b/plugins/processor_calyptia/calyptia_metrics_to_lua.c @@ -81,6 +81,7 @@ static void push_histogram(lua_State *L, struct cmt_map *map, static void push_summary(lua_State *L, struct cmt_map *map, struct cmt_metric *metric) { + int i; struct cmt_summary *summary; struct cmt_opts *opts; @@ -89,7 +90,7 @@ static void push_summary(lua_State *L, struct cmt_map *map, if (metric->sum_quantiles_set) { lua_createtable(L, summary->quantiles_count, 0); - for (int i = 0; i < summary->quantiles_count; i++) { + for (i = 0; i < summary->quantiles_count; i++) { lua_pushnumber(L, summary->quantiles[i]); lua_pushnumber(L, cmt_summary_quantile_get_value(metric, i)); lua_settable(L, -3); diff --git a/plugins/processor_calyptia/lua_to_cfl.c b/plugins/processor_calyptia/lua_to_cfl.c index 4229508b8e8..d96fd905cac 100644 --- a/plugins/processor_calyptia/lua_to_cfl.c +++ b/plugins/processor_calyptia/lua_to_cfl.c @@ -76,9 +76,10 @@ bool lua_isinteger(lua_State *L, int index) struct cfl_array *lua_array_to_variant(lua_State *L, int array_len) { + int i; struct cfl_array *array = cfl_array_create(array_len); - for (int i = 1; i <= array_len; i++) { + for (i = 1; i <= array_len; i++) { lua_rawgeti(L, -1, i); struct cfl_variant *variant = lua_to_variant(L, -1); cfl_array_append(array, variant);