[PATCH] perf tool: Fix shadowed declaration in parse-events.c

From: Jiri Olsa
Date: Tue Sep 29 2015 - 11:05:46 EST


On Tue, Sep 29, 2015 at 11:52:59AM -0300, Arnaldo Carvalho de Melo wrote:

SNIP

> > > >>>
> > > >>
> > > >>Do I need to send new ones based on your patch below now?
> > > >
> > > >that'd be great.. also please make sure you don't reintroduce it
> > > >
> > >
> > > I saw Ingo just accepted ACME's pull request which contains my patches,
> > > then resend may reintroduce or conflict things, I will wait for ACME's
> > > suggestion for my lack of experience in this.
> >
> > hum, I can see your changes in pull request to Ingo,
> > but not in acme's perf/core.. strange.. let's wait
> > for Arnaldo to sort it out ;-)
>
> Sorry, probably I didn't push perf/core yesterday, just the
> perf-core-for-mingo tag.
>
> Anyway, please pull again, should have everything in there now plus some
> patches I processed today.

np, resending the patch rebase on your latest perf/core

thanks,
jirka


---
The error variable breaks build on CentOS 6.7, due to
collision with global error symbol:

CC util/parse-events.o
cc1: warnings being treated as errors
util/parse-events.c:419: error: declaration of âerrorâ shadows a global
declaration
util/util.h:135: error: shadowed declaration is here
util/parse-events.c: In function âadd_tracepoint_multi_eventâ:
...

Using different argument names instead to fix it.

Reported-by: Vinson Lee <vlee@xxxxxxxxxxxxxxxx>
Link: http://lkml.kernel.org/n/tip-i9mdgdbrgauy3fe76s9rd125@xxxxxxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/util/parse-events.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 5ffb356cbcc6..c01a44b18faf 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -389,7 +389,7 @@ int parse_events_add_cache(struct list_head *list, int *idx,
return add_event(list, idx, &attr, name, NULL);
}

-static void tracepoint_error(struct parse_events_error *error, int err,
+static void tracepoint_error(struct parse_events_error *e, int err,
char *sys, char *name)
{
char help[BUFSIZ];
@@ -402,30 +402,30 @@ static void tracepoint_error(struct parse_events_error *error, int err,

switch (err) {
case EACCES:
- error->str = strdup("can't access trace events");
+ e->str = strdup("can't access trace events");
break;
case ENOENT:
- error->str = strdup("unknown tracepoint");
+ e->str = strdup("unknown tracepoint");
break;
default:
- error->str = strdup("failed to add tracepoint");
+ e->str = strdup("failed to add tracepoint");
break;
}

tracing_path__strerror_open_tp(err, help, sizeof(help), sys, name);
- error->help = strdup(help);
+ e->help = strdup(help);
}

static int add_tracepoint(struct list_head *list, int *idx,
char *sys_name, char *evt_name,
- struct parse_events_error *error __maybe_unused,
+ struct parse_events_error *err,
struct list_head *head_config)
{
struct perf_evsel *evsel;

evsel = perf_evsel__newtp_idx(sys_name, evt_name, (*idx)++);
if (IS_ERR(evsel)) {
- tracepoint_error(error, PTR_ERR(evsel), sys_name, evt_name);
+ tracepoint_error(err, PTR_ERR(evsel), sys_name, evt_name);
return PTR_ERR(evsel);
}

@@ -443,7 +443,7 @@ static int add_tracepoint(struct list_head *list, int *idx,

static int add_tracepoint_multi_event(struct list_head *list, int *idx,
char *sys_name, char *evt_name,
- struct parse_events_error *error,
+ struct parse_events_error *err,
struct list_head *head_config)
{
char evt_path[MAXPATHLEN];
@@ -454,7 +454,7 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,
snprintf(evt_path, MAXPATHLEN, "%s/%s", tracing_events_path, sys_name);
evt_dir = opendir(evt_path);
if (!evt_dir) {
- tracepoint_error(error, errno, sys_name, evt_name);
+ tracepoint_error(err, errno, sys_name, evt_name);
return -1;
}

@@ -469,7 +469,7 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,
continue;

ret = add_tracepoint(list, idx, sys_name, evt_ent->d_name,
- error, head_config);
+ err, head_config);
}

closedir(evt_dir);
@@ -478,19 +478,19 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,

static int add_tracepoint_event(struct list_head *list, int *idx,
char *sys_name, char *evt_name,
- struct parse_events_error *error,
+ struct parse_events_error *err,
struct list_head *head_config)
{
return strpbrk(evt_name, "*?") ?
add_tracepoint_multi_event(list, idx, sys_name, evt_name,
- error, head_config) :
+ err, head_config) :
add_tracepoint(list, idx, sys_name, evt_name,
- error, head_config);
+ err, head_config);
}

static int add_tracepoint_multi_sys(struct list_head *list, int *idx,
char *sys_name, char *evt_name,
- struct parse_events_error *error,
+ struct parse_events_error *err,
struct list_head *head_config)
{
struct dirent *events_ent;
@@ -499,7 +499,7 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx,

events_dir = opendir(tracing_events_path);
if (!events_dir) {
- tracepoint_error(error, errno, sys_name, evt_name);
+ tracepoint_error(err, errno, sys_name, evt_name);
return -1;
}

@@ -515,7 +515,7 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx,
continue;

ret = add_tracepoint_event(list, idx, events_ent->d_name,
- evt_name, error, head_config);
+ evt_name, err, head_config);
}

closedir(events_dir);
--
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/