Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: scsi_devinfo: Remove redundant 'found'

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>

authored by

mrigendrachaubey and committed by
Martin K. Petersen
26b971d5 6243146b

+3 -8
+3 -8
drivers/scsi/scsi_devinfo.c
··· 269 269 static struct scsi_dev_info_list_table *scsi_devinfo_lookup_by_key(int key) 270 270 { 271 271 struct scsi_dev_info_list_table *devinfo_table; 272 - int found = 0; 273 272 274 273 list_for_each_entry(devinfo_table, &scsi_dev_info_list, node) 275 - if (devinfo_table->key == key) { 276 - found = 1; 277 - break; 278 - } 279 - if (!found) 280 - return ERR_PTR(-EINVAL); 274 + if (devinfo_table->key == key) 275 + return devinfo_table; 281 276 282 - return devinfo_table; 277 + return ERR_PTR(-EINVAL); 283 278 } 284 279 285 280 /*