diff mbox series

[4/5] lib/vsprintf.c: remove unused ip6_addr_string()

Message ID 20210520100528.322846-5-rasmus.villemoes@prevas.dk
State Superseded
Delegated to: Tom Rini
Headers show
Series assorted printf-related patches | expand

Commit Message

Rasmus Villemoes May 20, 2021, 10:05 a.m. UTC
There's currently no user of %p[iI]6, so including ip6_addr_string()
in the image is a waste of bytes. It's easy enough to have the
compiler elide it without removing the code completely.

The closest I can find to anybody "handling" ipv6 in U-Boot currently
is in efi_net.c which does

        if (ipv6) {
                ret = EFI_UNSUPPORTED;

As indicated in the comment, it can easily be put back, but preferably
under a config knob.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 lib/vsprintf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Simon Glass May 20, 2021, 5:51 p.m. UTC | #1
On Thu, 20 May 2021 at 04:05, Rasmus Villemoes
<rasmus.villemoes@prevas.dk> wrote:
>
> There's currently no user of %p[iI]6, so including ip6_addr_string()
> in the image is a waste of bytes. It's easy enough to have the
> compiler elide it without removing the code completely.
>
> The closest I can find to anybody "handling" ipv6 in U-Boot currently
> is in efi_net.c which does
>
>         if (ipv6) {
>                 ret = EFI_UNSUPPORTED;
>
> As indicated in the comment, it can easily be put back, but preferably
> under a config knob.
>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---
>  lib/vsprintf.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Heinrich Schuchardt May 21, 2021, 2:32 p.m. UTC | #2
On 20.05.21 12:05, Rasmus Villemoes wrote:
> There's currently no user of %p[iI]6, so including ip6_addr_string()
> in the image is a waste of bytes. It's easy enough to have the
> compiler elide it without removing the code completely.
>
> The closest I can find to anybody "handling" ipv6 in U-Boot currently
> is in efi_net.c which does
>
>         if (ipv6) {
>                 ret = EFI_UNSUPPORTED;
>
> As indicated in the comment, it can easily be put back, but preferably
> under a config knob.
>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---
>  lib/vsprintf.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 65d985982d..6742b0985a 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -434,6 +434,9 @@ static char *uuid_string(char *buf, char *end, u8 *addr, int field_width,
>   * - 'i' [46] for 'raw' IPv4/IPv6 addresses, IPv6 omits the colons, IPv4 is
>   *       currently the same
>   *
> + * Note: IPv6 support is currently if(0)'ed out. If you ever need
> + * %pI6, please add an IPV6 Kconfig knob, make your code select or
> + * depend on that, and change the 0 below to CONFIG_IS_ENABLED(IPV6).
>   */
>  static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
>  		int field_width, int precision, int flags)
> @@ -478,7 +481,7 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
>  		flags |= SPECIAL;
>  		/* Fallthrough */
>  	case 'I':
> -		if (fmt[1] == '6')

Please, provide a commment like "%pI6 currently unused" here.

Best regards

Heinrich

> +		if (0 && fmt[1] == '6')
>  			return ip6_addr_string(buf, end, ptr, field_width,
>  					       precision, flags);
>  		if (fmt[1] == '4')
>
diff mbox series

Patch

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 65d985982d..6742b0985a 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -434,6 +434,9 @@  static char *uuid_string(char *buf, char *end, u8 *addr, int field_width,
  * - 'i' [46] for 'raw' IPv4/IPv6 addresses, IPv6 omits the colons, IPv4 is
  *       currently the same
  *
+ * Note: IPv6 support is currently if(0)'ed out. If you ever need
+ * %pI6, please add an IPV6 Kconfig knob, make your code select or
+ * depend on that, and change the 0 below to CONFIG_IS_ENABLED(IPV6).
  */
 static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
 		int field_width, int precision, int flags)
@@ -478,7 +481,7 @@  static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
 		flags |= SPECIAL;
 		/* Fallthrough */
 	case 'I':
-		if (fmt[1] == '6')
+		if (0 && fmt[1] == '6')
 			return ip6_addr_string(buf, end, ptr, field_width,
 					       precision, flags);
 		if (fmt[1] == '4')