[PATCH:xts 11/16] xts5: Add parentheses around assignment in an if.

walter harms wharms at bfs.de
Thu May 26 02:49:58 PDT 2011



Am 25.05.2011 13:00, schrieb Cyril Brulebois:
> Tell compilers we really meant to assign and then check.
> 
> The following warning goes away accordingly:
> |   CC     nextvclass.lo
> | nextvclass.c:224:14: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
> |                         if (comma = strchr(++s, COMMA))
> |                             ~~~~~~^~~~~~~~~~~~~~~~~~~~
> | nextvclass.c:224:14: note: use '==' to turn this assignment into an equality comparison
> |                         if (comma = strchr(++s, COMMA))
> |                                   ^
> |                                   ==
> | nextvclass.c:224:14: note: place parentheses around the assignment to silence this warning
> |                         if (comma = strchr(++s, COMMA))
> |                                   ^
> |                             (                         )
> 
> Signed-off-by: Cyril Brulebois <kibi at debian.org>
> ---
>  xts5/src/lib/nextvclass.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/xts5/src/lib/nextvclass.c b/xts5/src/lib/nextvclass.c
> index 13b7f6c..7a6a5f2 100644
> --- a/xts5/src/lib/nextvclass.c
> +++ b/xts5/src/lib/nextvclass.c
> @@ -221,7 +221,7 @@ int	Lclass;
>  		}
>  		Lclass = Nclass;
>  		for (s = left_bracket; s; s = comma) {

Just to improve readabiliy:
			comma = strchr(++s, COMMA);
			if ( comma )
				*comma = '\0';		

> -			if (comma = strchr(++s, COMMA))
> +			if ((comma = strchr(++s, COMMA)))
>  				*comma = '\0';
>  			if (*s == '\0')
>  				break;


More information about the xorg-devel mailing list