perf callchains: Switch from strtok() to strtok_r() when parsing options
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 5 Apr 2017 14:38:10 +0000 (11:38 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 11 Apr 2017 11:45:09 +0000 (08:45 -0300)
Trying to keep everything reentrant.

Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/n/tip-rdce0p2k9e1b4qnrb8ki9mtf@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/callchain.c

index 3cea1fb5404b3ab787c4ad8682c0ece66e975387..2e5eff5abef06693fc7e90620efbd5975a0d25a0 100644 (file)
@@ -116,7 +116,7 @@ static int
 __parse_callchain_report_opt(const char *arg, bool allow_record_opt)
 {
        char *tok;
-       char *endptr;
+       char *endptr, *saveptr = NULL;
        bool minpcnt_set = false;
        bool record_opt_set = false;
        bool try_stack_size = false;
@@ -127,7 +127,7 @@ __parse_callchain_report_opt(const char *arg, bool allow_record_opt)
        if (!arg)
                return 0;
 
-       while ((tok = strtok((char *)arg, ",")) != NULL) {
+       while ((tok = strtok_r((char *)arg, ",", &saveptr)) != NULL) {
                if (!strncmp(tok, "none", strlen(tok))) {
                        callchain_param.mode = CHAIN_NONE;
                        callchain_param.enabled = false;