Browse code

db_redis: declare variables at the beginning of the function

- compiling with gcc 4.9 on debian jessie gives:
error: 'for' loop initial declarations are only allowed in C99 or C11 mode

Daniel-Constantin Mierla authored on 23/11/2019 10:10:40
Showing 1 changed files
... ...
@@ -923,6 +923,7 @@ static int db_redis_scan_query_keys(km_redis_con_t *con, const str *table_name,
923 923
     char *match = NULL;
924 924
     int ret;
925 925
     redisReply *reply = NULL;
926
+    int i, j;
926 927
 
927 928
     *query_keys = NULL;
928 929
     *query_keys_count = 0;
... ...
@@ -992,7 +993,7 @@ static int db_redis_scan_query_keys(km_redis_con_t *con, const str *table_name,
992 993
         memcpy(match, ts_scan_key->s, scan_offset);
993 994
 
994 995
         // append a number of ?. minimum string length is 10 digits
995
-        for (int i = 0; i < scan_length - 1; i++) {
996
+        for (i = 0; i < scan_length - 1; i++) {
996 997
             int len = scan_offset + i;
997 998
             char match_char = ts_scan_key->s[len];
998 999
             // skip non-numbers
... ...
@@ -1020,7 +1021,7 @@ static int db_redis_scan_query_keys(km_redis_con_t *con, const str *table_name,
1020 1021
         }
1021 1022
     }
1022 1023
 
1023
-    for (int i = 0; i < scan_length; i++) {
1024
+    for (i = 0; i < scan_length; i++) {
1024 1025
         int len = scan_offset + i;
1025 1026
         char match_char = ts_scan_key->s[len];
1026 1027
         // skip non-numbers
... ...
@@ -1042,7 +1043,7 @@ static int db_redis_scan_query_keys(km_redis_con_t *con, const str *table_name,
1042 1043
         else
1043 1044
             len += sprintf(match + len, "[%c-9]", match_char + 1);
1044 1045
         // finish with trailing ?s
1045
-	for (int j = i + 1; j < scan_length; j++) {
1046
+	for (j = i + 1; j < scan_length; j++) {
1046 1047
             match_char = ts_scan_key->s[scan_offset + j];
1047 1048
             // skip non-numbers
1048 1049
             if (match_char < '0' || match_char > '9') {
... ...
@@ -1108,7 +1109,7 @@ static int db_redis_scan_query_keys(km_redis_con_t *con, const str *table_name,
1108 1109
 
1109 1110
         LM_DBG("adding %i keys returned from set", (int) reply->elements);
1110 1111
 
1111
-        for (int i = 0; i < reply->elements; i++) {
1112
+        for (i = 0; i < reply->elements; i++) {
1112 1113
             if (reply->element[i]->type != REDIS_REPLY_STRING) {
1113 1114
                 LM_ERR("Unexpected entry key type in type query, expecting a string\n");
1114 1115
                 goto out;