linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marco Pagani <marpagan@redhat.com>
To: Moritz Fischer <mdf@kernel.org>
Cc: Wu Hao <hao.wu@intel.com>, Xu Yilun <yilun.xu@intel.com>,
	Tom Rix <trix@redhat.com>,
	linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fpga: altera-pr-ip: fix unsigned comparison with less than zero
Date: Fri, 22 Apr 2022 17:47:02 +0200	[thread overview]
Message-ID: <736b71d7-1e07-f5c3-d8ad-c3e1b1595d5c@redhat.com> (raw)
In-Reply-To: <Yl+K789ZUWd5Si0B@archbook>

On 2022-04-20 06:24, Moritz Fischer wrote:
> Marco,
> 
> On Tue, Apr 05, 2022 at 08:53:49PM +0200, Marco Pagani wrote:
>> Fix the "comparison with less than zero" warning reported by
>> cppcheck for the unsigned (size_t) parameter "count" of the
>> "alt_pr_fpga_write()" function.
>>
> Should this have a Reported-by: tag?

I found this problem using the "cppcheck" tool, as reported in the
commit log. I did not find any previous report of this. Am I missing
something?

>> Signed-off-by: Marco Pagani <marpagan@redhat.com>
>> ---
>>  drivers/fpga/altera-pr-ip-core.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/fpga/altera-pr-ip-core.c b/drivers/fpga/altera-pr-ip-core.c
>> index be0667968d33..2ff3d8e46a0c 100644
>> --- a/drivers/fpga/altera-pr-ip-core.c
>> +++ b/drivers/fpga/altera-pr-ip-core.c
>> @@ -108,7 +108,7 @@ static int alt_pr_fpga_write(struct fpga_manager *mgr, const char *buf,
>>  	u32 *buffer_32 = (u32 *)buf;
>>  	size_t i = 0;
>>  
>> -	if (count <= 0)
>> +	if (count == 0)
>>  		return -EINVAL;
> 
> if (!count)
> 	return -EINVAL?

Ok, I'll change that in v2.

>>  
>>  	/* Write out the complete 32-bit chunks */
>> -- 
>> 2.35.1
> 
> Cheers,
> Moritz
>>
> 

Cheers,
Marco


      reply	other threads:[~2022-04-22 15:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 18:53 [PATCH] fpga: altera-pr-ip: fix unsigned comparison with less than zero Marco Pagani
2022-04-06 14:18 ` Tom Rix
2022-04-07  2:09   ` Xu Yilun
2022-04-20  4:24 ` Moritz Fischer
2022-04-22 15:47   ` Marco Pagani [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=736b71d7-1e07-f5c3-d8ad-c3e1b1595d5c@redhat.com \
    --to=marpagan@redhat.com \
    --cc=hao.wu@intel.com \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdf@kernel.org \
    --cc=trix@redhat.com \
    --cc=yilun.xu@intel.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).