Re: [PATCH rfc 1/4] net/utils: generic inet_pton_with_scope helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
	}
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux