cmd: ufetch: print Net feature when NET_LWIP=y, prettyfy if NET=n
v2 cover cmd: ufetch: print Net feature when NET_LWIP=y, prettyfy if NET=n
Make sure the Net feature is printed when NET_LWIP is enabled, not only when NET_LEGACY is.
Only print comma and following whitespace as separator if there was a feature printed before feature to be printed.
---
Changes in v2:
- added R-b trailers,
- fixed spurious colon character before separator in cat,
- Link to v1: https://patch.msgid.link/[email protected]
---
Quentin Schulz (2):
cmd: ufetch: show net feature when NET_LWIP is selected
cmd: ufetch: only show comma separator if there was a previous feature
cmd/ufetch.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
---
base-commit: bb0f3eebb3c196d9b6efbbd1e5aa9b16abbb9ad6
change-id: 20260428-ufetch-net-1ba7553a20c7
Best regards,
Signature · 1 line
Quentin Schulz <[email protected]>
PATCH v2 1/2 cmd: ufetch: show net feature when NET_LWIP is selected
From: Quentin Schulz <[email protected]>
We've had a new lwIP networking stack for a couple of years already, so let's show there is a "net" feature if it's selected. Since NET_LEGACY || NET_LWIP is the same as NET, let's check on NET.
--- cmd/ufetch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/ufetch.c +1 -1
@@ -159,7 +159,7 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc,break ;case FEATURES :printf ("Features:" RESET " " ); -if (IS_ENABLED (CONFIG_NET_LEGACY )) +if (IS_ENABLED (CONFIG_NET ))printf ("Net" );if (IS_ENABLED (CONFIG_EFI_LOADER ))printf (", EFI" );
Signature · 1 line
2.54.0
PATCH v2 2/2 cmd: ufetch: only show comma separator if there was a previous feature
In reply to Quentin SchulzFrom: Quentin Schulz <[email protected]>
Currently, if NET is disabled, the next feature to be printed will start with a comma and a space which is not pretty. Add the comma and whitespace only when a previous feature has already been shown.
--- cmd/ufetch.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
cmd/ufetch.c +20 -9
@@ -157,26 +157,37 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc,printf (" (%d baud)" , gd->baudrate);putc ('\n' );break ; -case FEATURES : +case FEATURES : { +bool sep = false; +printf ("Features:" RESET " " ); -if (IS_ENABLED (CONFIG_NET )) -printf ("Net" ); -if (IS_ENABLED (CONFIG_EFI_LOADER )) -printf (", EFI" ); -if (IS_ENABLED (CONFIG_CMD_CAT )) -printf (", cat :3" ); +if (IS_ENABLED (CONFIG_NET )) { +printf ("%sNet" , sep ?", " :"" ); + sep = true; + } +if (IS_ENABLED (CONFIG_EFI_LOADER )) { +printf ("%sEFI" , sep ?", " :"" ); + sep = true; + } +if (IS_ENABLED (CONFIG_CMD_CAT )) { +printf ("%scat :3" , sep ?", " :"" ); + sep = true; + }#ifdef CONFIG_ARM64 switch (current_el ()) {case 2 : -printf (", VMs" ); +printf ("%sVMs" , sep ?", " :"" ); + sep = true;break ;case 3 : -printf (", full control!" ); +printf ("%sfull control!" , sep ?", " :"" ); + sep = true;break ; }#endif printf ("\n" );break ; + }case RELOCATION :if (gd->flags &GD_FLG_SKIP_RELOC )printf ("Relocated:" RESET " no\n" );
Signature · 1 line
2.54.0
Re: [PATCH v2 2/2] cmd: ufetch: only show comma separator if there was a previous feature
Hi Quentin,
Quoted 26 lines · Quentin Schulz
cmd: ufetch: only show comma separator if there was a previous feature
Currently, if NET is disabled, the next feature to be printed will start with a comma and a space which is not pretty. Add the comma and whitespace only when a previous feature has already been shown.
Signed-off-by Quentin Schulz <[email protected]>
cmd/ufetch.c| 29 ++++++++++++++++++++---------1 file changed, 20 insertions(+), 9 deletions(-)cmd/ufetch.c +5
-7@@ -157,26 +157,37 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc, -case FEATURES : +case FEATURES : { +bool sep = false; + printf('Features:' RESET " "); -if (IS_ENABLED (CONFIG_NET )) -printf ('Net' ); -if (IS_ENABLED (CONFIG_EFI_LOADER )) -printf (", EFI" ); -if (IS_ENABLED (CONFIG_CMD_CAT )) -printf (", cat :3" ); +if (IS_ENABLED (CONFIG_NET )) { +printf ('%sNet' , sep ?", " :"" );
cmd/ufetch.c static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc, · line 172
Quoted 10 lines
cmd/ufetch.c +10
-0+ sep = true; + } +if (IS_ENABLED (CONFIG_EFI_LOADER )) { +printf ('%sEFI' , sep ?", " :"" ); + sep = true; + } +if (IS_ENABLED (CONFIG_CMD_CAT )) { +printf ("%scat :3" , sep ?", " :"" ); + sep = true; + }
Sorry, one more thought: you couldkeep the separator as a string that starts empty and becomes ", " after the first print:
const char *sep = "";
if (IS_ENABLED(CONFIG_NET)) {
printf('%sNet', sep);
sep = ", ";
}Quoted 6 lines
cmd/ufetch.c +0
-1@@ -157,26 +157,37 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc,#ifdef CONFIG_ARM64 switch (current_el ()) {case 2 : -printf (", VMs" );
cmd/ufetch.c static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc, · line 168
Quoted 10 lines
cmd/ufetch.c +4
-1+printf ('%sVMs' , sep ?", " :"" ); + sep = true;break ;case 3 : -printf (", full control!" ); +printf ("%sfull control!" , sep ?", " :"" ); + sep = true; break; }#endif
nit: the sep = true is dead since nothing follows the switch.
Regards,
Simon