* [PATCH 2.4.31 9/9] gcc4: fix i386 struct_cpy() warnings
@ 2005-06-12 11:22 Mikael Pettersson
2005-06-12 16:43 ` Denis Vlasenko
0 siblings, 1 reply; 3+ messages in thread
From: Mikael Pettersson @ 2005-06-12 11:22 UTC (permalink / raw)
To: marcelo.tosatti; +Cc: linux-kernel
On i386 gcc4 generates a few compile-time warnings like:
process.c:556: warning: statement with no effect
process.c:569: warning: statement with no effect
This is because the i386 struct_cpy() macro references an
undefined variable when its two operands differ in size,
in the hope of turning a runtime error into a link-time error.
However, a simple variable reference has no effect, which
is why gcc4 complains.
The fix is to change it to a call to an undefined function.
Signed-off-by: Mikael Pettersson <mikpe@csd.uu.se>
include/asm-i386/string.h | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
diff -rupN linux-2.4.31/include/asm-i386/string.h linux-2.4.31.gcc4-i386-struct_cpy-warnings/include/asm-i386/string.h
--- linux-2.4.31/include/asm-i386/string.h 2001-08-12 11:35:53.000000000 +0200
+++ linux-2.4.31.gcc4-i386-struct_cpy-warnings/include/asm-i386/string.h 2005-06-12 11:52:25.000000000 +0200
@@ -337,7 +337,7 @@ extern void __struct_cpy_bug (void);
#define struct_cpy(x,y) \
({ \
if (sizeof(*(x)) != sizeof(*(y))) \
- __struct_cpy_bug; \
+ __struct_cpy_bug(); \
memcpy(x, y, sizeof(*(x))); \
})
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2.4.31 9/9] gcc4: fix i386 struct_cpy() warnings
2005-06-12 11:22 [PATCH 2.4.31 9/9] gcc4: fix i386 struct_cpy() warnings Mikael Pettersson
@ 2005-06-12 16:43 ` Denis Vlasenko
0 siblings, 0 replies; 3+ messages in thread
From: Denis Vlasenko @ 2005-06-12 16:43 UTC (permalink / raw)
To: Mikael Pettersson, marcelo.tosatti; +Cc: linux-kernel
On Sunday 12 June 2005 14:22, Mikael Pettersson wrote:
> On i386 gcc4 generates a few compile-time warnings like:
>
> process.c:556: warning: statement with no effect
> process.c:569: warning: statement with no effect
>
> This is because the i386 struct_cpy() macro references an
> undefined variable when its two operands differ in size,
> in the hope of turning a runtime error into a link-time error.
>
> However, a simple variable reference has no effect, which
> is why gcc4 complains.
>
> The fix is to change it to a call to an undefined function.
>
> Signed-off-by: Mikael Pettersson <mikpe@csd.uu.se>
>
> include/asm-i386/string.h | 2 +-
> 1 files changed, 1 insertion(+), 1 deletion(-)
>
> diff -rupN linux-2.4.31/include/asm-i386/string.h linux-2.4.31.gcc4-i386-struct_cpy-warnings/include/asm-i386/string.h
> --- linux-2.4.31/include/asm-i386/string.h 2001-08-12 11:35:53.000000000 +0200
> +++ linux-2.4.31.gcc4-i386-struct_cpy-warnings/include/asm-i386/string.h 2005-06-12 11:52:25.000000000 +0200
> @@ -337,7 +337,7 @@ extern void __struct_cpy_bug (void);
> #define struct_cpy(x,y) \
> ({ \
> if (sizeof(*(x)) != sizeof(*(y))) \
> - __struct_cpy_bug; \
> + __struct_cpy_bug(); \
> memcpy(x, y, sizeof(*(x))); \
> })
1) Don't you need a void __struct_cpy_bug(void) declaration before this
(as a matter of style, not correctness)?
2) Why __ ? It is not compiler- or library-special, why not
BUG_struct_cpy_different_sizes() or something like this?
--
vda
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2.4.31 9/9] gcc4: fix i386 struct_cpy() warnings
@ 2005-06-12 17:03 Mikael Pettersson
0 siblings, 0 replies; 3+ messages in thread
From: Mikael Pettersson @ 2005-06-12 17:03 UTC (permalink / raw)
To: vda; +Cc: linux-kernel, marcelo.tosatti
On Sun, 12 Jun 2005 19:43:03 +0300, Denis Vlasenko wrote:
> > diff -rupN linux-2.4.31/include/asm-i386/string.h linux-2.4.31.gcc4-i386-struct_cpy-warnings/include/asm-i386/string.h
> > --- linux-2.4.31/include/asm-i386/string.h 2001-08-12 11:35:53.000000000 +0200
> > +++ linux-2.4.31.gcc4-i386-struct_cpy-warnings/include/asm-i386/string.h 2005-06-12 11:52:25.000000000 +0200
> > @@ -337,7 +337,7 @@ extern void __struct_cpy_bug (void);
> > #define struct_cpy(x,y) \
> > ({ \
> > if (sizeof(*(x)) != sizeof(*(y))) \
> > - __struct_cpy_bug; \
> > + __struct_cpy_bug(); \
> > memcpy(x, y, sizeof(*(x))); \
> > })
>
> 1) Don't you need a void __struct_cpy_bug(void) declaration before this
> (as a matter of style, not correctness)?
Not any more than would the original version with the variable.
gcc4 doesn't complain.
> 2) Why __ ? It is not compiler- or library-special, why not
> BUG_struct_cpy_different_sizes() or something like this?
Ask the original author. I'm just following existing practise.
(I only seek minimal changes to enable gcc4 support, I'm _not_
on a mission to "clean up" code.)
/Mikael
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-06-12 20:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-12 11:22 [PATCH 2.4.31 9/9] gcc4: fix i386 struct_cpy() warnings Mikael Pettersson
2005-06-12 16:43 ` Denis Vlasenko
2005-06-12 17:03 Mikael Pettersson
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®