[PATCH] block: Remove unreachable code
Andrew Goodbody
andrew.goodbody at linaro.org
Mon Jul 14 17:38:53 CEST 2025
The two functions blk_find_first and blk_find_next use a for loop with
the content being a 'return 0' which means that the 'increment' code is
unreachable so remove it and also remove the variable ret which is
assigned to but its value is never used.
This issue found by Smatch.
Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
---
drivers/block/blk-uclass.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index f3ac8db9464..b38c21ffbe2 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -613,11 +613,8 @@ static int blk_flags_check(struct udevice *dev, enum blk_flag_t req_flags)
int blk_find_first(enum blk_flag_t flags, struct udevice **devp)
{
- int ret;
-
- for (ret = uclass_find_first_device(UCLASS_BLK, devp);
- *devp && !blk_flags_check(*devp, flags);
- ret = uclass_find_next_device(devp))
+ for (uclass_find_first_device(UCLASS_BLK, devp);
+ *devp && !blk_flags_check(*devp, flags);)
return 0;
return -ENODEV;
@@ -625,11 +622,8 @@ int blk_find_first(enum blk_flag_t flags, struct udevice **devp)
int blk_find_next(enum blk_flag_t flags, struct udevice **devp)
{
- int ret;
-
- for (ret = uclass_find_next_device(devp);
- *devp && !blk_flags_check(*devp, flags);
- ret = uclass_find_next_device(devp))
+ for (uclass_find_next_device(devp);
+ *devp && !blk_flags_check(*devp, flags);)
return 0;
return -ENODEV;
---
base-commit: 074e05952705972072f52128cf2e3ec2d8f35de6
change-id: 20250714-blk-uclass-34684c01f60c
Best regards,
--
Andrew Goodbody <andrew.goodbody at linaro.org>
More information about the U-Boot
mailing list