From: mrigendrachaubey <mrigendra.chaubey@gmail.com>
To: James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
mrigendrachaubey <mrigendra.chaubey@gmail.com>
Subject: [PATCH] scsi: scsi_devinfo: remove redundant 'found'
Date: Sat, 31 May 2025 11:16:38 +0530 [thread overview]
Message-ID: <20250531054638.46256-1-mrigendra.chaubey@gmail.com> (raw)
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 | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index a348df895dca..53cc60ab6dab 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -269,17 +269,13 @@ 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);
+ list_for_each_entry(devinfo_table, &scsi_dev_info_list, node) {
+ if (devinfo_table->key == key)
+ return devinfo_table;
+ }
- return devinfo_table;
+ return ERR_PTR(-EINVAL);
}
/*
--
2.34.1
next reply other threads:[~2025-05-31 5:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-31 5:46 mrigendrachaubey [this message]
2025-06-09 23:56 ` [PATCH] scsi: scsi_devinfo: remove redundant 'found' Bart Van Assche
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=20250531054638.46256-1-mrigendra.chaubey@gmail.com \
--to=mrigendra.chaubey@gmail.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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).