lkml.org 
[lkml]   [2013]   [Jun]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH net-next v3 1/2] lib: vsprintf: add IPv4/v6 generic %p[Ii]S[pfs] format specifier
From
Date
On Fri, 2013-06-28 at 14:05 +0200, Daniel Borkmann wrote:
> In order to avoid making code that deals with printing both, IPv4 and
> IPv6 addresses, unnecessary complicated as for example ...

Thanks Daniel, seems sensible. Just trivial comments...

[]

> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
[]

Should any other include other than net/addrconf be needed?

> +char *ip6_addr_string_sa(char *buf, char *end, const struct sockaddr_in6 *sa,
> + struct printf_spec spec, const char *fmt)
> +{
[]
> + char fmt6[2] = { fmt[0], '6'};

This looks odd to me. why not use a bool compressed
flag and identify this before the isalpha loop and not
have fmt6 at all?

> + u8 off = 0;
> +
> + fmt++;
> + while (isalpha(*++fmt)) {
> + switch (*fmt) {
> + case 'p':
> + have_p = true;
> + break;
> + case 'f':
> + have_f = true;
> + break;
> + case 's':
> + have_s = true;
> + break;
> + case 'c':
> + have_c = true;
> + break;
> + }
> + }




\
 
 \ /
  Last update: 2013-06-28 19:21    [W:0.128 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site