Subject: Re: [Patch net-next 0/7] net: introduce generic type and helpers for IP address

From: Cong Wang <[email-masked]>
Date: Tue, 23 Jul 2013 10:26:37 +0800

On Mon, 2013-07-22 at 19:16 -0700, Joe Perches wrote:
> On Tue, 2013-07-23 at 10:00 +0800, Cong Wang wrote:
> > On Mon, 2013-07-22 at 13:44 -0700, Joe Perches wrote:
> > > 
> > > I see no reason why vsprint's support for
> > > "struct sockaddr *" %pIS should be removed.
> > > 
> > > %pIS and %pIA can both exist.
> 
> > Because there is no need to keep both of them, struct sockaddr can be
> > safely converted to union inet_addr.
> 
> That's a bit fragile.
> The cost of keeping %pIS is pretty low.

I knew, but again, there is no need at all.

> 
> Also, if there is ever a check for %p<type>,
> then using:
> 
> 	struct sockaddr *foo = bar;
> 	...
> 	snprintf(buf, len, "%pIA", foo)
> 
> would need foo to be cast first to union inet_addr *
> 
> 	snprintf(buf, len, "%pIA", (union inet_addr *)foo);
> 
> 

You don't have to, compiler doesn't check the new specifier, and it is
safe even without any casting.

What's more, the existing %pIS user (sctp) is already converted to union
inet_addr, see patch 6/7.