lkml.org 
[lkml]   [2020]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 05/26] perf tools: Add build_id__is_defined function
    Em Mon, Sep 14, 2020 at 10:47:01PM +0200, Jiri Olsa escreveu:
    > On Mon, Sep 14, 2020 at 02:44:35PM +0900, Namhyung Kim wrote:
    > > On Mon, Sep 14, 2020 at 6:05 AM Jiri Olsa <jolsa@kernel.org> wrote:
    > > >
    > > > Adding build_id__is_defined helper to check build id
    > > > is defined and is != zero build id.
    > > >
    > > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    > > > ---
    > > > tools/perf/util/build-id.c | 11 +++++++++++
    > > > tools/perf/util/build-id.h | 1 +
    > > > 2 files changed, 12 insertions(+)
    > > >
    > > > diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
    > > > index 31207b6e2066..bdee4e08e60d 100644
    > > > --- a/tools/perf/util/build-id.c
    > > > +++ b/tools/perf/util/build-id.c
    > > > @@ -902,3 +902,14 @@ bool perf_session__read_build_ids(struct perf_session *session, bool with_hits)
    > > >
    > > > return ret;
    > > > }
    > > > +
    > > > +bool build_id__is_defined(const u8 *build_id)
    > > > +{
    > > > + static u8 zero[BUILD_ID_SIZE];
    > > > + int err = 0;
    > > > +
    > > > + if (build_id)
    > > > + err = memcmp(build_id, &zero, BUILD_ID_SIZE);
    > > > +
    > > > + return err ? true : false;
    > > > +}
    > >
    > > I think this is a bit confusing.. How about this?
    > >
    > > bool ret = false;
    > > if (build_id)
    > > ret = memcmp(...);
    > > return ret;
    >
    > ok
    >
    > >
    > > Or, it can be a oneliner..
    >
    > everything can be oneliner ;-)

    But has to pass checkpatch.pl, so no more than 80 chars.

    ;-)

    - Arnaldo

    \
     
     \ /
      Last update: 2020-09-14 23:52    [W:2.782 / U:0.204 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site