[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20170222074354.GA19012@infradead.org>
Date: Tue, 21 Feb 2017 23:43:54 -0800
From: Christoph Hellwig <hch@...radead.org>
To: Sagi Grimberg <sagi@...mberg.me>
Cc: Christoph Hellwig <hch@...radead.org>,
linux-nvme@...ts.infradead.org, linux-rdma@...r.kernel.org,
target-devel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH rfc 1/4] net/utils: generic inet_pton_with_scope helper
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;
}
Powered by blists - more mailing lists