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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47002C43334 for ; Sun, 19 Jun 2022 17:13:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236755AbiFSRNB convert rfc822-to-8bit (ORCPT ); Sun, 19 Jun 2022 13:13:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232771AbiFSRM7 (ORCPT ); Sun, 19 Jun 2022 13:12:59 -0400 Received: from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D0C110BE; Sun, 19 Jun 2022 10:12:58 -0700 (PDT) Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 3E71D1C0B8F; Sun, 19 Jun 2022 19:12:57 +0200 (CEST) Date: Sun, 19 Jun 2022 19:12:48 +0200 From: Pavel Machek To: Ian Rogers Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Yuze Chi Subject: Re: [PATCH] libbpf: Fix is_pow_of_2 Message-ID: <20220619171248.GC3362@bug> References: <20220603041701.2799595-1-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: <20220603041701.2799595-1-irogers@google.com> User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi! > From: Yuze Chi > > +++ b/tools/lib/bpf/libbpf.c > @@ -4956,7 +4956,7 @@ static void bpf_map__destroy(struct bpf_map *map); > > static bool is_pow_of_2(size_t x) > { > - return x && (x & (x - 1)); > + return x && !(x & (x - 1)); > } I'm pretty sure we have this test in macro in includes somewhere... should we use that instead? Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html