All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
To: "Doherty,
	Declan" <declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: dev-VfR2kkLFssw@public.gmane.org
Subject: Re: [PATCH] eal / malloc : alignment parameter check failing due to changes in rte_is_power_of_2
Date: Mon, 19 Jan 2015 10:00:43 +0100	[thread overview]
Message-ID: <3882238.XjXCyuyOGj@xps13> (raw)
In-Reply-To: <345C63BAECC1AD42A2EC8C63AFFC3ADC2747EE3D-kPTMFJFq+rF9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>

2015-01-18 19:26, Doherty, Declan:
> From: Thomas Monjalon [mailto:thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org]
> > 2015-01-16 15:10, Declan Doherty:
> > > In commit 2fc8d6d the behaviour of function rte_is_power_of_2 was
> > > changed to not return true for 0. memzone_reserve_aligned_thread_unsafe
> > > and rte_malloc_socket both make the assumption that for align = 0
> > > !rte_is_power_of_2(align) will return false. This patch adds a check
> > > that align parameter is non-zero before doing the power of 2 check
> > >
> > > Signed-off-by: Declan Doherty <declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> > [...]
> > > -	if (!rte_is_power_of_2(align)) {
> > > +	if (align ? !rte_is_power_of_2(align) : 0) {
> > [...]
> > > -	if (size == 0 || !rte_is_power_of_2(align))
> > > +	if (size == 0 || align ? !rte_is_power_of_2(align) : 0)

There is an operator precedence bug here.
Parens are needed after ||.

> > I don't understand why you write "align ? !rte_is_power_of_2(align) : 0"
> > instead of the more readable "align && !rte_is_power_of_2(align)" ?
> > 
> > Pablo acked it so I guess there is something obvious I'm missing.
> 
> No there's nothing you're missing, this is just the way I saw the logic, if align is none
> zero, then test the power of 2 condition otherwise return 0. I have no problem with
> your suggestion in you prefer that, at the end of the day the logic test works out equivalent.

So I change to the simpler && form and I add parentheses
after || to correctly check size==0.

Applied with above changes.

Thanks
-- 
Thomas

      parent reply	other threads:[~2015-01-19  9:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-16 15:10 [PATCH] eal / malloc : alignment parameter check failing due to changes in rte_is_power_of_2 Declan Doherty
     [not found] ` <1421421030-22261-1-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-01-16 15:37   ` De Lara Guarch, Pablo
2015-01-16 17:01   ` Thomas Monjalon
2015-01-18 19:26     ` Doherty, Declan
     [not found]       ` <345C63BAECC1AD42A2EC8C63AFFC3ADC2747EE3D-kPTMFJFq+rF9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-01-19  9:00         ` Thomas Monjalon [this message]

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=3882238.XjXCyuyOGj@xps13 \
    --to=thomas.monjalon-pdr9zngts4eavxtiumwx3w@public.gmane.org \
    --cc=declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.