From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:40966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWIKf-00086m-Of for qemu-devel@nongnu.org; Mon, 13 Jun 2011 21:22:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QWIKb-0003hV-Uj for qemu-devel@nongnu.org; Mon, 13 Jun 2011 21:22:17 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:59358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWIKb-0003gI-Jy for qemu-devel@nongnu.org; Mon, 13 Jun 2011 21:22:13 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 14 Jun 2011 03:22:07 +0200 Message-Id: <1308014527-60251-11-git-send-email-andreas.faerber@web.de> In-Reply-To: <1308014527-60251-10-git-send-email-andreas.faerber@web.de> References: <1308014527-60251-1-git-send-email-andreas.faerber@web.de> <1308014527-60251-2-git-send-email-andreas.faerber@web.de> <1308014527-60251-3-git-send-email-andreas.faerber@web.de> <1308014527-60251-4-git-send-email-andreas.faerber@web.de> <1308014527-60251-5-git-send-email-andreas.faerber@web.de> <1308014527-60251-6-git-send-email-andreas.faerber@web.de> <1308014527-60251-7-git-send-email-andreas.faerber@web.de> <1308014527-60251-8-git-send-email-andreas.faerber@web.de> <1308014527-60251-9-git-send-email-andreas.faerber@web.de> <1308014527-60251-10-git-send-email-andreas.faerber@web.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: andreas.faerber@web.de Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 10/10] Darwin: Fix compilation warning regarding the deprecated daemon() function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexandre Raymond , Blue Swirl , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Alexandre Raymond 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 >=3D 10.5, daemon() is deprecated, resulting in the following warn= ing: ----8<---- qemu-nbd.c: In function =E2=80=98main=E2=80=99: qemu-nbd.c:371: warning: =E2=80=98daemon=E2=80=99 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 std= lib.h and declares it manually as an extern function. This way, the compiler do= es not see the declaration from stdlib.h and thus does not display the warning. Signed-off-by: Alexandre Raymond Cc: Blue Swirl Signed-off-by: Andreas F=C3=A4rber --- osdep.h | 1 + oslib-posix.c | 16 ++++++++++++++++ qemu-nbd.c | 2 +- 3 files changed, 18 insertions(+), 1 deletions(-) diff --git a/osdep.h b/osdep.h index 970d767..6eb9a49 100644 --- a/osdep.h +++ b/osdep.h @@ -88,6 +88,7 @@ # define QEMU_GNUC_PREREQ(maj, min) 0 #endif =20 +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); diff --git a/oslib-posix.c b/oslib-posix.c index 7bc5f7c..3a18e86 100644 --- a/oslib-posix.c +++ b/oslib-posix.c @@ -26,11 +26,27 @@ * THE SOFTWARE. */ =20 +/* 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 O= SX */ +#ifdef __APPLE__ +#define daemon qemu_fake_daemon_function +#include +#undef daemon +extern int daemon(int, int); +#endif + #include "config-host.h" #include "sysemu.h" #include "trace.h" #include "qemu_socket.h" =20 + + +int qemu_daemon(int nochdir, int noclose) +{ + return daemon(nochdir, noclose); +} + void *qemu_oom_check(void *ptr) { if (ptr =3D=3D NULL) { diff --git a/qemu-nbd.c b/qemu-nbd.c index 110d78e..d91c02c 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -359,7 +359,7 @@ int main(int argc, char **argv) =20 if (!verbose) { /* detach client and server */ - if (daemon(0, 0) =3D=3D -1) { + if (qemu_daemon(0, 0) =3D=3D -1) { err(EXIT_FAILURE, "Failed to daemonize"); } } --=20 1.7.5.3