From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Sergey Shtylyov <s.shtylyov@omp.ru>, linux-ide@vger.kernel.org
Subject: Re: [PATCH] ata: pata_sil680: fix result type of sil680_sel{dev|reg}()
Date: Tue, 12 Apr 2022 07:49:39 +0900 [thread overview]
Message-ID: <c77dce62-4851-786c-392a-dae21c8112bd@opensource.wdc.com> (raw)
In-Reply-To: <bfd973a5-87ea-148e-ea88-72881b202761@omp.ru>
On 4/12/22 05:42, Sergey Shtylyov wrote:
> Hello!
>
> On 4/11/22 2:47 AM, Damien Le Moal wrote:
>
>>> sil680_sel{dev|reg}() return a PCI config space address but needlessly
>>> use the *unsigned long* type for that, whereas the PCI config space
>>> accessors take *int* for the address parameter. Switch these functions
>>> to returning *int*, updating the local variables at their call sites.
>>> Add the empty lines after some declarations, while at it...
>>>
>>> Found by Linux Verification Center (linuxtesting.org) with the SVACE static
>>> analysis tool.
>>>
>>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>>>
>>> ---
>>> This patch is against the 'for-next' branch of Damien Le Moal's 'libata.git'
>>> repo.
>>>
>>> drivers/ata/pata_sil680.c | 27 +++++++++++++++------------
>>> 1 file changed, 15 insertions(+), 12 deletions(-)
>>>
>>> Index: libata/drivers/ata/pata_sil680.c
>>> ===================================================================
>>> --- libata.orig/drivers/ata/pata_sil680.c
>>> +++ libata/drivers/ata/pata_sil680.c
>>> @@ -47,9 +47,10 @@
>>> * criticial.
>>> */
>>>
>>> -static unsigned long sil680_selreg(struct ata_port *ap, int r)
>>> +static int sil680_selreg(struct ata_port *ap, int r)
>>> {
>>> - unsigned long base = 0xA0 + r;
>>> + int base = 0xA0 + r;
>>> +
>>> base += (ap->port_no << 4);
>>> return base;
>>
>> The variable "base" is rather useless here... A simple:
>>
>> return 0xA0 + r + (ap->port_no << 4);
>>
>> would work too and is a lot cleaner.
>
> Yes, probably... but it's a matter of a separate patch, I think.
> Note that both functions are inlined by gcc.
No need for a separate patch. Your patch already changes the base variable
type. It may as well remove it :)
>
> [...]
>
> MBR, Sergey
--
Damien Le Moal
Western Digital Research
prev parent reply other threads:[~2022-04-11 22:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-09 20:29 [PATCH] ata: pata_sil680: fix result type of sil680_sel{dev|reg}() Sergey Shtylyov
2022-04-10 23:47 ` Damien Le Moal
2022-04-11 20:42 ` Sergey Shtylyov
2022-04-11 22:49 ` Damien Le Moal [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=c77dce62-4851-786c-392a-dae21c8112bd@opensource.wdc.com \
--to=damien.lemoal@opensource.wdc.com \
--cc=linux-ide@vger.kernel.org \
--cc=s.shtylyov@omp.ru \
/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