ACK: [PATCH] lib: fwts_framework: use strtok instead of strtok_r

ivanhu ivan.hu at canonical.com
Thu Mar 5 03:33:54 UTC 2015



On 2015年03月04日 17:42, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> CoverityScan is being a bit overly pedantic about the passing of
> the 3rd argument into strtok_r.  Since we're not running in a
> multi-threaded context, we can use strtok() instead and remove the
> need for the unrequired saveptr.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   src/lib/src/fwts_framework.c | 12 ++++--------
>   1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index b800632..d9896b4 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -950,9 +950,8 @@ static int fwts_framework_skip_test_parse(const char *arg, fwts_list *tests_to_s
>   {
>   	char *str;
>   	char *token;
> -	char *saveptr = NULL;
>   
> -	for (str = (char*)arg; (token = strtok_r(str, ",", &saveptr)) != NULL; str = NULL) {
> +	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
>   		fwts_framework_test *test;
>   
>   		if ((test = fwts_framework_test_find(token)) == NULL) {
> @@ -969,9 +968,8 @@ static int fwts_framework_filter_error_parse(const char *arg, fwts_list *list)
>   {
>   	char *str;
>   	char *token;
> -	char *saveptr = NULL;
>   
> -	for (str = (char*)arg; (token = strtok_r(str, ",", &saveptr)) != NULL; str = NULL) {
> +	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
>   		if (fwts_list_append(list, token) == NULL) {
>   			fprintf(stderr, "Out of memory parsing argument %s\n", arg);
>   			fwts_list_free_items(list, NULL);
> @@ -990,11 +988,10 @@ static int fwts_framework_log_type_parse(fwts_framework *fw, const char *arg)
>   {
>   	char *str;
>   	char *token;
> -	char *saveptr = NULL;
>   
>   	fw->log_type = 0;
>   
> -	for (str = (char*)arg; (token = strtok_r(str, ",", &saveptr)) != NULL; str = NULL) {
> +	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
>   		if (!strcmp(token, "plaintext"))
>   			fw->log_type |= LOG_TYPE_PLAINTEXT;
>   		else if (!strcmp(token, "json"))
> @@ -1023,11 +1020,10 @@ static int fwts_framework_acpica_parse(fwts_framework *fw, const char *arg)
>   {
>   	char *str;
>   	char *token;
> -	char *saveptr = NULL;
>   
>   	fw->acpica_mode = 0;
>   
> -	for (str = (char*)arg; (token = strtok_r(str, ",", &saveptr)) != NULL; str = NULL) {
> +	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
>   		if (!strcmp(token, "serialized"))
>   			fw->acpica_mode |= FWTS_ACPICA_MODE_SERIALIZED;
>   		else if (!strcmp(token, "slack"))

Acked-by: Ivan Hu <ivan.hu at canonical.com>




More information about the fwts-devel mailing list