From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Mark Brown <broonie@kernel.org>
Cc: Takashi Iwai <tiwai@suse.de>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ASoC: soc-dapm: Fix comparison of pointers
Date: Fri, 12 Dec 2014 14:43:27 +0100 [thread overview]
Message-ID: <87h9x10yrk.fsf@rasmusvillemoes.dk> (raw)
In-Reply-To: <20141212132109.GH11764@sirena.org.uk> (Mark Brown's message of "Fri, 12 Dec 2014 13:21:09 +0000")
On Fri, Dec 12 2014, Mark Brown <broonie@kernel.org> wrote:
> 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.
I'm not worrying about standards conformance. Casting pointers to and
from [unsigned] long is done everywhere in the kernel, and that's
fine. But subtracting ints or longs and using the sign of the result for
comparison is simply wrong. See acbbe6fbb2 (kcmp: fix standard
comparison bug) for the long story. In this case the narrowing (when
BITS_PER_LONG==64) of the result from long to int just makes it even
more wrong.
Rasmus
next prev parent reply other threads:[~2014-12-12 13:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-09 21:53 Rasmus Villemoes
2014-12-12 13:21 ` Mark Brown
2014-12-12 13:43 ` Rasmus Villemoes [this message]
2014-12-12 14:17 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h9x10yrk.fsf@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®