[PATCH app/xdm] Add missing brackets to multi-statement if in SaveServerAuthorizations

Matthieu Herrb matthieu at herrb.eu
Sun May 6 06:03:18 UTC 2018


On Sat, May 05, 2018 at 12:33:12PM -0700, Alan Coopersmith wrote:
> Introduced by commit 5222d28e8d8e5b4cc
> 
> Reported by gcc 7.3:
> 
> auth.c: In function ‘SaveServerAuthorizations’:
> auth.c:447:6: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
>       if (auths[i]->data_length > 0)
>       ^~
> auth.c:452:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
>    (void) fflush (auth_file);
>    ^
> 
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

Reviewed-by: Matthieu Herrb <matthieu at herrb.eu>

> ---
>  xdm/auth.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/xdm/auth.c b/xdm/auth.c
> index 068a643..1e5d8e9 100644
> --- a/xdm/auth.c
> +++ b/xdm/auth.c
> @@ -442,21 +442,22 @@ SaveServerAuthorizations (
>  	    /*
>  	     * User-based auths may not have data until
>  	     * a user logs in.  In which case don't write
>  	     * to the auth file so xrdb and setup programs don't fail.
>  	     */
> -	    if (auths[i]->data_length > 0)
> +	    if (auths[i]->data_length > 0) {
>  		if (!XauWriteAuth (auth_file, auths[i]))
>  		{
>  		    Debug ("XauWriteAuth() failed\n");
>  		}
>  		(void) fflush (auth_file);
>  		if (ferror (auth_file))
>  		{
>  		    err = errno;
>  		    ret = FALSE;
>  		}
> +            }
>  	}
>  	/*
>  	 * XXX: This is not elegant, but stdio has no truncation function.
>  	 */
>  	if (ftruncate(fileno(auth_file), ftell(auth_file)))
> -- 
> 2.15.0
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel

-- 
Matthieu Herrb
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 793 bytes
Desc: not available
URL: <https://lists.x.org/archives/xorg-devel/attachments/20180506/dd01d5ca/attachment.sig>


More information about the xorg-devel mailing list