[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <deee5abe-1992-426d-a62d-51249014bdc9@vivo.com>
Date: Wed, 20 Aug 2025 20:50:08 +0800
From: Qianfeng Rong <rongqianfeng@...o.com>
To: David Laight <david.laight.linux@...il.com>
Cc: Don Brace <don.brace@...rochip.com>,
"James E.J. Bottomley" <James.Bottomley@...senPartnership.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
"open list:HEWLETT-PACKARD SMART ARRAY RAID DRIVER (hpsa)"
<storagedev@...rochip.com>,
"open list:HEWLETT-PACKARD SMART ARRAY RAID DRIVER (hpsa)"
<linux-scsi@...r.kernel.org>, open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/6] scsi: hpsa: use min()/min_t() to improve code
在 2025/8/20 20:02, David Laight 写道:
> [You don't often get email from david.laight.linux@...il.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> On Fri, 15 Aug 2025 20:16:04 +0800
> Qianfeng Rong <rongqianfeng@...o.com> wrote:
>
>> Use min()/min_t() to reduce the code in complete_scsi_command() and
>> hpsa_vpd_page_supported(), and improve readability.
>>
>> Signed-off-by: Qianfeng Rong <rongqianfeng@...o.com>
>> ---
>> drivers/scsi/hpsa.c | 11 +++--------
>> 1 file changed, 3 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
>> index c73a71ac3c29..95dfcbac997f 100644
>> --- a/drivers/scsi/hpsa.c
>> +++ b/drivers/scsi/hpsa.c
>> @@ -2662,10 +2662,8 @@ static void complete_scsi_command(struct CommandList *cp)
>> case CMD_TARGET_STATUS:
>> cmd->result |= ei->ScsiStatus;
>> /* copy the sense data */
>> - if (SCSI_SENSE_BUFFERSIZE < sizeof(ei->SenseInfo))
>> - sense_data_size = SCSI_SENSE_BUFFERSIZE;
>> - else
>> - sense_data_size = sizeof(ei->SenseInfo);
>> + sense_data_size = min_t(unsigned long, SCSI_SENSE_BUFFERSIZE,
>> + sizeof(ei->SenseInfo));
> Why min_t() ?
> A plain min() should be fine.
> If it isn't you should really need to justify why the type of one parameter
> can't be changes before using min_t().
SCSI_SENSE_BUFFERSIZE is a macro definition and is generally of type int.
The return type of sizeof(ei->SenseInfo) is size_t, so I used min_t()
here. However, as you mentioned, min() can also be used. Do I need to
send v2?
Best regards,
Qianfeng
Powered by blists - more mailing lists