All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fix definition of NULL
@ 2009-02-06 21:20 Stefan Weil
  2009-02-06 23:25 ` M. Warner Losh
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Weil @ 2009-02-06 21:20 UTC (permalink / raw)
  To: QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 263 bytes --]

Hello,

the definition of NULL in dyngen-exec.h is correct for C++
but wrong for C. It results in a compiler warning.

My patch fixes it. Because Qemu does not support C++,
I just used the C definition and did not try to support
C++, too.

Regards
Stefan Weil




[-- Attachment #2: null.patch --]
[-- Type: text/x-diff, Size: 496 bytes --]

Fix declaration of NULL.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>

Index: trunk/dyngen-exec.h
===================================================================
--- trunk.orig/dyngen-exec.h	2009-02-06 22:15:33.000000000 +0100
+++ trunk/dyngen-exec.h	2009-02-06 22:16:03.000000000 +0100
@@ -91,7 +91,7 @@
 extern int fputs(const char *, FILE *);
 extern int printf(const char *, ...);
 #undef NULL
-#define NULL 0
+#define NULL ((void *)0)
 
 #if defined(__i386__)
 #define AREG0 "ebp"

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] Fix definition of NULL
  2009-02-06 21:20 [Qemu-devel] [PATCH] Fix definition of NULL Stefan Weil
@ 2009-02-06 23:25 ` M. Warner Losh
  0 siblings, 0 replies; 2+ messages in thread
From: M. Warner Losh @ 2009-02-06 23:25 UTC (permalink / raw)
  To: qemu-devel, weil

In message: <498CA9B6.5080302@mail.berlios.de>
            Stefan Weil <weil@mail.berlios.de> writes:
: Hello,
: 
: the definition of NULL in dyngen-exec.h is correct for C++
: but wrong for C. It results in a compiler warning.
: 
: My patch fixes it. Because Qemu does not support C++,
: I just used the C definition and did not try to support
: C++, too.

Actually, it is correct for C as well.  "#define NULL 0" is a
perfectly acceptable definition[*].  Your definition is also correct,
since there are two valid NULL pointer definitions in 'C'.  Which one
you use will determine which class of errors you catch, but neither
one will catch all errors.

which compilers is it generating warnings on and what are the
warnings?

Warner

[*] C9x section 3.2.3 para 3 states:

       [#3] An integer constant expression with  the  value  0,  or
       such  an  expression  cast  to type void *, is called a null
       pointer constant.

with a footnote that says NULL is defined in stddef.h.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-02-06 23:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-06 21:20 [Qemu-devel] [PATCH] Fix definition of NULL Stefan Weil
2009-02-06 23:25 ` M. Warner Losh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.