Re: [Patch] kbuild: fix a compile warning

From: Luming Yu
Date: Thu May 28 2009 - 09:18:25 EST


On Fri, May 15, 2009 at 3:51 PM, Amerigo Wang <amwang@xxxxxxxxxx> wrote:
>
> I got this warning:
>
> ÂHOSTCC Âscripts/basic/fixdep
> scripts/basic/fixdep.c: In function 'traps':
> scripts/basic/fixdep.c:377: warning: dereferencing type-punned pointer will break strict-aliasing rules
> scripts/basic/fixdep.c:379: warning: dereferencing type-punned pointer will break strict-aliasing rules


these warnings can be supressed by adding a compile option -fno-strict-aliasing


>
> Patch below fixes it.
>
> Signed-off-by: WANG Cong <amwang@xxxxxxxxxx>
> Cc: Sam Ravnborg <sam@xxxxxxxxxxxx>
>
> ---
> diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
> index 8912c0f..72c1520 100644
> --- a/scripts/basic/fixdep.c
> +++ b/scripts/basic/fixdep.c
> @@ -373,10 +373,11 @@ void print_deps(void)
> Âvoid traps(void)
> Â{
> Â Â Â Âstatic char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
> + Â Â Â int *p = (int *)test;
>
> - Â Â Â if (*(int *)test != INT_CONF) {
> + Â Â Â if (*p != INT_CONF) {
> Â Â Â Â Â Â Â Âfprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
> - Â Â Â Â Â Â Â Â Â Â Â *(int *)test);
> + Â Â Â Â Â Â Â Â Â Â Â *p);
> Â Â Â Â Â Â Â Âexit(2);
> Â Â Â Â}
> Â}
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
> Please read the FAQ at Âhttp://www.tux.org/lkml/
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/