Darwin: Fix compilation warning regarding the deprecated daemon() function
RFC PATCH 1/1 Darwin: Fix compilation warning regarding the deprecated daemon() function
On OSX > 10.5, daemon() is deprecated, resulting int he 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
--- qemu-nbd.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
qemu-nbd.c +9 -0
@@ -16,6 +16,10 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#if __APPLE__ +#define daemon fake_daemon_function +#endif +#include <qemu-common.h> #include "block_int.h" #include "nbd.h"
@@ -32,6 +36,11 @@#include <signal.h> #include <libgen.h> +#if __APPLE__ +#undef daemon +extern int daemon (int ,int ); +#endif +#define SOCKET_PATH "/var/lock/qemu-nbd-%s"#define NBD_BUFFER_SIZE (1024*1024)
Signature · 1 line
1.7.5
Am 02.06.2011 um 04:45 schrieb Alexandre Raymond:
Quoted 3 lines
On OSX > 10.5,
daemon()is deprecated, resulting int he following warning:= 10.5
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/daemon.3.html
Quoted 7 lines
----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
Even if apparently applied by Apple themselves, I consider it a bad hack for curing symptoms.
Possibly a better fix would be to supply a .plist file for use with launchd/launchctl and to #ifndef __APPLE__ the daemon() functionality?
Further comments inline.
Quoted 14 lines
Signed-off-by Alexandre Raymond <[email protected]>---
qemu-nbd.c| 9 +++++++++1 files changed, 9 insertions(+), 0 deletions(-)qemu-nbd.c +0
-0@@ -16,6 +16,10 @@* along with this program; if not, see <http://www.gnu.org/ licenses/>.
*/
Quoted 1 line
+#if
__APPLE__
#ifdef __APPLE__
qemu-nbd.c line 39
Quoted 11 lines
qemu-nbd.c +3
-0+#define daemon fake_daemon_function +#endif +#include <
qemu-common.h>
#include "block_int.h"
#include "nbd.h"qemu-nbd.c +1
-0@@ -32,6 +36,11 @@#include <signal.h> #include <libgen.h> +#if __APPLE__
dito
qemu-nbd.c line 41
Quoted 2 lines
qemu-nbd.c +2
-0+#undef daemon +extern int daemon (int ,int );
Blue Swirl has declared war on "extern"... ;)
Quoted 7 lines
qemu-nbd.c +2
-0+#endif +#define SOCKET_PATH "/var/lock/qemu-nbd-%s"#define NBD_BUFFER_SIZE (1024*1024)Signature · 1 line
1.7.5
Andreas
Hi Andreas,
Quoted 14 lines · Andreas Färber
Am 02.06.2011 um 04:45 schrieb Alexandre Raymond:
Quoted 3 lines
On OSX > 10.5,
daemon()is deprecated, resulting int he following warning:= 10.5
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/daemon.3.html
Quoted 6 lines
----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
Quoted 3 lines
The following trick, used in mDNSResponder, takes care of this warning:
http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-258.18/mDNSPosix/PosixDaemon.c
Even if apparently applied by Apple themselves, I consider it a bad hack for curing symptoms.
I agree that this is a nasty hack. It's really up to you guys. I can try to modify this patch to use launchd instead.
Alexandre
Quoted 2 lines · Alexandre Raymond
The following trick, used in mDNSResponder, takes care of this warning:
http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-258.18/mDNSPosix/PosixDaemon.c
If we do decide to borrow this trick from there, can we also borrow some equivalent of the comment which explains why we're doing it?
-- PMM
Quoted 30 lines · Alexandre Raymond
On OSX > 10.5,
daemon()is deprecated, resulting int he 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.cSigned-off-by Alexandre Raymond <[email protected]>---
qemu-nbd.c | 9 +++++++++1 files changed, 9 insertions(+), 0 deletions(-)qemu-nbd.c +4
-0@@ -16,6 +16,10 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#if __APPLE__ +#define daemon fake_daemon_function +#endif + #include <qemu-common.h> #include "block_int.h" #include "nbd.h"
qemu-nbd.c line 43
Quoted 8 lines
qemu-nbd.c +5
-0@@ -32,6 +36,11 @@ #include <signal.h> #include <libgen.h> +#if __APPLE__ +#undef daemon +extern int daemon (int ,int ); +#endif +
Please introduce a wrapper instead, for example in oslib-posix.c. Then the #ifdeffery is not spread to generic files.