From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
malat@debian.org, aneesh.kumar@linux.vnet.ibm.com
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/mm: fix always true/false warning in slice.c
Date: Thu, 2 Aug 2018 09:30:31 +0000 [thread overview]
Message-ID: <1f090f15-eda3-90b1-2aab-ac73d9abb550@c-s.fr> (raw)
In-Reply-To: <871scqwbbo.fsf@concordia.ellerman.id.au>
On 06/29/2018 02:55 AM, Michael Ellerman wrote:
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>
>> This patch fixes the following warnings (obtained with make W=1).
>>
>> arch/powerpc/mm/slice.c: In function 'slice_range_to_mask':
>> arch/powerpc/mm/slice.c:73:12: error: comparison is always true due to limited range of data type [-Werror=type-limits]
>> if (start < SLICE_LOW_TOP) {
>
> Presumably only on 32-bit ?
Sure
>
>> diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
>> index 9530c6db406a..17c57760e06c 100644
>> --- a/arch/powerpc/mm/slice.c
>> +++ b/arch/powerpc/mm/slice.c
>> @@ -79,7 +86,7 @@ static void slice_range_to_mask(unsigned long start, unsigned long len,
>> - (1u << GET_LOW_SLICE_INDEX(start));
>> }
>>
>> - if ((start + len) > SLICE_LOW_TOP) {
>> + if (!slice_addr_is_low(end)) {
>> unsigned long start_index = GET_HIGH_SLICE_INDEX(start);
>> unsigned long align_end = ALIGN(end, (1UL << SLICE_HIGH_SHIFT));
>> unsigned long count = GET_HIGH_SLICE_INDEX(align_end) - start_index;
>
> This worries me.
I'll change it in v2 to:
if (SLICE_NUM_HIGH && !slice_addr_is_low(end)) {
>
> By casting before the comparison in the helper you squash the compiler
> warning, but the code is still broken if (start + len) overflows.
>
> Presumably that "never happens", but it just seems fishy.
>
> The other similar check in that file does:
>
> if (SLICE_NUM_HIGH && ((start + len) > SLICE_LOW_TOP)) {
>
> Where SLICE_NUM_HIGH == 0 on 32-bit.
>
>
> Could we fix the less than comparisons with SLICE_LOW_TOP with something
> similar, eg:
>
> if (!SLICE_NUM_HIGH || start < SLICE_LOW_TOP) {
>
> ie. limit them to the 64-bit code?
That's not enough to make GCC happy:
arch/powerpc/mm/slice.c: In function ‘slice_range_to_mask’:
arch/powerpc/mm/slice.c:74:31: error: comparison is always true due to
limited range of data type [-Werror=type-limits]
if (!SLICE_NUM_HIGH || start < SLICE_LOW_TOP) {
Christophe
>
> cheers
>
prev parent reply other threads:[~2018-08-02 9:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-22 13:49 Christophe Leroy
2018-06-22 14:55 ` Mathieu Malaterre
2018-06-22 16:17 ` Christophe LEROY
2018-06-29 2:55 ` Michael Ellerman
2018-08-02 9:30 ` Christophe Leroy [this message]
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=1f090f15-eda3-90b1-2aab-ac73d9abb550@c-s.fr \
--to=christophe.leroy@c-s.fr \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=malat@debian.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
/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®