linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Luciano Coelho <luciano.coelho@intel.com>,
	Samuel Zou <zou_wei@huawei.com>,
	johannes.berg@intel.com, emmanuel.grumbach@intel.com,
	linuxwifi@intel.com, kvalo@codeaurora.org, davem@davemloft.net,
	Julia Lawall <julia.lawall@lip6.fr>
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, cocci <cocci@systeme.lip6.fr>
Subject: Re: [PATCH -next] iwlwifi: pcie: Use bitwise instead of arithmetic operator for flags
Date: Wed, 06 May 2020 08:15:08 -0700	[thread overview]
Message-ID: <2208e464cd8bd399cfb9b49abb5aed211f27b3a8.camel@perches.com> (raw)
In-Reply-To: <bfd6b3a7db0c50cd3d084510bd43c9e540688edd.camel@intel.com>

On Wed, 2020-05-06 at 16:51 +0300, Luciano Coelho wrote:
> On Tue, 2020-05-05 at 20:19 -0700, Joe Perches wrote:
> > On Wed, 2020-05-06 at 11:07 +0800, Samuel Zou wrote:
> > > This silences the following coccinelle warning:
> > > 
> > > "WARNING: sum of probable bitmasks, consider |"
> > 
> > I suggest instead ignoring bad and irrelevant warnings.
> > 
> > PREFIX_LEN is 32 not 0x20 or BIT(5)
> > PCI_DUMP_SIZE is 352
> > 
> > > diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
> > []
> > > @@ -109,9 +109,9 @@ void iwl_trans_pcie_dump_regs(struct iwl_trans *trans)
> > >  
> > >  	/* Alloc a max size buffer */
> > >  	alloc_size = PCI_ERR_ROOT_ERR_SRC +  4 + PREFIX_LEN;
> > > -	alloc_size = max_t(u32, alloc_size, PCI_DUMP_SIZE + PREFIX_LEN);
> > > -	alloc_size = max_t(u32, alloc_size, PCI_MEM_DUMP_SIZE + PREFIX_LEN);
> > > -	alloc_size = max_t(u32, alloc_size, PCI_PARENT_DUMP_SIZE + PREFIX_LEN);
> > > +	alloc_size = max_t(u32, alloc_size, PCI_DUMP_SIZE | PREFIX_LEN);
> > > +	alloc_size = max_t(u32, alloc_size, PCI_MEM_DUMP_SIZE | PREFIX_LEN);
> > > +	alloc_size = max_t(u32, alloc_size, PCI_PARENT_DUMP_SIZE | PREFIX_LEN);
> > >  
> > >  	buf = kmalloc(alloc_size, GFP_ATOMIC);
> > >  	if (!buf)
> 
> Yeah, those macros are clearly not bitmasks.  I'm dropping this patch.

Can the cocci script that generated this warning

scripts/coccinelle/misc/orplus.cocci

be dropped or improved to validate the likelihood that
the defines or constants used are more likely than
not are bit values?

Maybe these should be defined as hex or BIT or BIT_ULL
or GENMASK or the like?


Right now it seems it just tests for two constants.



  reply	other threads:[~2020-05-06 15:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06  3:07 [PATCH -next] iwlwifi: pcie: Use bitwise instead of arithmetic operator for flags Samuel Zou
2020-05-06  3:19 ` Joe Perches
2020-05-06 13:51   ` Luciano Coelho
2020-05-06 15:15     ` Joe Perches [this message]
2020-05-07  4:10       ` Samuel Zou

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=2208e464cd8bd399cfb9b49abb5aed211f27b3a8.camel@perches.com \
    --to=joe@perches.com \
    --cc=cocci@systeme.lip6.fr \
    --cc=davem@davemloft.net \
    --cc=emmanuel.grumbach@intel.com \
    --cc=johannes.berg@intel.com \
    --cc=julia.lawall@lip6.fr \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linuxwifi@intel.com \
    --cc=luciano.coelho@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=zou_wei@huawei.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).