All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Guo Ren <guoren@kernel.org>
Cc: andriy.shevchenko@linux.intel.com, davem@davemloft.net,
	edumazet@google.com, pabeni@redhat.com, linux@rasmusvillemoes.dk,
	yury.norov@gmail.com, caraitto@google.com, willemb@google.com,
	jonolson@google.com, amritha.nambiar@intel.com,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	Guo Ren <guoren@linux.alibaba.com>
Subject: Re: [PATCH V2 1/2] net: Fixup netif_attrmask_next_and warning
Date: Fri, 14 Oct 2022 08:52:19 -0700	[thread overview]
Message-ID: <20221014085219.635d25cd@kernel.org> (raw)
In-Reply-To: <CAJF2gTQyMHNHLizeU-gvUdA5hRLUWxvHXuVVqSoPg3M_WxPPdw@mail.gmail.com>

On Fri, 14 Oct 2022 14:38:56 +0800 Guo Ren wrote:
> > This does not look equivalent, have you tested it?
> >
> > nr_ids is unsigned, doesn't it mean we'll never enter the loop?  
> 
> Yes, you are right. Any unsigned int would break the result.
> (gdb) p (int)-1 < (int)2
> $1 = 1
> (gdb) p (int)-1 < (unsigned int)2
> $2 = 0
> (gdb) p (unsigned int)-1 < (int)2
> $4 = 0
> 
> So it should be:
>  -     for (j = -1; j = netif_attrmask_next_and(j, online_mask, mask, nr_ids),
>  -          j < nr_ids;) {
>  +     for (j = -1; j < (int)nr_ids;
>  +          j = netif_attrmask_next_and(j, online_mask, mask, nr_ids)) {
> 
> Right? Of cause, nr_ids couldn't be 0xffffffff (-1).

No. You can't enter the loop with -1 as the iterator either. 
Let's move on.

  reply	other threads:[~2022-10-14 15:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14  3:04 [PATCH V2 0/2] net: Fixup cpu_mask usage guoren
2022-10-14  3:04 ` [PATCH V2 1/2] net: Fixup netif_attrmask_next_and warning guoren
2022-10-14  3:35   ` Jakub Kicinski
2022-10-14  3:39     ` Jakub Kicinski
2022-10-14  4:42       ` Yury Norov
2022-10-14  6:42         ` Guo Ren
2022-10-14 16:03         ` Jakub Kicinski
2022-10-14 16:16           ` Yury Norov
2022-10-14 18:03             ` Jakub Kicinski
2022-10-15  1:41           ` Guo Ren
2022-10-14  6:38     ` Guo Ren
2022-10-14 15:52       ` Jakub Kicinski [this message]
2022-10-15  1:38         ` Guo Ren
2022-10-14 10:00   ` Andy Shevchenko
2022-10-14 10:04     ` Guo Ren
2022-10-14  3:04 ` [PATCH V2 2/2] net: Fixup virtnet_set_affinity() cause cpumask warning guoren
2022-10-14 10:00   ` Andy Shevchenko
2022-10-14 10:04     ` Guo Ren
2022-10-17  1:58   ` Xuan Zhuo
2022-10-17  2:46     ` Guo Ren
2022-10-17  2:58       ` Xuan Zhuo

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=20221014085219.635d25cd@kernel.org \
    --to=kuba@kernel.org \
    --cc=amritha.nambiar@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=caraitto@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=guoren@kernel.org \
    --cc=guoren@linux.alibaba.com \
    --cc=jonolson@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    --cc=yury.norov@gmail.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 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.