]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: scsi_devinfo: Remove redundant 'found'
authormrigendrachaubey <mrigendra.chaubey@gmail.com>
Sun, 22 Jun 2025 05:57:09 +0000 (11:27 +0530)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 25 Jun 2025 01:17:22 +0000 (21:17 -0400)
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>
Link: https://lore.kernel.org/r/20250622055709.7893-1-mrigendra.chaubey@gmail.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_devinfo.c

index 8ff679e67bbfc909145403a6176c5b4fc26247d8..78346b2b69c91c36d5fda5ccbd2a68cb9b5eaa1d 100644 (file)
@@ -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);
 }
 
 /*