[PATCH 2/3] cmd: Allow building ufetch without CONFIG_BLK

Caleb Connolly caleb.connolly at linaro.org
Mon Dec 9 16:04:50 CET 2024



On 05/12/2024 19:35, J. Neuschäfer via B4 Relay wrote:
> From: "J. Neuschäfer" <j.ne at posteo.net>
> 
> The ufetch command is still quite useful on systems without block
> device support; remove the CONFIG_BLK dependency and make sure the code
> compiles/works with and without CONFIG_BLK.
> 
> Signed-off-by: J. Neuschäfer <j.ne at posteo.net>

Small nit below, but with that:

Reviewed-by: Caleb Connolly <caleb.connolly at linaro.org>
> ---
>  cmd/Kconfig  |  1 -
>  cmd/ufetch.c | 10 +++++++---
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 4936a70f3ef16ddb093ceafa12d011ca1b89e95c..547fd2a91f7883e2ae5982897ec93c4483d67852 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -178,7 +178,6 @@ config CMD_CPU
>  
>  config CMD_UFETCH
>  	bool "U-Boot fetch"
> -	depends on BLK
>  	help
>  	  Fetch utility for U-Boot (akin to neofetch). Prints information
>  	  about U-Boot and the board it is running on in a pleasing format.
> diff --git a/cmd/ufetch.c b/cmd/ufetch.c
> index 5f3ef847b268dc384271fc6774720e5fd2337157..7aed0b447bda104b837d37c6adcbb21b80237aba 100644
> --- a/cmd/ufetch.c
> +++ b/cmd/ufetch.c
> @@ -92,11 +92,9 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc,
>  	int num_lines = max((size_t)LAST_LINE + 1, ARRAY_SIZE(logo_lines));
>  	const char *model, *compatible;
>  	char *ipaddr;
> -	int n_cmds, n_cpus = 0, ret, compatlen;
> +	int n_cmds, n_cpus = 0, compatlen;
>  	size_t size;
>  	ofnode np;
> -	struct udevice *dev;
> -	struct blk_desc *desc;
>  	bool skip_ascii = false;
>  
>  	if (argc > 1 && strcmp(argv[1], "-n") == 0) {
> @@ -200,6 +198,11 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc,
>  			break;
>  		case STORAGE:
>  		default:
> +#ifdef CONFIG_BLK
> +			struct udevice *dev;

At least without the #ifdef, I see a warning "A label followed by a
declaration is a C23 extension". So to be on the safe side please put
this section in a block:

		default: {

...

		}

Kind regards,

> +			struct blk_desc *desc;
> +			int ret;
> +
>  			ret = uclass_find_device_by_seq(UCLASS_BLK, line - STORAGE, &dev);
>  			if (!ret && dev) {
>  				desc = dev_get_uclass_plat(dev);
> @@ -213,6 +216,7 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc,
>  			} else if (ret == -ENODEV && (skip_ascii || line > ARRAY_SIZE(logo_lines))) {
>  				break;
>  			}
> +#endif
>  			printf("\n");
>  		}
>  	}
> 

-- 
// Caleb (they/them)



More information about the U-Boot mailing list