qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH] Darwin: Fix compilation warning regarding the deprecated daemon() function
@ 2011-06-02  2:45 Alexandre Raymond
  2011-06-02 12:09 ` Andreas Färber
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Alexandre Raymond @ 2011-06-02  2:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alexandre Raymond, andreas.faerber

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

Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
---
 qemu-nbd.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/qemu-nbd.c b/qemu-nbd.c
index e858033..10b0791 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -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)
-- 
1.7.5

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

* Re: [Qemu-devel] [RFC PATCH] Darwin: Fix compilation warning regarding the deprecated daemon() function
  2011-06-02  2:45 [Qemu-devel] [RFC PATCH] Darwin: Fix compilation warning regarding the deprecated daemon() function Alexandre Raymond
@ 2011-06-02 12:09 ` Andreas Färber
  2011-06-02 13:34   ` Alexandre Raymond
  2011-06-02 13:55 ` Peter Maydell
  2011-06-04  8:39 ` Blue Swirl
  2 siblings, 1 reply; 5+ messages in thread
From: Andreas Färber @ 2011-06-02 12:09 UTC (permalink / raw)
  To: Alexandre Raymond; +Cc: Blue Swirl, QEMU Developers

Am 02.06.2011 um 04:45 schrieb Alexandre Raymond:

> 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

> ----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.

http://developer.apple.com/library/mac/technotes/tn2083/_index.html#// 
apple_ref/doc/uid/DTS10003794-CH1-SUBSECTION64

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.

> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
> ---
> qemu-nbd.c |    9 +++++++++
> 1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index e858033..10b0791 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -16,6 +16,10 @@
>  *  along with this program; if not, see <http://www.gnu.org/ 
> licenses/>.
>  */
>
> +#if __APPLE__

#ifdef __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__

dito

> +#undef daemon
> +extern int daemon(int, int);

Blue Swirl has declared war on "extern"... ;)

> +#endif
> +
> #define SOCKET_PATH    "/var/lock/qemu-nbd-%s"
>
> #define NBD_BUFFER_SIZE (1024*1024)
> -- 
> 1.7.5

Andreas

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

* Re: [Qemu-devel] [RFC PATCH] Darwin: Fix compilation warning regarding the deprecated daemon() function
  2011-06-02 12:09 ` Andreas Färber
@ 2011-06-02 13:34   ` Alexandre Raymond
  0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Raymond @ 2011-06-02 13:34 UTC (permalink / raw)
  To: Andreas Färber; +Cc: Blue Swirl, QEMU Developers

Hi Andreas,

On Thu, Jun 2, 2011 at 8:09 AM, Andreas Färber <andreas.faerber@web.de> wrote:
> Am 02.06.2011 um 04:45 schrieb Alexandre Raymond:
>
>> 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
>
>> ----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.
>
> http://developer.apple.com/library/mac/technotes/tn2083/_index.html#//apple_ref/doc/uid/DTS10003794-CH1-SUBSECTION64

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

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

* Re: [Qemu-devel] [RFC PATCH] Darwin: Fix compilation warning regarding the deprecated daemon() function
  2011-06-02  2:45 [Qemu-devel] [RFC PATCH] Darwin: Fix compilation warning regarding the deprecated daemon() function Alexandre Raymond
  2011-06-02 12:09 ` Andreas Färber
@ 2011-06-02 13:55 ` Peter Maydell
  2011-06-04  8:39 ` Blue Swirl
  2 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2011-06-02 13:55 UTC (permalink / raw)
  To: Alexandre Raymond; +Cc: andreas.faerber, qemu-devel

On 2 June 2011 03:45, Alexandre Raymond <cerbere@gmail.com> wrote:

> 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

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

* Re: [Qemu-devel] [RFC PATCH] Darwin: Fix compilation warning regarding the deprecated daemon() function
  2011-06-02  2:45 [Qemu-devel] [RFC PATCH] Darwin: Fix compilation warning regarding the deprecated daemon() function Alexandre Raymond
  2011-06-02 12:09 ` Andreas Färber
  2011-06-02 13:55 ` Peter Maydell
@ 2011-06-04  8:39 ` Blue Swirl
  2 siblings, 0 replies; 5+ messages in thread
From: Blue Swirl @ 2011-06-04  8:39 UTC (permalink / raw)
  To: Alexandre Raymond; +Cc: andreas.faerber, qemu-devel

On Thu, Jun 2, 2011 at 5:45 AM, Alexandre Raymond <cerbere@gmail.com> wrote:
> 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
>
> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
> ---
>  qemu-nbd.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index e858033..10b0791 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -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
> +

Please introduce a wrapper instead, for example in oslib-posix.c. Then
the #ifdeffery is not spread to generic files.

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

end of thread, other threads:[~2011-06-04  8:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-02  2:45 [Qemu-devel] [RFC PATCH] Darwin: Fix compilation warning regarding the deprecated daemon() function Alexandre Raymond
2011-06-02 12:09 ` Andreas Färber
2011-06-02 13:34   ` Alexandre Raymond
2011-06-02 13:55 ` Peter Maydell
2011-06-04  8:39 ` Blue Swirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).