@@ -9,6 +9,7 @@
#include <rte_cryptodev.h>
#include <rte_malloc.h>
#include <rte_ether.h>
+#include <rte_os_shim.h>
#include "cperf_options.h"
#include "cperf_test_common.h"
@@ -166,6 +167,7 @@ parse_range(const char *arg, uint32_t *min, uint32_t *max, uint32_t *inc)
{
char *token;
uint32_t number;
+ char *sp = NULL;
char *copy_arg = strdup(arg);
@@ -173,7 +175,7 @@ parse_range(const char *arg, uint32_t *min, uint32_t *max, uint32_t *inc)
return -1;
errno = 0;
- token = strtok(copy_arg, ":");
+ token = strtok_r(copy_arg, ":", &sp);
/* Parse minimum value */
if (token != NULL) {
@@ -187,7 +189,7 @@ parse_range(const char *arg, uint32_t *min, uint32_t *max, uint32_t *inc)
} else
goto err_range;
- token = strtok(NULL, ":");
+ token = strtok_r(NULL, ":", &sp);
/* Parse increment value */
if (token != NULL) {
@@ -201,7 +203,7 @@ parse_range(const char *arg, uint32_t *min, uint32_t *max, uint32_t *inc)
} else
goto err_range;
- token = strtok(NULL, ":");
+ token = strtok_r(NULL, ":", &sp);
/* Parse maximum value */
if (token != NULL) {
@@ -216,7 +218,7 @@ parse_range(const char *arg, uint32_t *min, uint32_t *max, uint32_t *inc)
} else
goto err_range;
- if (strtok(NULL, ":") != NULL)
+ if (strtok_r(NULL, ":", &sp) != NULL)
goto err_range;
free(copy_arg);
@@ -235,6 +237,7 @@ parse_list(const char *arg, uint32_t *list, uint32_t *min, uint32_t *max)
uint8_t count = 0;
uint32_t temp_min;
uint32_t temp_max;
+ char *sp = NULL;
char *copy_arg = strdup(arg);
@@ -242,7 +245,7 @@ parse_list(const char *arg, uint32_t *list, uint32_t *min, uint32_t *max)
return -1;
errno = 0;
- token = strtok(copy_arg, ",");
+ token = strtok_r(copy_arg, ",", &sp);
/* Parse first value */
if (token != NULL) {
@@ -258,7 +261,7 @@ parse_list(const char *arg, uint32_t *list, uint32_t *min, uint32_t *max)
} else
goto err_list;
- token = strtok(NULL, ",");
+ token = strtok_r(NULL, ",", &sp);
while (token != NULL) {
if (count == MAX_LIST) {
@@ -280,7 +283,7 @@ parse_list(const char *arg, uint32_t *list, uint32_t *min, uint32_t *max)
if (number > temp_max)
temp_max = number;
- token = strtok(NULL, ",");
+ token = strtok_r(NULL, ",", &sp);
}
if (min)
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include <rte_malloc.h>
+#include <rte_os_shim.h>
#include "cperf_options.h"
#include "cperf_test_vectors.h"
@@ -220,8 +221,9 @@ parse_values(char *tokens, uint8_t **data, uint32_t *data_length)
uint8_t *values, *values_resized;
char *tok, *error = NULL;
+ char *sp = NULL;
- tok = strtok(tokens, CPERF_VALUE_DELIMITER);
+ tok = strtok_r(tokens, CPERF_VALUE_DELIMITER, &sp);
if (tok == NULL)
return -1;
@@ -252,7 +254,7 @@ parse_values(char *tokens, uint8_t **data, uint32_t *data_length)
return -1;
}
- tok = strtok(NULL, CPERF_VALUE_DELIMITER);
+ tok = strtok_r(NULL, CPERF_VALUE_DELIMITER, &sp);
if (tok == NULL)
break;
@@ -283,6 +285,7 @@ parse_entry(char *entry, struct cperf_test_vector *vector,
uint8_t *data = NULL;
char *token, *key_token;
+ char *sp = NULL;
if (entry == NULL) {
printf("Expected entry value\n");
@@ -290,10 +293,10 @@ parse_entry(char *entry, struct cperf_test_vector *vector,
}
/* get key */
- token = strtok(entry, CPERF_ENTRY_DELIMITER);
+ token = strtok_r(entry, CPERF_ENTRY_DELIMITER, &sp);
key_token = token;
/* get values for key */
- token = strtok(NULL, CPERF_ENTRY_DELIMITER);
+ token = strtok_r(NULL, CPERF_ENTRY_DELIMITER, &sp);
if (key_token == NULL || token == NULL) {
printf("Expected 'key = values' but was '%.40s'..\n", entry);