lkml.org 
[lkml]   [2015]   [Sep]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf tools: Don't write to evsel if parser doesn't collect evsel
Em Wed, Sep 02, 2015 at 08:05:54PM +0800, pi3orama escreveu:
> 发自我的 iPhone
> > 在 2015年9月2日,下午7:54,Jiri Olsa <jolsa@redhat.com> 写道:
> >> On Wed, Sep 02, 2015 at 02:53:58PM +0800, Wangnan (F) wrote:
> >>> @@ -1252,7 +1262,13 @@ foreach_evsel_in_last_glob(struct perf_evlist *evlist,
> >>> struct perf_evsel *last = NULL;
> >>> int err;
> >>> - if (evlist->nr_entries > 0)
> >>> + /*
> >>> + * Don't return when list_empty, give func a chance to report
> >>> + * error when it found last == NULL.
> >>> + *
> >>> + * So no need to WARN here, let *func do this.
> >>> + */
> >>> + if (!list_empty(&evlist->entries))

> > why is it better than to check evlist->nr_entries?
> > evlist->nr_entries is equivalent to !list_empty(&evlist->entries) in here, right?

> By checking list we won't rely on the assumption that nr_entries reflects the
> actual number of elements in that list, makes the logic of this code more compact.

But why would we want to break that assumption?

If I see FOO->entries and FOO->nr_entries, it is reasonable to expect
that whatever data structure FOO->entries may be has FOO->nr_entries in
it, lets not break that assumption.

- Arnaldo

> Don't you think so?
>
> At this point they are equivalent, but the whole patch is preventive action.


\
 
 \ /
  Last update: 2015-09-02 16:21    [W:0.103 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site