[PATCH] Remove incorrect & in swap_uint32

Thomas Dickey dickey at his.com
Wed Sep 28 14:30:27 PDT 2011


On Wed, 28 Sep 2011, Matt Turner wrote:

> Caused by commit 893e86a4, and hidden by the (char *) cast.

That's an example of why just adding casts is not always a good idea.

Another way to do this would be to provide a local variable with
the "right" type (and generally at no cost, due to optimization).

> Signed-off-by: Matt Turner <mattst88 at gmail.com>
> ---
> include/misc.h |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/include/misc.h b/include/misc.h
> index 1fea73e..180b3c1 100644
> --- a/include/misc.h
> +++ b/include/misc.h
> @@ -277,7 +277,7 @@ static inline void __builtin_constant_p(int x)
> /* byte swap a 32-bit value */
> static inline void swap_uint32(uint32_t *x)
> {
> -	char n = ((char *) &x)[0];
> +	char n = ((char *) x)[0];
> 	((char *) x)[0] = ((char *) x)[3];
> 	((char *) x)[3] = n;
> 	n = ((char *) x)[1];
> -- 
> 1.7.3.4

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net


More information about the xorg-devel mailing list