[libvirt] [PATCH] xen: Fix inside_daemon being unused when libvirtd is disabled

The defined __sun is there, because inside_daemon is used in xenUnifiedOpen if __sun is defined. Also initialize it to 0. --- src/xen/xen_driver.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 5ab169d..b16a16a 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -70,7 +70,9 @@ static struct xenUnifiedDriver const * const drivers[XEN_UNIFIED_NR_DRIVERS] = { #endif }; -static int inside_daemon; +#if defined WITH_LIBVIRTD || defined __sun +static int inside_daemon = 0; +#endif #define xenUnifiedError(code, ...) \ virReportErrorHelper(NULL, VIR_FROM_XEN, code, __FILE__, \ -- 1.6.3.3

On 04/23/2010 11:00 AM, Matthias Bolte wrote:
The defined __sun is there, because inside_daemon is used in xenUnifiedOpen if __sun is defined. Also initialize it to 0. --- src/xen/xen_driver.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 5ab169d..b16a16a 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -70,7 +70,9 @@ static struct xenUnifiedDriver const * const drivers[XEN_UNIFIED_NR_DRIVERS] = { #endif };
-static int inside_daemon; +#if defined WITH_LIBVIRTD || defined __sun
ACK on this line.
+static int inside_daemon = 0;
NAK on this change. C89 guarantees that static variables are initialized to 0, thanks to the .bss. And although gcc can optimize explicit initialization to 0 to use the .bss, not all compilers do that, so you end up with a larger binary for no reason. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

2010/4/23 Eric Blake <eblake@redhat.com>:
On 04/23/2010 11:00 AM, Matthias Bolte wrote:
The defined __sun is there, because inside_daemon is used in xenUnifiedOpen if __sun is defined. Also initialize it to 0. --- src/xen/xen_driver.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 5ab169d..b16a16a 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -70,7 +70,9 @@ static struct xenUnifiedDriver const * const drivers[XEN_UNIFIED_NR_DRIVERS] = { #endif };
-static int inside_daemon; +#if defined WITH_LIBVIRTD || defined __sun
ACK on this line.
+static int inside_daemon = 0;
NAK on this change. C89 guarantees that static variables are initialized to 0, thanks to the .bss. And although gcc can optimize explicit initialization to 0 to use the .bss, not all compilers do that, so you end up with a larger binary for no reason.
Ah, okay. I didn't know that. I removed the = 0 and pushed the patch. Matthias
participants (2)
-
Eric Blake
-
Matthias Bolte