From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:57467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWDcp-00005R-Fs for qemu-devel@nongnu.org; Mon, 13 Jun 2011 16:20:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QWDcm-0006Mo-60 for qemu-devel@nongnu.org; Mon, 13 Jun 2011 16:20:42 -0400 Received: from mail-qw0-f45.google.com ([209.85.216.45]:40483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWDcl-0006Md-Rp for qemu-devel@nongnu.org; Mon, 13 Jun 2011 16:20:39 -0400 Received: by qwj8 with SMTP id 8so2917737qwj.4 for ; Mon, 13 Jun 2011 13:20:39 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <3F92F108-6AEF-4041-AA1C-895EA552D012@web.de> References: <1307417650-12955-1-git-send-email-cerbere@gmail.com> <3F92F108-6AEF-4041-AA1C-895EA552D012@web.de> From: Blue Swirl Date: Mon, 13 Jun 2011 23:20:19 +0300 Message-ID: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] Darwin: Fix compilation warning regarding the deprecated daemon() function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Andreas_F=C3=A4rber?= Cc: Alexandre Raymond , Peter Maydell , qemu-devel Developers , Alexander Graf On Thu, Jun 9, 2011 at 9:47 PM, Andreas F=C3=A4rber wrote: > Am 07.06.2011 um 05:34 schrieb 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 >> warning: >> ----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 (declare= d 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.1= 8/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. >> >> Signed-off-by: Alexandre Raymond > > Acked-by: Andreas F=C3=A4rber > > 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. > I have two further issues on my radar, 1) Alexandre's handleEvent: warnin= g > and 2) the big sigfd issue, and would then send a pull request. > > Andreas > >> --- >> osdep.h =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A01 + >> oslib-posix.c | =C2=A0 15 +++++++++++++++ >> qemu-nbd.c =C2=A0 =C2=A0| =C2=A0 =C2=A02 +- >> 3 files changed, 17 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 >> >> +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..5392e25 100644 >> --- a/oslib-posix.c >> +++ b/oslib-posix.c >> @@ -26,11 +26,26 @@ >> =C2=A0* THE SOFTWARE. >> =C2=A0*/ >> >> +/* The following block of code temporarily renames the daemon() functio= n >> so the >> + =C2=A0 compiler does not see the warning associated with it in stdlib.= h on >> OSX */ >> +#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" >> >> + >> + >> +int qemu_daemon(int nochdir, int noclose) { Here the brace should be on a new line. This is C, not Java. >> + =C2=A0 =C2=A0return daemon(nochdir, noclose); >> +} >> + >> void *qemu_oom_check(void *ptr) >> { >> =C2=A0 =C2=A0if (ptr =3D=3D NULL) { >> diff --git a/qemu-nbd.c b/qemu-nbd.c >> index e858033..e65cc6c 100644 >> --- a/qemu-nbd.c >> +++ b/qemu-nbd.c >> @@ -359,7 +359,7 @@ int main(int argc, char **argv) >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!verbose) { >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* detach client and server */ >> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (daemon(0, 0) =3D=3D -1) { >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (qemu_daemon(0, 0) =3D=3D = -1) { >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0err(EXIT_FAILURE,= "Failed to daemonize"); >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} >> =C2=A0 =C2=A0 =C2=A0 =C2=A0} >> -- >> 1.7.5 >> >> > >