* [PATCH -next] iwlwifi: pcie: Use bitwise instead of arithmetic operator for flags
@ 2020-05-06 3:07 Samuel Zou
2020-05-06 3:19 ` Joe Perches
0 siblings, 1 reply; 5+ messages in thread
From: Samuel Zou @ 2020-05-06 3:07 UTC (permalink / raw)
To: johannes.berg, emmanuel.grumbach, luciano.coelho, linuxwifi,
kvalo, davem
Cc: linux-wireless, netdev, linux-kernel, Samuel Zou
This silences the following coccinelle warning:
"WARNING: sum of probable bitmasks, consider |"
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Samuel Zou <zou_wei@huawei.com>
---
drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index a0daae0..6d9bf9f 100644
--- 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)
--
2.6.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH -next] iwlwifi: pcie: Use bitwise instead of arithmetic operator for flags
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
0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2020-05-06 3:19 UTC (permalink / raw)
To: Samuel Zou, johannes.berg, emmanuel.grumbach, luciano.coelho,
linuxwifi, kvalo, davem
Cc: linux-wireless, netdev, linux-kernel
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)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH -next] iwlwifi: pcie: Use bitwise instead of arithmetic operator for flags
2020-05-06 3:19 ` Joe Perches
@ 2020-05-06 13:51 ` Luciano Coelho
2020-05-06 15:15 ` Joe Perches
0 siblings, 1 reply; 5+ messages in thread
From: Luciano Coelho @ 2020-05-06 13:51 UTC (permalink / raw)
To: Joe Perches, Samuel Zou, johannes.berg, emmanuel.grumbach,
linuxwifi, kvalo, davem
Cc: linux-wireless, netdev, linux-kernel
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.
--
Cheers,
Luca.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH -next] iwlwifi: pcie: Use bitwise instead of arithmetic operator for flags
2020-05-06 13:51 ` Luciano Coelho
@ 2020-05-06 15:15 ` Joe Perches
2020-05-07 4:10 ` Samuel Zou
0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2020-05-06 15:15 UTC (permalink / raw)
To: Luciano Coelho, Samuel Zou, johannes.berg, emmanuel.grumbach,
linuxwifi, kvalo, davem, Julia Lawall
Cc: linux-wireless, netdev, linux-kernel, cocci
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH -next] iwlwifi: pcie: Use bitwise instead of arithmetic operator for flags
2020-05-06 15:15 ` Joe Perches
@ 2020-05-07 4:10 ` Samuel Zou
0 siblings, 0 replies; 5+ messages in thread
From: Samuel Zou @ 2020-05-07 4:10 UTC (permalink / raw)
To: Joe Perches, Luciano Coelho, johannes.berg, emmanuel.grumbach,
linuxwifi, kvalo, davem, Julia Lawall
Cc: linux-wireless, netdev, linux-kernel, cocci
Both of you are right.
I neglected, and this patch is wrong.
Thanks.
On 2020/5/6 23:15, Joe Perches wrote:
> 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.
>
>
>
> .
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-05-07 4:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2020-05-07 4:10 ` Samuel Zou
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).