@@ -21,10 +21,11 @@ struct metrics_header {
2121
2222static void free_labels (char * * labels , size_t label_count )
2323{
24+ int i ;
2425 if (!labels ) {
2526 return ;
2627 }
27- for (int i = 0 ; i < label_count ; i ++ ) {
28+ for (i = 0 ; i < label_count ; i ++ ) {
2829 if (labels [i ]) {
2930 free (labels [i ]);
3031 }
@@ -59,7 +60,8 @@ static void split_fqname(const char *fqname, struct metrics_header *header)
5960static int assign_label (char * * keys , size_t key_count , char * * values ,
6061 const char * key , const char * value )
6162{
62- for (size_t i = 0 ; i < key_count ; i ++ ) {
63+ size_t i ;
64+ for (i = 0 ; i < key_count ; i ++ ) {
6365 if (!strcmp (keys [i ], key )) {
6466 values [i ] = strdup (value );
6567 if (!values [i ]) {
@@ -124,13 +126,14 @@ static double *lua_to_quantile_values(struct flb_processor_instance *ins,
124126 lua_State * L , double * quantile_keys ,
125127 int count )
126128{
129+ int i ;
127130 double * quantile_values = calloc (count , sizeof (* quantile_values ));
128131 if (!quantile_values ) {
129132 flb_plg_error (ins , "could not allocate memory for quantile values" );
130133 return NULL ;
131134 }
132135
133- for (int i = 0 ; i < count ; i ++ ) {
136+ for (i = 0 ; i < count ; i ++ ) {
134137 lua_pushnumber (L , quantile_keys [i ]);
135138 lua_gettable (L , -2 );
136139 quantile_values [i ] = lua_to_double (L , -1 );
@@ -144,13 +147,14 @@ static uint64_t *lua_to_bucket_values(struct flb_processor_instance *ins,
144147 lua_State * L , double * bucket_keys ,
145148 int count )
146149{
150+ int i ;
147151 uint64_t * values = calloc (count , sizeof (* values ));
148152 if (!values ) {
149153 flb_plg_error (ins , "could not allocate memory for bucket values" );
150154 return NULL ;
151155 }
152156
153- for (int i = 0 ; i < count ; i ++ ) {
157+ for (i = 0 ; i < count ; i ++ ) {
154158 lua_pushnumber (L , bucket_keys [i ]);
155159 lua_gettable (L , -2 );
156160 values [i ] = lua_to_uint (L );
@@ -163,6 +167,7 @@ static uint64_t *lua_to_bucket_values(struct flb_processor_instance *ins,
163167static double * lua_to_quantiles_buckets (struct flb_processor_instance * ins ,
164168 lua_State * L , int * count )
165169{
170+ int i ;
166171 double * keys ;
167172 * count = 0 ;
168173 if (lua_type (L , -1 ) != LUA_TTABLE ) {
@@ -183,7 +188,7 @@ static double *lua_to_quantiles_buckets(struct flb_processor_instance *ins,
183188 }
184189
185190 lua_pushnil (L ); // first key
186- int i = 0 ;
191+ i = 0 ;
187192 while (lua_next (L , -2 ) != 0 ) {
188193 keys [i ] = lua_to_double (L , -2 );
189194 i ++ ;
@@ -200,6 +205,7 @@ static double *lua_to_quantile_bucket_keys(struct flb_processor_instance *ins,
200205 lua_State * L , const char * kind ,
201206 int * count )
202207{
208+ int i ;
203209 int sample_count ;
204210 double * keys ;
205211
@@ -214,7 +220,7 @@ static double *lua_to_quantile_bucket_keys(struct flb_processor_instance *ins,
214220 int found = 0 ;
215221
216222 /* find the first sample that has quantiles */
217- for (int i = 1 ; i <= sample_count ; i ++ ) {
223+ for (i = 1 ; i <= sample_count ; i ++ ) {
218224 lua_rawgeti (L , -1 , i );
219225 lua_getfield (L , -1 , kind );
220226 if (lua_type (L , -1 ) == LUA_TTABLE ) {
@@ -240,7 +246,8 @@ static double *lua_to_quantile_bucket_keys(struct flb_processor_instance *ins,
240246static char * * append_label (char * * labels , size_t * labels_size ,
241247 size_t * label_index , const char * label )
242248{
243- for (size_t i = 0 ; i < * label_index ; i ++ ) {
249+ size_t i ;
250+ for (i = 0 ; i < * label_index ; i ++ ) {
244251 if (!strcmp (labels [i ], label )) {
245252 /* don't do anything if the label is already in the array */
246253 return labels ;
@@ -272,6 +279,7 @@ static char **append_label(char **labels, size_t *labels_size,
272279static char * * lua_to_label_keys (struct flb_processor_instance * ins ,
273280 lua_State * L , int * label_count )
274281{
282+ int i ;
275283 int sample_count ;
276284 char * * label_keys ;
277285 size_t label_index ;
@@ -295,7 +303,7 @@ static char **lua_to_label_keys(struct flb_processor_instance *ins,
295303 labels_size = 0 ;
296304 label_index = 0 ;
297305
298- for (int i = 1 ; i <= sample_count ; i ++ ) {
306+ for (i = 1 ; i <= sample_count ; i ++ ) {
299307 lua_rawgeti (L , -1 , i );
300308 if (lua_type (L , -1 ) != LUA_TTABLE ) {
301309 free_labels (label_keys , label_index );
@@ -357,6 +365,8 @@ int calyptia_metrics_from_lua(struct flb_processor_instance *ins, lua_State *L,
357365 char * * label_vals ;
358366 int label_count ;
359367 uint64_t timestamp ;
368+ int i ;
369+ int j ;
360370
361371 if (lua_type (L , -1 ) != LUA_TTABLE ) {
362372 flb_plg_error (ins , "expected metrics array" );
@@ -365,7 +375,7 @@ int calyptia_metrics_from_lua(struct flb_processor_instance *ins, lua_State *L,
365375
366376 metric_count = lua_objlen (L , -1 );
367377
368- for (int i = 1 ; i <= metric_count ; i ++ ) {
378+ for (i = 1 ; i <= metric_count ; i ++ ) {
369379 lua_rawgeti (L , -1 , i );
370380
371381 label_keys = lua_to_label_keys (ins , L , & label_count );
@@ -465,7 +475,7 @@ int calyptia_metrics_from_lua(struct flb_processor_instance *ins, lua_State *L,
465475 return -1 ;
466476 }
467477
468- for (int j = 1 ; j <= sample_count ; j ++ ) {
478+ for (j = 1 ; j <= sample_count ; j ++ ) {
469479 label_vals = NULL ;
470480
471481 /* get sample */
0 commit comments