Darwin: Fix compilation warning regarding the deprecated daemon() function
PATCH v2 1/1 Darwin: Fix compilation warning regarding the deprecated daemon() function
Changes since v1: create a wrapper function named qemu_daemon() in oslib-posix.c instead of putting the OS specific workaround in qemu-nbd.c directly.
On OSX >= 10.5, daemon() is deprecated, resulting in the following warning:
----8<----qemu-nbd.c: In function ‘main’:
qemu-nbd.c:371: warning: ‘daemon’ is deprecated (declared at /usr/include/stdlib.h:289) ----8<----
The following trick, used in mDNSResponder, takes care of this warning:
http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-258.18/mDNSPosix/PosixDaemon.c
On OSX, it temporarily renames the daemon() function before including stdlib.h and declares it manually as an extern function. This way, the compiler does not see the declaration from stdlib.h and thus does not display the warning.
--- osdep.h | 1 + oslib-posix.c | 15 +++++++++++++++ qemu-nbd.c | 2 +- 3 files changed, 17 insertions(+), 1 deletions(-)
osdep.h +1 -0
@@ -88,6 +88,7 @@# define QEMU_GNUC_PREREQ (maj, min) 0#endif +int qemu_daemon (int nochdir,int noclose);void *qemu_memalign (size_t alignment,size_t size);void *qemu_vmalloc (size_t size);void qemu_vfree (void *ptr);
oslib-posix.c +15 -0
@@ -26,11 +26,26 @@* THE SOFTWARE. */ +/* The following block of code temporarily renames the daemon() function so the +compiler does not see the warning associated with it in stdlib.h on OSX */ +#ifdef __APPLE__ +#define daemon qemu_fake_daemon_function +#include <stdlib.h> +#undef daemon +extern int daemon (int ,int ); +#endif +#include "config-host.h" #include "sysemu.h" #include "trace.h" #include "qemu_socket.h" + + +int qemu_daemon (int nochdir,int noclose) { +return daemon (nochdir, noclose); +} +void *qemu_oom_check (void *ptr) {if (ptr ==NULL ) {
qemu-nbd.c +1 -1
@@ -359,7 +359,7 @@ int main(int argc, char **argv)if (!verbose) {/* detach client and server */ -if (daemon (0 ,0 ) ==-1 ) { +if (qemu_daemon (0 ,0 ) ==-1 ) {err (EXIT_FAILURE ,"Failed to daemonize" ); } }
Signature · 1 line
1.7.5
Am 07.06.2011 um 05:34 schrieb Alexandre Raymond:
Quoted 9 lines
Changes since v1: create a wrapper function named
qemu_daemon()inoslib-posix.cinstead of putting the OS specific workaround inqemu-nbd.cdirectly.On OSX >= 10.5,
daemon()is deprecated, resulting in the following warning:
----8<----qemu-nbd.c: In function ‘main’:
qemu-nbd.c:371: warning: ‘daemon’ is deprecated (declared at/usr/include/stdlib.h:289) ----8<----
Quoted 8 lines
The following trick, used in mDNSResponder, takes care of this warning:
http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-258.18/mDNSPosix/PosixDaemon.cOn OSX, it temporarily renames the
daemon()function before includingstdlib.hand declares it manually as an extern function. This way, the compiler does not see the declaration fromstdlib.hand thus does not display the warning.Signed-off-by Alexandre Raymond <[email protected]>
Blue, do you want this to go through the cocoa queue (please ack then) or do you want to apply this directly?
I have two further issues on my radar, 1) Alexandre's handleEvent: warning and 2) the big sigfd issue, and would then send a pull request.
Andreas
Quoted 68 lines
---
osdep.h | 1 + oslib-posix.c | 15 +++++++++++++++ qemu-nbd.c | 2 +- 3 files changed, 17 insertions(+), 1 deletions(-)osdep.h +1
-0@@ -88,6 +88,7 @@# define QEMU_GNUC_PREREQ (maj, min) 0#endif +int qemu_daemon (int nochdir,int noclose);void *qemu_memalign (size_t alignment,size_t size);void *qemu_vmalloc (size_t size);void qemu_vfree (void *ptr);oslib-posix.c +1
-0@@ -26,11 +26,26 @@* THE SOFTWARE. */ +/* The following block of code temporarily renames the daemon() function so the
+ compiler does not see the warning associated with it instdlib.h
on OSX */oslib-posix.c +7
-0+#ifdef __APPLE__ +#define daemon qemu_fake_daemon_function +#include <stdlib.h> +#undef daemon +extern int daemon (int ,int ); +#endif +#include "
config-host.h"
#include "sysemu.h"
#include "trace.h"
#include "qemu_socket.h"oslib-posix.c +6
-0+ + +int qemu_daemon (int nochdir,int noclose) { +return daemon (nochdir, noclose); +} +void *qemu_oom_check(void *ptr)
{ if (ptr == NULL) {qemu-nbd.c +1
-1@@ -359,7 +359,7 @@ int main(int argc, char **argv)if (!verbose) {/* detach client and server */ -if (daemon (0 ,0 ) ==-1 ) { +if (qemu_daemon (0 ,0 ) ==-1 ) {err (EXIT_FAILURE ,"Failed to daemonize" ); } }Signature · 1 line
1.7.5
Am 09.06.2011 um 20:47 schrieb Andreas Färber:
Quoted 34 lines
Am 07.06.2011 um 05:34 schrieb Alexandre Raymond:
Quoted 9 lines
Changes since v1: create a wrapper function named
qemu_daemon()inoslib-posix.cinstead of putting the OS specific workaround inqemu-nbd.cdirectly.On OSX >= 10.5,
daemon()is deprecated, resulting in the following warning:
----8<----qemu-nbd.c: In function ‘main’:
qemu-nbd.c:371: warning: ‘daemon’ is deprecated (declared at/usr/include/stdlib.h:289) ----8<----Quoted 8 lines
The following trick, used in mDNSResponder, takes care of this warning:
http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-258.18/mDNSPosix/PosixDaemon.cOn OSX, it temporarily renames the
daemon()function before includingstdlib.hand declares it manually as an extern function. This way, the compiler does not see the declaration fromstdlib.hand thus does not display the warning.Signed-off-by Alexandre Raymond <[email protected]>Acked-by Andreas Färber <[email protected]>Blue, do you want this to go through the cocoa queue (please ack then) or do you want to apply this directly?
I have two further issues on my radar, 1) Alexandre's handleEvent: warning and 2) the big sigfd issue, and would then send a pull request.
Quoted 8 lines
oslib-posix.c +0
-0@@ -26,11 +26,26 @@* THE SOFTWARE. */
Quoted 2 lines
Quoted 2 lines
oslib-posix.c +1
-0+/* The following block of code temporarily renames the daemon() function so the
This line had a trailing whitespace btw.
Andreas
Quoted 24 lines · Andreas Färber
Am 07.06.2011 um 05:34 schrieb Alexandre Raymond:
Quoted 22 lines
Changes since v1: create a wrapper function named
qemu_daemon()inoslib-posix.c
instead of putting the OS specific workaround inqemu-nbd.cdirectly.On OSX >= 10.5,
daemon()is deprecated, resulting in the following warning:
----8<----qemu-nbd.c: In function ‘main’:
qemu-nbd.c:371: warning: ‘daemon’ is deprecated (declared at/usr/include/stdlib.h:289)
----8<----The following trick, used in mDNSResponder, takes care of this warning:
http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-258.18/mDNSPosix/PosixDaemon.c
On OSX, it temporarily renames the
daemon()function before includingstdlib.h
and declares it manually as an extern function. This way, the compiler does not
see the declaration fromstdlib.hand thus does not display the warning.
Quoted 6 lines
Quoted 1 line
Signed-off-by Alexandre Raymond <[email protected]>Acked-by Andreas Färber <[email protected]>Blue, do you want this to go through the cocoa queue (please ack then) or do you want to apply this directly?
I have a minor style comment, but otherwise this could go via cocoa queue.
Quoted 47 lines
I have two further issues on my radar, 1) Alexandre's handleEvent: warning and 2) the big sigfd issue, and would then send a pull request.
Andreas
Quoted 42 lines
---
osdep.h| 1 +oslib-posix.c| 15 +++++++++++++++qemu-nbd.c| 2 +-3 files changed, 17 insertions(+), 1 deletions(-)osdep.h +1
-0@@ -88,6 +88,7 @@# define QEMU_GNUC_PREREQ (maj, min) 0#endif +int qemu_daemon (int nochdir,int noclose);void *qemu_memalign (size_t alignment,size_t size);void *qemu_vmalloc (size_t size);void qemu_vfree (void *ptr);oslib-posix.c +1
-0@@ -26,11 +26,26 @@* THE SOFTWARE. */ +/* The following block of code temporarily renames the daemon() function so the
+ compiler does not see the warning associated with it instdlib.hon OSX */oslib-posix.c +7
-0+#ifdef __APPLE__ +#define daemon qemu_fake_daemon_function +#include <stdlib.h> +#undef daemon +extern int daemon (int ,int ); +#endif +#include "
config-host.h"
#include "sysemu.h"
#include "trace.h"
#include "qemu_socket.h"
Quoted 3 lines
oslib-posix.c line 45
Quoted 3 lines
oslib-posix.c +3
-0+ + +int qemu_daemon (int nochdir,int noclose) {
Here the brace should be on a new line. This is C, not Java.
Quoted 25 lines
Quoted 23 lines
+ return
daemon(nochdir, noclose);oslib-posix.c +2
-0+} +void *qemu_oom_check(void *ptr)
{
if (ptr == NULL) {qemu-nbd.c +1
-2@@ -359,7 +359,7 @@ int main(int argc, char **argv) if (!verbose) { /* detach client and server */ - if (daemon(0, 0) == -1) { + if (qemu_daemon(0, 0) == -1) { err(EXIT_FAILURE, "Failed to daemonize"); } } --1.7.5
Am 13.06.2011 um 22:20 schrieb Blue Swirl:
Quoted 37 lines · Andreas Färber
Quoted 24 lines
Am 07.06.2011 um 05:34 schrieb Alexandre Raymond:
Quoted 22 lines
Changes since v1: create a wrapper function named
qemu_daemon()inoslib-posix.c
instead of putting the OS specific workaround inqemu-nbd.cdirectly.On OSX >= 10.5,
daemon()is deprecated, resulting in the following warning:
----8<----qemu-nbd.c: In function ‘main’:
qemu-nbd.c:371: warning: ‘daemon’ is deprecated (declared at/usr/include/stdlib.h:289)
----8<----The following trick, used in mDNSResponder, takes care of this warning:
http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-258.18/mDNSPosix/PosixDaemon.c
On OSX, it temporarily renames the
daemon()function before includingstdlib.h
and declares it manually as an extern function. This way, the compiler does not
see the declaration fromstdlib.hand thus does not display the warning.Quoted 6 lines
Quoted 1 line
Signed-off-by Alexandre Raymond <[email protected]>Acked-by Andreas Färber <[email protected]>Blue, do you want this to go through the cocoa queue (please ack then) or do you want to apply this directly?
I have a minor style comment, but otherwise this could go via cocoa queue.
Quoted 3 lines
I have two further issues on my radar, 1) Alexandre's handleEvent: warning and 2) the big sigfd issue, and would then send a pull request.
Quoted 8 lines
Quoted 6 lines
Andreas
Quoted 4 lines
oslib-posix.c +1
-0+int qemu_daemon (int nochdir,int noclose) {Here the brace should be on a new line.
Fixed.
Andreas