Messages in this thread | | | Date | Tue, 17 Nov 2020 21:53:59 +0100 | From | Jiri Olsa <> | Subject | Re: [PATCH 06/24] perf tools: Add build_id__is_defined function |
| |
On Tue, Nov 17, 2020 at 11:00:37AM -0800, Ian Rogers wrote: > On Tue, Nov 17, 2020 at 3:01 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 | 7 +++++++ > > tools/perf/util/build-id.h | 1 + > > 2 files changed, 8 insertions(+) > > > > diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c > > index 6b410c3d52dc..7d9ecc37849c 100644 > > --- a/tools/perf/util/build-id.c > > +++ b/tools/perf/util/build-id.c > > @@ -912,3 +912,10 @@ void build_id__init(struct build_id *bid, const u8 > > *data, size_t size) > > memcpy(bid->data, data, size); > > bid->size = size; > > } > > + > > +bool build_id__is_defined(const struct build_id *bid) > > +{ > > + static u8 zero[BUILD_ID_SIZE]; > > + > > + return bid && bid->size ? memcmp(bid->data, &zero, bid->size) : > > false; > > > > Fwiw, I find this method to test for zero a little hard to parse - I'm
heh, it's controversial one, Namhyung commented on this one in previous version, so I changed it ;-) https://lore.kernel.org/lkml/CAM9d7cjjGjTN8sDgLZ1PoQZ-sUXWjnVaNdyOVE1yHxq46PrPkw@mail.gmail.com/
> failing as a C programmer :-) Nit, should zero be const?
right, should be const, will change
thanks, jirka
| |