All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <alex.elder@linaro.org>
To: Dan Carpenter <error27@gmail.com>
Cc: elder@linaro.org, kernel-janitors@vger.kernel.org
Subject: Re: [bug report] net: ipa: reduce arguments to ipa_table_init_add()
Date: Sat, 19 Nov 2022 03:04:50 -0600	[thread overview]
Message-ID: <847759a7-9501-194a-0314-2ec3eceb1613@linaro.org> (raw)
In-Reply-To: <Y3W83708rvg1Krvy@kadam>

On 11/16/22 22:47, Dan Carpenter wrote:
> On Tue, Nov 15, 2022 at 11:00:49AM -0600, Alex Elder wrote:
>>> drivers/net/ipa/ipa_table.c
>>>      413			count = mem->size / sizeof(__le64);
>>>      414			hash_count = hash_mem && hash_mem->size / sizeof(__le64);
>>
>> Line 414 is wrong.  It should be:
>>      hash_count = hash_mem ? hash_mem->size / sizeof(__le64) : 0;
>>
> 
> Heh.  It really feels like this line should have generated a checker
> warning as well.  I've created two versions.  The first complains when
> ever there is a divide used as a condition:

I agree, this is a good case to identify if you can.

> 
> 	if (a / b) {

That seems reasonable.  In a real "if" statement it is
along the lines of an assignment used as a condition,
where a second set of parentheses can be used to indicate
it's intentional.

> The other complains when it's part of a logical && or ||.
> 
> 	if (a && a / b) {

I don't know how Smatch works, but at the C parser level
it seems any divide used in a conditional context might
be worth paying attention to.

> 
> drivers/net/ipa/ipa_table.c:414 ipa_table_init_add() warn: divide condition: 'hash_mem->size / 8'
> drivers/net/ipa/ipa_table.c:414 ipa_table_init_add() warn: divide condition (logical): 'hash_mem->size / 8'
> 
> I'll test them out tonight and see if either gives useful results.

Sounds good.  Sorry I didn't respond a few days ago, I'm away
from home and am not keeping up with everything well.

					-Alex

> 
> regards,
> dan carpenter
> 


      parent reply	other threads:[~2022-11-19  9:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15 13:03 [bug report] net: ipa: reduce arguments to ipa_table_init_add() Dan Carpenter
2022-11-15 17:00 ` Alex Elder
2022-11-17  4:47   ` Dan Carpenter
2022-11-18  9:50     ` Dan Carpenter
2022-11-19  9:21       ` Alex Elder
2022-11-19 10:48         ` Dan Carpenter
2022-11-19  9:04     ` Alex Elder [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=847759a7-9501-194a-0314-2ec3eceb1613@linaro.org \
    --to=alex.elder@linaro.org \
    --cc=elder@linaro.org \
    --cc=error27@gmail.com \
    --cc=kernel-janitors@vger.kernel.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.