Re: [announce] new tree: "fix all build warnings, on all configs"

Ingo Molnar
2008-10-18T08:23:16Z

* Roland Dreier <rdreier@cisco.com> wrote:

> > i certainly have a found a couple of such cases, see tip/warnings/ugly -
> > for example see the one below where gcc is not able to see through type
> > width.
>
> Yes, the uninitialized variable warnings are obnoxious too. By the way,
> I think this:
>
> @@ -72,7 +72,7 @@ static __always_inline void *__constant_memcpy(void *to, const void *from,
> return to;
> case 5:
> *(int *)to = *(int *)from;
> - *((char *)to + 4) = *((char *)from + 4);
> + *((short *)to + 3) = *((short *)from + 3);
> return to;
> case 6:
> *(int *)to = *(int *)from;
>
> is actually *wrong*, because the cast operator binds tighter than
> addition -- so
>
> + *((short *)to + 3) = *((short *)from + 3);
>
> actually copies bytes at offset 6 and 7; I think what you intended was:
>
> + *((short *)(to + 3)) = *((short *)(from + 3));

thx, you are right - fixed it via the patch below.

> which illustrates the risks in fixing warnings.

yeah. Note that this was not a routine case at all, i did the commit in
the early stages when i didnt even know how much effort it all would be
to keep the whole kernel warning-free, in all configs. It looked odd and
ugly and was in tip/warnings/ugly rightfully.

It would be nice if you could find an outright incorrect change in
tip/warnings/simple. The ones flagged 'simple' are the ones that have
the highest risk of not being reviewed much beyond their initial
addition.

Ingo

--------------->
>From 9d8f9578ca252bf26474ed77fde7ea30e9dee595 Mon Sep 17 00:00:00 2001
From: Ingo Molnar <mingo@elte.hu>
Date: Sat, 18 Oct 2008 10:17:36 +0200
Subject: [PATCH] hack, workaround for warning drivers/acpi/tables/tbfadt.c, fix

Fix commit fbf03326a16b29f8d34a5a3883a267bac4d38fc2, pointed
out by Roland Dreier.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
include/asm-x86/string_32.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/asm-x86/string_32.h b/include/asm-x86/string_32.h
index 419ab10..be82619 100644
--- a/include/asm-x86/string_32.h
+++ b/include/asm-x86/string_32.h
@@ -72,7 +72,7 @@ static __always_inline void *__constant_memcpy(void *to, const void *from,
return to;
case 5:
*(int *)to = *(int *)from;
- *((short *)to + 3) = *((short *)from + 3);
+ *((char *)(to + 3)) = *((char *)(from + 3));
return to;
case 6:
*(int *)to = *(int *)from;