Silence static analyser warnings related to strtok() function use

Some static analyser warn about strtok() function being deprecated since
it does not support reentrant use cases. While the uses here in
sigma_dut are not really reentrant in the current design, it is
relatively change to move to using strtok_r() to avoid such analyser
warnings.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
diff --git a/ap.c b/ap.c
index 383cda3..7957a44 100644
--- a/ap.c
+++ b/ap.c
@@ -547,20 +547,21 @@
 		int nss, mcs;
 		char token[20];
 		char *result = NULL;
+		char *saveptr;
 
 		if (strlen(val) >= sizeof(token))
 			return -1;
 		strcpy(token, val);
-		result = strtok(token, ";");
+		result = strtok_r(token, ";", &saveptr);
 		nss = atoi(result);
-		result = strtok(NULL, ";");
+		result = strtok_r(NULL, ";", &saveptr);
 		if (result == NULL) {
 			sigma_dut_print(dut, DUT_MSG_ERROR,
 					"VHTMCS NOT SPECIFIED!");
 			return 0;
 		}
-		result = strtok(result, "-");
-		result = strtok(NULL, "-");
+		result = strtok_r(result, "-", &saveptr);
+		result = strtok_r(NULL, "-", &saveptr);
 		mcs = atoi(result);
 		switch (nss) {
 		case 1:
@@ -2254,6 +2255,7 @@
 	DIR *dir_in;
 	FILE *fp;
 	char *pid, *temp;
+	char *saveptr;
 
 	if (dir == NULL)
 		return -1;
@@ -2277,8 +2279,8 @@
 		if (fgets(buf, 100, fp) == NULL)
 			buf[0] = '\0';
 		fclose(fp);
-		pid = strtok(buf, " ");
-		temp = strtok(NULL, " ");
+		pid = strtok_r(buf, " ", &saveptr);
+		temp = strtok_r(NULL, " ", &saveptr);
 		if (pid && temp &&
 		    strncmp(temp, proc_name, strlen(proc_name)) == 0) {
 			sigma_dut_print(dut, DUT_MSG_INFO,
@@ -6491,6 +6493,7 @@
 	char *token, *result;
 	int nss = 0, chwidth = 0;
 	char buf[100];
+	char *saveptr;
 
 	/*
 	 * The following commands should be invoked to generate
@@ -6501,7 +6504,7 @@
 	token = strdup(val);
 	if (!token)
 		return -1;
-	result = strtok(token, ";");
+	result = strtok_r(token, ";", &saveptr);
 	if (result) {
 		int count = atoi(result);
 
@@ -6524,7 +6527,7 @@
 	}
 
 	/* Extract the Channel width info */
-	result = strtok(NULL, ";");
+	result = strtok_r(NULL, ";", &saveptr);
 	if (result) {
 		switch (atoi(result)) {
 		case 20:
@@ -6570,11 +6573,12 @@
 	int nss, mcs;
 	char *token, *result;
 	char buf[100];
+	char *saveptr;
 
 	token = strdup(val);
 	if (!token)
 		return -1;
-	result = strtok(token, ";");
+	result = strtok_r(token, ";", &saveptr);
 	if (strcasecmp(result, "def") != 0) {
 		nss = atoi(result);
 
@@ -6596,7 +6600,7 @@
 		}
 	}
 
-	result = strtok(NULL, ";");
+	result = strtok_r(NULL, ";", &saveptr);
 	if (strcasecmp(result, "def") == 0) {
 		if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) {
 			snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs 7",
@@ -6634,17 +6638,18 @@
 	int channel = 36;
 	int chwidth = 80;
 	char buf[100];
+	char *saveptr;
 
 	/* Extract the channel info */
 	token = strdup(val);
 	if (!token)
 		return -1;
-	result = strtok(token, ";");
+	result = strtok_r(token, ";", &saveptr);
 	if (result)
 		channel = atoi(result);
 
 	/* Extract the channel width info */
-	result = strtok(NULL, ";");
+	result = strtok_r(NULL, ";", &saveptr);
 	if (result)
 		chwidth = atoi(result);
 
@@ -6813,12 +6818,13 @@
 	char *token, *result;
 	int channel = 36;
 	char buf[100];
+	char *saveptr;
 
 	/* Extract the channel info */
 	token = strdup(val);
 	if (!token)
 		return -1;
-	result = strtok(token, ";");
+	result = strtok_r(token, ";", &saveptr);
 	if (result)
 		channel = atoi(result);
 
diff --git a/sta.c b/sta.c
index 5b96ef3..7303b41 100644
--- a/sta.c
+++ b/sta.c
@@ -2441,10 +2441,11 @@
 	char token[50];
 	char *result;
 	char buf[100];
+	char *saveptr;
 
 	strncpy(token, val, sizeof(token));
 	token[sizeof(token) - 1] = '\0';
-	result = strtok(token, ":");
+	result = strtok_r(token, ":", &saveptr);
 	while (result) {
 		if (strcmp(result, "disable") == 0) {
 			snprintf(buf, sizeof(buf),
@@ -2459,7 +2460,7 @@
 			sigma_dut_print(dut, DUT_MSG_ERROR,
 					"iwpriv noackpolicy failed");
 		}
-		result = strtok(NULL, ":");
+		result = strtok_r(NULL, ":", &saveptr);
 		counter++;
 	}
 }
@@ -3843,6 +3844,7 @@
 		char *bss_line;
 		char *bss_id = NULL;
 		const char *ifname = get_param(cmd, "Interface");
+		char *saveptr;
 
 		if (ifname == NULL) {
 			sigma_dut_print(dut, DUT_MSG_INFO,
@@ -3867,7 +3869,7 @@
 				ifname, bss_list);
 
 		snprintf(buf, sizeof(buf), "DeviceList");
-		bss_line = strtok(bss_list, "\n");
+		bss_line = strtok_r(bss_list, "\n", &saveptr);
 		while (bss_line) {
 			if (sscanf(bss_line, "bssid=%ms", &bss_id) > 0 &&
 			    bss_id) {
@@ -3898,7 +3900,7 @@
 				}
 			}
 
-			bss_line = strtok(NULL, "\n");
+			bss_line = strtok_r(NULL, "\n", &saveptr);
 		}
 
 		sigma_dut_print(dut, DUT_MSG_INFO, "DiscoveredDevList is %s",
@@ -4361,10 +4363,11 @@
 		char delim[] = ";";
 		char token[30];
 		int value, config_val = 0;
+		char *saveptr;
 
 		strncpy(token, val, sizeof(token));
 		token[sizeof(token) - 1] = '\0';
-		result = strtok(token, delim);
+		result = strtok_r(token, delim, &saveptr);
 
 		/* Extract the NSS information */
 		if (result) {
@@ -4403,7 +4406,7 @@
 		}
 
 		/* Extract the channel width information */
-		result = strtok(NULL, delim);
+		result = strtok_r(NULL, delim, &saveptr);
 		if (result) {
 			value = atoi(result);
 			switch (value) {
@@ -4447,10 +4450,11 @@
 		char token[20];
 		char *result = NULL;
 		unsigned int vht_mcsmap = 0;
+		char *saveptr;
 
 		strncpy(token, val, sizeof(token));
 		token[sizeof(token) - 1] = '\0';
-		result = strtok(token, ";");
+		result = strtok_r(token, ";", &saveptr);
 		if (!result) {
 			sigma_dut_print(dut, DUT_MSG_ERROR,
 					"VHT NSS not specified");
@@ -4464,14 +4468,14 @@
 					"iwpriv nss failed");
 		}
 
-		result = strtok(NULL, ";");
+		result = strtok_r(NULL, ";", &saveptr);
 		if (result == NULL) {
 			sigma_dut_print(dut, DUT_MSG_ERROR,
 					"VHTMCS NOT SPECIFIED!");
 			return 0;
 		}
-		result = strtok(result, "-");
-		result = strtok(NULL, "-");
+		result = strtok_r(result, "-", &saveptr);
+		result = strtok_r(NULL, "-", &saveptr);
 		if (!result) {
 			sigma_dut_print(dut, DUT_MSG_ERROR,
 					"VHT MCS not specified");
@@ -6491,11 +6495,12 @@
 		/* String (nss_operating_mode; mcs_operating_mode) */
 		int nss, mcs;
 		char buf[50];
+		char *saveptr;
 
 		token = strdup(val);
 		if (!token)
 			return 0;
-		result = strtok(token, ";");
+		result = strtok_r(token, ";", &saveptr);
 		if (strcasecmp(result, "def") != 0) {
 			nss = atoi(result);
 			if (nss == 4)
@@ -6509,7 +6514,7 @@
 			}
 		}
 
-		result = strtok(NULL, ";");
+		result = strtok_r(NULL, ";", &saveptr);
 		if (strcasecmp(result, "def") == 0) {
 			snprintf(buf, sizeof(buf), "iwpriv %s set11NRates 0",
 				 intf);