* [PATCH v2] scsi: scsi_devinfo: remove redundant 'found'
@ 2025-06-22 5:57 mrigendrachaubey
2025-06-23 15:59 ` Bart Van Assche
2025-06-25 1:17 ` Martin K. Petersen
0 siblings, 2 replies; 4+ messages in thread
From: mrigendrachaubey @ 2025-06-22 5:57 UTC (permalink / raw)
To: James.Bottomley, martin.petersen
Cc: linux-scsi, linux-kernel, mrigendrachaubey
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);
}
/*
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2] scsi: scsi_devinfo: remove redundant 'found'
2025-05-31 5:46 [PATCH] " mrigendrachaubey
@ 2025-06-22 7:05 ` mrigendrachaubey
0 siblings, 0 replies; 4+ messages in thread
From: mrigendrachaubey @ 2025-06-22 7:05 UTC (permalink / raw)
To: James.Bottomley, martin.petersen
Cc: linux-scsi, linux-kernel, mrigendrachaubey
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);
}
/*
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] scsi: scsi_devinfo: remove redundant 'found'
2025-06-22 5:57 [PATCH v2] scsi: scsi_devinfo: remove redundant 'found' mrigendrachaubey
@ 2025-06-23 15:59 ` Bart Van Assche
2025-06-25 1:17 ` Martin K. Petersen
1 sibling, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2025-06-23 15:59 UTC (permalink / raw)
To: mrigendrachaubey, James.Bottomley, martin.petersen
Cc: linux-scsi, linux-kernel
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] scsi: scsi_devinfo: remove redundant 'found'
2025-06-22 5:57 [PATCH v2] scsi: scsi_devinfo: remove redundant 'found' mrigendrachaubey
2025-06-23 15:59 ` Bart Van Assche
@ 2025-06-25 1:17 ` Martin K. Petersen
1 sibling, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2025-06-25 1:17 UTC (permalink / raw)
To: mrigendrachaubey
Cc: James.Bottomley, martin.petersen, linux-scsi, linux-kernel
> 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.
Applied to 6.17/scsi-staging, thanks!
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-25 1:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-22 5:57 [PATCH v2] scsi: scsi_devinfo: remove redundant 'found' mrigendrachaubey
2025-06-23 15:59 ` Bart Van Assche
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
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).