From: Michael Ellerman <mpe@ellerman•id.au>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux•vnet.ibm.com>,
benh@kernel•crashing.org, paulus@samba•org
Cc: linuxppc-dev@lists•ozlabs.org,
"Aneesh Kumar K.V" <aneesh.kumar@linux•vnet.ibm.com>
Subject: Re: powerpc: Fix _ALIGN_* errors due to type difference.
Date: Tue, 6 Oct 2015 20:48:43 +1100 (AEDT) [thread overview]
Message-ID: <20151006094843.C8ECF140D71@ozlabs.org> (raw)
In-Reply-To: <1443796428-11517-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
On Fri, 2015-02-10 at 14:33:48 UTC, "Aneesh Kumar K.V" wrote:
> This avoid errors like
>
> unsigned int usize = 1 << 30;
> int size = 1 << 30;
> unsigned long addr = 64UL << 30 ;
>
> value = _ALIGN_DOWN(addr, usize); -> 0
> value = _ALIGN_DOWN(addr, size); -> 0x1000000000
Are you actually seeing that anywhere? I assume not.
> diff --git a/arch/powerpc/boot/page.h b/arch/powerpc/boot/page.h
> index 14eca30fef64..87c42d7d283d 100644
> --- a/arch/powerpc/boot/page.h
> +++ b/arch/powerpc/boot/page.h
> @@ -22,8 +22,8 @@
> #define PAGE_MASK (~(PAGE_SIZE-1))
>
> /* align addr on a size boundary - adjust address up/down if needed */
> -#define _ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1)))
> -#define _ALIGN_DOWN(addr,size) ((addr)&(~((size)-1)))
> +#define _ALIGN_UP(addr, size) (((addr)+((size)-1))&(~((typeof(addr))(size)-1)))
> +#define _ALIGN_DOWN(addr, size) ((addr)&(~((typeof(addr))(size)-1)))
>
> /* align addr on a size boundary - adjust address up if needed */
> #define _ALIGN(addr,size) _ALIGN_UP(addr,size)
> diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
> index 71294a6e976e..1dd69774a31c 100644
> --- a/arch/powerpc/include/asm/page.h
> +++ b/arch/powerpc/include/asm/page.h
> @@ -240,8 +240,8 @@ extern long long virt_phys_offset;
> #endif
>
> /* align addr on a size boundary - adjust address up/down if needed */
> -#define _ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1)))
> -#define _ALIGN_DOWN(addr,size) ((addr)&(~((size)-1)))
> +#define _ALIGN_UP(addr, size) (((addr)+((size)-1))&(~((typeof(addr))(size)-1)))
> +#define _ALIGN_DOWN(addr, size) ((addr)&(~((typeof(addr))(size)-1)))
It looks like ALIGN() in kernel.h already does this right, so can we just use
that instead for _ALIGN_UP() at least.
cheers
next prev parent reply other threads:[~2015-10-06 9:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-02 14:33 [PATCH] powerpc: Fix _ALIGN_* errors due to type difference Aneesh Kumar K.V
2015-10-06 9:48 ` Michael Ellerman [this message]
2015-10-07 8:46 ` Aneesh Kumar K.V
2015-10-07 9:16 ` Michael Ellerman
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=20151006094843.C8ECF140D71@ozlabs.org \
--to=mpe@ellerman$(echo .)id.au \
--cc=aneesh.kumar@linux$(echo .)vnet.ibm.com \
--cc=benh@kernel$(echo .)crashing.org \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=paulus@samba$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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