From: Arnaldo Carvalho de Melo Date: Wed, 5 Apr 2017 14:38:10 +0000 (-0300) Subject: perf callchains: Switch from strtok() to strtok_r() when parsing options X-Git-Tag: MMI-PSA29.97-13-9~5737^2~12^2~17 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dadafc315ded31a36cb4899bc85ef4050f0332a7;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git perf callchains: Switch from strtok() to strtok_r() when parsing options Trying to keep everything reentrant. Cc: Namhyung Kim Link: http://lkml.kernel.org/n/tip-rdce0p2k9e1b4qnrb8ki9mtf@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 3cea1fb5404b..2e5eff5abef0 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -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;