[PATCH] block: Remove unreachable code
Tom Rini
trini at konsulko.com
Mon Jul 14 18:29:51 CEST 2025
On Mon, Jul 14, 2025 at 04:38:53PM +0100, Andrew Goodbody wrote:
> 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;
Should we clean up uclass_find_next_device(...) to not return int? The
function comments don't quite make sense (include/dm/uclass-internal.h)
and it always returns 0.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20250714/461db618/attachment.sig>
More information about the U-Boot
mailing list