mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: mrigendrachaubey <mrigendra.chaubey@gmail.com>,
	James.Bottomley@HansenPartnership.com,
	martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] scsi: scsi_devinfo: remove redundant 'found'
Date: Mon, 23 Jun 2025 08:59:05 -0700	[thread overview]
Message-ID: <57435584-b04e-4de6-908c-018fe48ad0ac@acm.org> (raw)
In-Reply-To: <20250622055709.7893-1-mrigendra.chaubey@gmail.com>

On 6/21/25 10:57 PM, mrigendrachaubey wrote:
> Remove the unnecessary 'found' flag in scsi_devinfo_lookup_by_key().
> The loop can return the matching entry directly when found, and fall
> through to return ERR_PTR(-EINVAL) otherwise.
> 
> Signed-off-by: mrigendrachaubey <mrigendra.chaubey@gmail.com>
> ---
>   drivers/scsi/scsi_devinfo.c | 11 +++--------
>   1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
> index a348df895dca..e364829b6079 100644
> --- a/drivers/scsi/scsi_devinfo.c
> +++ b/drivers/scsi/scsi_devinfo.c
> @@ -269,17 +269,12 @@ static struct {
>   static struct scsi_dev_info_list_table *scsi_devinfo_lookup_by_key(int key)
>   {
>   	struct scsi_dev_info_list_table *devinfo_table;
> -	int found = 0;
>   
>   	list_for_each_entry(devinfo_table, &scsi_dev_info_list, node)
> -		if (devinfo_table->key == key) {
> -			found = 1;
> -			break;
> -		}
> -	if (!found)
> -		return ERR_PTR(-EINVAL);
> +		if (devinfo_table->key == key)
> +			return devinfo_table;
>   
> -	return devinfo_table;
> +	return ERR_PTR(-EINVAL);
>   }

Reviewed-by: Bart Van Assche <bvanassche@acm.org>


  reply	other threads:[~2025-06-23 15:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-22  5:57 mrigendrachaubey
2025-06-23 15:59 ` Bart Van Assche [this message]
2025-06-25  1:17 ` Martin K. Petersen
  -- strict thread matches above, loose matches on Subject: below --
2025-05-31  5:46 [PATCH] " mrigendrachaubey
2025-06-22  7:05 ` [PATCH v2] " mrigendrachaubey

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=57435584-b04e-4de6-908c-018fe48ad0ac@acm.org \
    --to=bvanassche@acm.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mrigendra.chaubey@gmail.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

all inboxes | Powered by JetHome®