From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752737AbdDLFgf (ORCPT ); Wed, 12 Apr 2017 01:36:35 -0400 Received: from terminus.zytor.com ([65.50.211.136]:56053 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750979AbdDLFgd (ORCPT ); Wed, 12 Apr 2017 01:36:33 -0400 Date: Tue, 11 Apr 2017 22:34:25 -0700 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: acme@redhat.com, mingo@kernel.org, tglx@linutronix.de, dsahern@gmail.com, hpa@zytor.com, linux-kernel@vger.kernel.org Reply-To: mingo@kernel.org, acme@redhat.com, hpa@zytor.com, tglx@linutronix.de, dsahern@gmail.com, linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf script: Use strtok_r() when parsing output field list Git-Commit-ID: 49346e858f34eda103d7c0e85c06edbaebfc83a9 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 49346e858f34eda103d7c0e85c06edbaebfc83a9 Gitweb: http://git.kernel.org/tip/49346e858f34eda103d7c0e85c06edbaebfc83a9 Author: Arnaldo Carvalho de Melo AuthorDate: Wed, 5 Apr 2017 11:43:41 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 11 Apr 2017 08:45:09 -0300 perf script: Use strtok_r() when parsing output field list Just avoiding non-reentrant functions. Cc: David Ahern Link: http://lkml.kernel.org/n/tip-eqytykipd74epzl9aexvppcg@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-script.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 46acc8e..2dab70f 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -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;