Browse Source

siputils: declare iterator out if for loop for C99 compiler

- for sip_generate_charging_vector()
- variables declared at the begining of blocks
Daniel-Constantin Mierla 7 tháng trước cách đây
mục cha
commit
6b0b8cb84b

+ 6 - 3
src/modules/siputils/chargingvector.c

@@ -88,6 +88,9 @@ static void sip_generate_charging_vector(char *pcv, const unsigned int maxsize)
 	static struct in_addr ip = {0};
 	static struct in_addr ip = {0};
 	unsigned char newConferenceIdentifier[SIZE_CONF_ID] = {0};
 	unsigned char newConferenceIdentifier[SIZE_CONF_ID] = {0};
 	int len = SIZE_CONF_ID;
 	int len = SIZE_CONF_ID;
+	int i;
+	char *ptr = NULL;
+	char *endptr = NULL;
 
 
 	/* if supplied buffer cannot carry 16 (SIZE_CONF_ID) hex characters and a null
 	/* if supplied buffer cannot carry 16 (SIZE_CONF_ID) hex characters and a null
 		terminator (=33 bytes), then reduce length of generated icid-value */
 		terminator (=33 bytes), then reduce length of generated icid-value */
@@ -145,10 +148,10 @@ static void sip_generate_charging_vector(char *pcv, const unsigned int maxsize)
 		idx++;
 		idx++;
 	}
 	}
 	LM_DBG("PCV generate\n");
 	LM_DBG("PCV generate\n");
-	char *ptr = pcv;
-	const char *endptr = ptr + maxsize - 1;
+	ptr = pcv;
+	endptr = ptr + maxsize - 1;
 
 
-	for(int i = 0; i < len && ptr < endptr; i++) {
+	for(i = 0; i < len && ptr < endptr; i++) {
 		ptr += snprintf(ptr, 3, "%02X", newConferenceIdentifier[i]);
 		ptr += snprintf(ptr, 3, "%02X", newConferenceIdentifier[i]);
 	}
 	}
 }
 }