From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, paulus@samba.org,
hpa@zytor.com, mingo@kernel.org, jolsa@kernel.org,
a.p.zijlstra@chello.nl, mail@milianw.de, namhyung.kim@lge.com,
namhyung@kernel.org, jolsa@redhat.com, dsahern@gmail.com,
tglx@linutronix.de, cjashfor@linux.vnet.ibm.com
Subject: [tip:perf/core] perf tools: Fix line number in the config file error message
Date: Sat, 27 Sep 2014 00:26:46 -0700 [thread overview]
Message-ID: <tip-49757c9cc7887bc79f742eb8aacf16e464ca5f0b@git.kernel.org> (raw)
In-Reply-To: <20140923115656.GC2979@krava.brq.redhat.com>
Commit-ID: 49757c9cc7887bc79f742eb8aacf16e464ca5f0b
Gitweb: http://git.kernel.org/tip/49757c9cc7887bc79f742eb8aacf16e464ca5f0b
Author: Jiri Olsa <jolsa@redhat.com>
AuthorDate: Tue, 23 Sep 2014 13:56:56 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 26 Sep 2014 12:45:23 -0300
perf tools: Fix line number in the config file error message
If we fail to parse the config file within the callback function,
the line number counter 'could be' already on the next line.
This results in wrong line number report like:
$ cat ~/.perfconfig
[call-graph]
sort-key = krava
$ perf record ls
Fatal: bad config file line 3 in /home/jolsa/.perfconfig
Fixing this by saving the current line number for this case.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Milian Wolff <mail@milianw.de>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20140923115656.GC2979@krava.brq.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/config.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 953512e..57ff826 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -222,7 +222,8 @@ static int perf_parse_file(config_fn_t fn, void *data)
const unsigned char *bomptr = utf8_bom;
for (;;) {
- int c = get_next_char();
+ int line, c = get_next_char();
+
if (bomptr && *bomptr) {
/* We are at the file beginning; skip UTF8-encoded BOM
* if present. Sane editors won't put this in on their
@@ -261,8 +262,16 @@ static int perf_parse_file(config_fn_t fn, void *data)
if (!isalpha(c))
break;
var[baselen] = tolower(c);
- if (get_value(fn, data, var, baselen+1) < 0)
+
+ /*
+ * The get_value function might or might not reach the '\n',
+ * so saving the current line number for error reporting.
+ */
+ line = config_linenr;
+ if (get_value(fn, data, var, baselen+1) < 0) {
+ config_linenr = line;
break;
+ }
}
die("bad config file line %d in %s", config_linenr, config_file_name);
}
prev parent reply other threads:[~2014-09-27 7:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-23 1:01 [PATCHSET 0/5] perf tools: Add call-graph config options (v2) Namhyung Kim
2014-09-23 1:01 ` [PATCH 1/5] perf hists browser: Fix callchain print bug on TUI Namhyung Kim
2014-09-27 7:25 ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-09-23 1:01 ` [PATCH 2/5] perf tools: Move callchain config from record_opts to callchain_param Namhyung Kim
2014-09-27 7:25 ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-09-23 1:01 ` [PATCH 3/5] perf tools: Move some callchain parser functions to callchain.c Namhyung Kim
2014-09-27 7:26 ` [tip:perf/core] perf callchain: Move some " tip-bot for Namhyung Kim
2014-09-27 14:29 ` Frederic Weisbecker
2014-09-29 4:18 ` Namhyung Kim
2014-09-23 1:01 ` [PATCH 4/5] perf tools: Introduce perf_callchain_config() Namhyung Kim
2014-09-27 7:26 ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-09-23 1:01 ` [PATCH 5/5] perf tools: Convert {record,top}.call-graph option to call-graph.record-mode Namhyung Kim
2014-09-27 7:26 ` [tip:perf/core] perf tools: Convert {record, top}.call-graph " tip-bot for Namhyung Kim
2014-09-23 11:56 ` [PATCH] perf tools: Fix line number in the config file error message Jiri Olsa
2014-09-24 0:21 ` Namhyung Kim
2014-09-27 7:26 ` tip-bot for Jiri Olsa [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-49757c9cc7887bc79f742eb8aacf16e464ca5f0b@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=dsahern@gmail.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mail@milianw.de \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--cc=namhyung@kernel.org \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).