Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 May 2012 16:48:08 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Guy Helmer <ghelmer@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r235739 - head/lib/libc/gen
Message-ID:  <20120522163814.T1056@besplex.bde.org>
In-Reply-To: <201205212104.q4LL4UDN072617@svn.freebsd.org>
References:  <201205212104.q4LL4UDN072617@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 21 May 2012, Guy Helmer wrote:

> Log:
>  Apply style(9) to return and switch/case statements.
>
>  Reviewed by:	delphij (prior version of the patch)
>
> Modified:
>  head/lib/libc/gen/getnetgrent.c
>
> Modified: head/lib/libc/gen/getnetgrent.c
> ==============================================================================
> --- head/lib/libc/gen/getnetgrent.c	Mon May 21 19:58:40 2012	(r235738)
> +++ head/lib/libc/gen/getnetgrent.c	Mon May 21 21:04:29 2012	(r235739)
> ...
> @@ -311,32 +311,35 @@ _revnetgr_lookup(char* lookupdom, char*
>
> 	for (rot = 0; ; rot++) {
> 		switch (rot) {
> -			case(0): snprintf(key, MAXHOSTNAMELEN, "%s.%s",
> -					  str, dom?dom:lookupdom);
> -				 break;
> -			case(1): snprintf(key, MAXHOSTNAMELEN, "%s.*",
> -					  str);
> -				 break;
> -			case(2): snprintf(key, MAXHOSTNAMELEN, "*.%s",
> -					  dom?dom:lookupdom);
> -				 break;
> -			case(3): snprintf(key, MAXHOSTNAMELEN, "*.*");
> -				 break;
> -			default: return(0);
> +		case(0):
> +			snprintf(key, MAXHOSTNAMELEN, "%s.%s", str,
> +			    dom ? dom : lookupdom);
> +			break;
> +		case(1):
> +			snprintf(key, MAXHOSTNAMELEN, "%s.*", str);
> +			break;
> +		case(2):
> +			snprintf(key, MAXHOSTNAMELEN, "*.%s",
> +			    dom ? dom : lookupdom);
> +			break;
> +		case(3):
> +			snprintf(key, MAXHOSTNAMELEN, "*.*");
> +			break;

Thanks, but a fuller application would have removed the obfuscatory
parentheses that make case() look like a function call...

> +		default: return (0);

... and split the case statements after ":" in all cases.

> 		}
> 		y = yp_match(lookupdom, map, key, strlen(key), &result,
> 			     &resultlen);

You fixed the continuation indentation in the case statement but not here.

> 		if (y == 0) {
> 			rv = _listmatch(result, group, resultlen);
> 			free(result);
> -			if (rv) return(1);
> +			if (rv) return (1);

Another statement not started on a new line.

> 		} else if (y != YPERR_KEY) {
> 			/*
> 			 * If we get an error other than 'no
> 			 * such key in map' then something is
> 			 * wrong and we should stop the search.
> 			 */
> -			return(-1);
> +			return (-1);
> 		}
> 	}
> }

These style bugs weren't in the CSRG version of course.  The YP code added
many.  The most obvious ones are the case(n) and gnu-style continuation
indentation.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120522163814.T1056>