[Devel] [PATCH 05/10] max_netmask(): switch fits better

Kir Kolyshkin kir at parallels.com
Tue May 7 05:04:34 PDT 2013


On 05/06/2013 11:42 PM, Igor Podlesny wrote:
> ---
>   src/lib/util.c |   11 +++++------
>   1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/src/lib/util.c b/src/lib/util.c
> index 61ce5df..febb676 100644
> --- a/src/lib/util.c
> +++ b/src/lib/util.c
> @@ -383,12 +383,11 @@ int get_netaddr(const char *ip_str, void *ip)
>   
>   static inline int max_netmask(int family)
>   {
> -	if (family == AF_INET)
> -		return 32;
> -	else if (family == AF_INET6)
> -		return 128;
> -	else
> -		return -1;
> +	switch (family) {
> +	case AF_INET:	return 32;
> +	case AF_INET6:	return 128;
> +	default:	return -1;
> +	}

Please put a case statement on a separate line, like this:

case A:
         return 1;
case B:
         return 2;
,,,
>   }
>   
>   /* Check and "canonicalize" an IP address with optional netmask




More information about the Devel mailing list