Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1224602
| From | Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 4/5] perf tools: Propagate error info from tp_format |
| Date | 2015-09-15 04:40 +0200 |
| Message-ID | <q8Ok2-8ll-1@gated-at.bofh.it> (permalink) |
| References | (3 earlier) <q75oZ-4nU-7@gated-at.bofh.it> <q8J10-Ci-19@gated-at.bofh.it> <q8JaF-12P-15@gated-at.bofh.it> <q8JDI-1AN-1@gated-at.bofh.it> <q8K6K-2nU-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Em Mon, Sep 14, 2015 at 06:05:38PM -0400, Raphaël Beamonte escreveu:
> 2015-09-14 17:36 GMT-04:00 Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>:
> > Em Mon, Sep 14, 2015 at 04:59:41PM -0400, Raphaël Beamonte escreveu:
> >> 2015-09-14 16:53 GMT-04:00 Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>:
> >> > +++ b/tools/perf/util/evsel.c
> >> > @@ -234,7 +234,9 @@ struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int
> >> > struct perf_evsel *evsel = zalloc(perf_evsel__object.size);
> >> > int err = -ENOMEM;
> >> >
> >> > - if (evsel != NULL) {
> >> > + if (evsel == NULL) {
> >> > + goto out_err;
> >> > + } else {
> >>
> >> Is the else really necessary after a goto?
> >
> > Not really, we can remove it and all would be equivalent (the code
> > with/without should be the same), its just that I wanted to avoid
> > touching the identation to reduce patch size and since we need o open a
> > brace to declare that attr variable...
>
> Ok. Though, given the content of that function, we could probably
> declare attr in the first lines of the function and assign it its
> value after the if. But I understand the patch size argument! :o)
Yeah, in other times I would have cleaned it all up, having that else is
ugly, but review time is more expensive, I think, so we need to reduce
its cost.
Cleaning it up makes it easier to read, but we get the info about when
that particular code was written buried a bit below the reindentation
cset.
Would be nice to have a 'git blame' that would just unwind things like
that :-)
> On another subject, but on the same lines, shouldn't we use if
> (!evsel) instead of if (evsel == NULL)? (kernel code style if I'm not
> mistaken) Or is there something that prevents from using it here?
I'd say both are ok. (evsel) is shorter than (evsel != NULL), but the
later is more expressive, at a glance you know it is a pointer, etc.
- Arnaldo
> >> > struct perf_event_attr attr = {
> >> > .type = PERF_TYPE_TRACEPOINT,
> >> > .sample_type = (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME |
> >> > @@ -261,6 +263,7 @@ struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int
> >> > out_free:
> >> > zfree(&evsel->name);
> >> > free(evsel);
> >> > +out_err:
> >> > return ERR_PTR(err);
> >> > }
> >> >
> >> > diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c
> >> > index 8e3a60e3e15f..802bb868d446 100644
> >> > --- a/tools/perf/util/trace-event.c
> >> > +++ b/tools/perf/util/trace-event.c
> >> > @@ -100,7 +100,7 @@ struct event_format*
> >> > trace_event__tp_format(const char *sys, const char *name)
> >> > {
> >> > if (!tevent_initialized && trace_event__init2())
> >> > - return NULL;
> >> > + return ERR_PTR(-ENOMEM);
> >> >
> >> > return tp_format(sys, name);
> >> > }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: [PATCH 4/5] perf tools: Propagate error info from tp_format Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-09 23:00 +0200
Re: [PATCH 4/5] perf tools: Propagate error info from tp_format Jiri Olsa <jolsa@redhat.com> - 2015-09-10 10:30 +0200
Re: [PATCH 4/5] perf tools: Propagate error info from tp_format Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-10 16:20 +0200
Re: [PATCH 4/5] perf tools: Propagate error info from tp_format Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 23:00 +0200
Re: [PATCH 4/5] perf tools: Propagate error info from tp_format Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 23:10 +0200
Re: [PATCH 4/5] perf tools: Propagate error info from tp_format Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-14 23:10 +0200
Re: [PATCH 4/5] perf tools: Propagate error info from tp_format Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> - 2015-09-14 23:40 +0200
Re: [PATCH 4/5] perf tools: Propagate error info from tp_format Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-15 00:10 +0200
Re: [PATCH 4/5] perf tools: Propagate error info from tp_format Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> - 2015-09-15 04:40 +0200
csiph-web