[alsa-devel] [PATCH] ASoC: soc-dapm: Fix comparison of pointers

Mark Brown broonie at kernel.org
Fri Dec 12 14:21:09 CET 2014


On Tue, Dec 09, 2014 at 10:53:41PM +0100, Rasmus Villemoes wrote:

>  	if (a->reg != b->reg)
>  		return a->reg - b->reg;
> -	if (a->dapm != b->dapm)
> -		return (unsigned long)a->dapm - (unsigned long)b->dapm;
> +	if (a->dapm < b->dapm)
> +		return -1;
> +	if (a->dapm > b->dapm)
> +		return 1;

If we're worrying about standards conformance type stuff here this is
also buggy since it's out of spec to compare pointers that are not part
of the same array like this.  Casting to uintptr_t is a better fix here.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20141212/641308a3/attachment.sig>


More information about the Alsa-devel mailing list