From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C36F7C63697 for ; Tue, 17 Nov 2020 20:54:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6672222240 for ; Tue, 17 Nov 2020 20:54:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dg6PqXsT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726466AbgKQUyP (ORCPT ); Tue, 17 Nov 2020 15:54:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51742 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726297AbgKQUyP (ORCPT ); Tue, 17 Nov 2020 15:54:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605646453; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Na5qrtekWhtUQWyADlsoTi+TWRlxFpXFSkHs1Gld4JY=; b=dg6PqXsT2y6+N26rS3npXlYuY+7qbDXd/kXxtEzw87IOkKFlF6DdMxCsmgHJa056JHhFiO zWBLXmNMWKmykS6kXeyVQ4Cb2k7oDS71eVfERrcXAhEQEc7BI0BWcJWpZIciOgCc7G9cmg ybhQV73y+QWNGnGYL7pdJd8Xw1jkWcc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-WJ5oIdGpNcWrgVNJG58W-g-1; Tue, 17 Nov 2020 15:54:06 -0500 X-MC-Unique: WJ5oIdGpNcWrgVNJG58W-g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D5D08030B9; Tue, 17 Nov 2020 20:54:04 +0000 (UTC) Received: from krava (unknown [10.40.192.215]) by smtp.corp.redhat.com (Postfix) with SMTP id 660526B8E9; Tue, 17 Nov 2020 20:54:00 +0000 (UTC) Date: Tue, 17 Nov 2020 21:53:59 +0100 From: Jiri Olsa To: Ian Rogers Cc: Jiri Olsa , Arnaldo Carvalho de Melo , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Song Liu , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: Re: [PATCH 06/24] perf tools: Add build_id__is_defined function Message-ID: <20201117205359.GJ1216482@krava> References: <20201117110053.1303113-1-jolsa@kernel.org> <20201117110053.1303113-7-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 17, 2020 at 11:00:37AM -0800, Ian Rogers wrote: > On Tue, Nov 17, 2020 at 3:01 AM Jiri Olsa wrote: > > > Adding build_id__is_defined helper to check build id > > is defined and is != zero build id. > > > > Signed-off-by: Jiri Olsa > > --- > > 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