netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zvi Effron <zeffron@riotgames.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: Ian Rogers <irogers@google.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org, Yuze Chi <chiyuze@google.com>
Subject: Re: [PATCH] libbpf: Fix is_pow_of_2
Date: Tue, 21 Jun 2022 18:03:27 -0500	[thread overview]
Message-ID: <CAC1LvL0rZcEHe_ZHDcB38XD49FmdURg4+yKHP0O=J7=4Xx8M3Q@mail.gmail.com> (raw)
In-Reply-To: <20220619171248.GC3362@bug>

On Sun, Jun 19, 2022 at 12:13 PM Pavel Machek <pavel@ucw.cz> wrote:
>
> Hi!
>
> > From: Yuze Chi <chiyuze@google.com>
> >
> > +++ 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?

I went looking for a macro that provided this check and could not find one. I
did find the inlined static function is_power_of_2 in log2.h, though, that we
could use.

> Pavel
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  reply	other threads:[~2022-06-21 23:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03  4:17 [PATCH] libbpf: Fix is_pow_of_2 Ian Rogers
2022-06-03  4:31 ` Zvi Effron
2022-06-03  5:33   ` Andrii Nakryiko
2022-06-03  5:35     ` Andrii Nakryiko
2022-06-19 17:12 ` Pavel Machek
2022-06-21 23:03   ` Zvi Effron [this message]
2022-06-22  0:20     ` Tiezhu Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAC1LvL0rZcEHe_ZHDcB38XD49FmdURg4+yKHP0O=J7=4Xx8M3Q@mail.gmail.com' \
    --to=zeffron@riotgames.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chiyuze@google.com \
    --cc=daniel@iogearbox.net \
    --cc=irogers@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).