Subject: Re: [PATCH 1/4] printk: add %I4, %I6, %i4, %i6 format specifiers

From: Joe Perches <[email-masked]>
Date: Thu, 30 Oct 2008 13:28:58 -0700

On Wed, 2008-10-29 at 11:35 -0700, Harvey Harrison wrote:
> For use in printing IPv4, or IPv6 addresses in the usual way:
> Signed-off-by: Harvey Harrison <[email-masked]>
> ---
>  lib/vsprintf.c |   31 +++++++++++++++++++++++++++++++
>  1 files changed, 31 insertions(+), 0 deletions(-)
> 
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index cb5bc04..a863006 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
[]
> @@ -650,6 +671,16 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field
>  		return mac_address_string(buf, end, ptr, field_width, precision, flags);
>  	case '6':
>  		return ip6_addr_string(buf, end, ptr, field_width, precision, flags);
> +	case 'i':
> +		flags |= SPECIAL;
> +		/* Fallthrough */
> +	case 'I':
> +		if (fmt[1] == '6')
> +			return ip6_addr_string(buf, end, ptr, field_width, precision, flags);
> +		if (fmt[1] == '4')
> +			return ip4_addr_string(buf, end, ptr, field_width, precision, flags);
> +		flags &= ~SPECIAL;
> +		break;
>  	}
>  	flags |= SMALL;
>  	if (field_width == -1) {

Hi Harvey.

I was thinking about extending %p<foo> to support
struct task_struct * and noticed this code isn't
really correct.

SPECIAL should be cleared from flags only when *fmt
is 'i' not 'I' and SPECIAL wasn't previously set.

cheers, Joe