[PATCH rfc 1/4] net/utils: generic inet_pton_with_scope helper
Christoph Hellwig
hch at infradead.org
Tue Feb 21 23:43:54 PST 2017
On Tue, Feb 21, 2017 at 11:18:04PM +0200, Sagi Grimberg wrote:
> I can maybe do something like:
>
> if (af == AF_INET || af == AF_UNSPEC) {
> ret = inet4_pton();
> if (!ret)
> return 0;
> else if (af != AF_UNSPEC)
> return ret;
> }
>
> if (af == AF_INET6 || af == AF_UNSPEC) {
> ret = inet6_pton();
> if (!ret)
> return 0;
> else if (af != AF_UNSPEC)
> return ret;
> }
>
> return -EINVAL;
>
> better?
My idead was the following:
switch (af) {
case AF_INET:
ret = inet_pton();
break;
case AF_INET6:
ret = inet6_pton();
break;
case AF_UNSPEC:
ret = inet6_pton();
if (ret)
ret = inet_pton();
break;
}
More information about the Linux-nvme
mailing list