]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
perf script: Use strtok_r() when parsing output field list
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 5 Apr 2017 14:43:41 +0000 (11:43 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 11 Apr 2017 11:45:09 +0000 (08:45 -0300)
Just avoiding non-reentrant functions.

Cc: David Ahern <dsahern@gmail.com>
Link: http://lkml.kernel.org/n/tip-eqytykipd74epzl9aexvppcg@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-script.c

index 46acc8ece41fe3f61bd4fb78f03b3d2d9ffd7097..2dab70fba2babbbd25473fd5acba463fb03bcc5c 100644 (file)
@@ -1708,7 +1708,7 @@ static int parse_scriptname(const struct option *opt __maybe_unused,
 static int parse_output_fields(const struct option *opt __maybe_unused,
                            const char *arg, int unset __maybe_unused)
 {
-       char *tok;
+       char *tok, *strtok_saveptr = NULL;
        int i, imax = ARRAY_SIZE(all_output_options);
        int j;
        int rc = 0;
@@ -1769,7 +1769,7 @@ static int parse_output_fields(const struct option *opt __maybe_unused,
                }
        }
 
-       for (tok = strtok(tok, ","); tok; tok = strtok(NULL, ",")) {
+       for (tok = strtok_r(tok, ",", &strtok_saveptr); tok; tok = strtok_r(NULL, ",", &strtok_saveptr)) {
                for (i = 0; i < imax; ++i) {
                        if (strcmp(tok, all_output_options[i].str) == 0)
                                break;