[PATCH 5/7] maint: avoid static zero init in helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



C guarantees that static variables are zero-initialized.  Some older
compilers (and also gcc -fno-zero-initialized-in-bss) create larger
binaries if you explicitly zero-initialize a static variable.

* src/conf/nwfilter_conf.c: Fix initialization.
* src/cpu/cpu_x86.c: Likewise.
* src/interface/interface_backend_netcf.c: Likewise.
* src/locking/lock_daemon.c: Likewise.
* src/locking/lock_driver_lockd.c: Likewise.
* src/locking/lock_driver_sanlock.c: Likewise.
* src/network/bridge_driver.c: Likewise.
* src/node_device/node_device_udev.c: Likewise.
* src/nwfilter/nwfilter_learnipaddr.c: Likewise.
* src/rpc/virnetserver.c: Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxGenSecurityLabel): Likewise.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---
 src/conf/nwfilter_conf.c                | 2 +-
 src/cpu/cpu_x86.c                       | 2 +-
 src/interface/interface_backend_netcf.c | 2 +-
 src/locking/lock_daemon.c               | 2 +-
 src/locking/lock_driver_lockd.c         | 4 ++--
 src/locking/lock_driver_sanlock.c       | 2 +-
 src/network/bridge_driver.c             | 2 +-
 src/node_device/node_device_udev.c      | 2 +-
 src/nwfilter/nwfilter_learnipaddr.c     | 2 +-
 src/rpc/virnetserver.c                  | 4 ++--
 src/security/security_selinux.c         | 2 +-
 11 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 0a0265d..4b22709 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -144,7 +144,7 @@ static const struct int_map chain_priorities[] = {
  * only one filter update allowed
  */
 static virRWLock updateLock;
-static bool initialized = false;
+static bool initialized;

 void
 virNWFilterReadLockFilterUpdates(void)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 57f343c..026b54e 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -92,7 +92,7 @@ struct x86_map {
     struct x86_feature *migrate_blockers;
 };

-static struct x86_map* virCPUx86Map = NULL;
+static struct x86_map* virCPUx86Map;
 int virCPUx86MapOnceInit(void);
 VIR_ONCE_GLOBAL_INIT(virCPUx86Map);

diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c
index c55a080..a4b2ea9 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -63,7 +63,7 @@ virNetcfDriverStateOnceInit(void)

 VIR_ONCE_GLOBAL_INIT(virNetcfDriverState)

-static virNetcfDriverStatePtr driverState = NULL;
+static virNetcfDriverStatePtr driverState;


 static void
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index fe7cfb8..75244e8 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -67,7 +67,7 @@ struct _virLockDaemon {

 virLockDaemonPtr lockDaemon = NULL;

-static bool execRestart = false;
+static bool execRestart;

 enum {
     VIR_LOCK_DAEMON_ERR_NONE = 0,
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index 0a40e94..a642122 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -1,7 +1,7 @@
 /*
  * lock_driver_lockd.c: A lock driver which locks nothing
  *
- * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2010-2011, 2014 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -79,7 +79,7 @@ struct _virLockManagerLockDaemonDriver {
     char *scsiLockSpaceDir;
 };

-static virLockManagerLockDaemonDriverPtr driver = NULL;
+static virLockManagerLockDaemonDriverPtr driver;

 static int virLockManagerLockDaemonLoadConfig(const char *configFile)
 {
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index aa6b8fb..0318f25 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -79,7 +79,7 @@ struct _virLockManagerSanlockDriver {
     gid_t group;
 };

-static virLockManagerSanlockDriver *driver = NULL;
+static virLockManagerSanlockDriver *driver;

 struct _virLockManagerSanlockPrivate {
     const char *vm_uri;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 5f2e778..10ded33 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -126,7 +126,7 @@ static int networkUnplugBandwidth(virNetworkObjPtr net,
 static void networkNetworkObjTaint(virNetworkObjPtr net,
                                    virNetworkTaintFlags taint);

-static virNetworkDriverStatePtr driverState = NULL;
+static virNetworkDriverStatePtr driverState;

 static virNetworkObjPtr
 networkObjFromNetwork(virNetworkPtr net)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 53792f0..f580a9b 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -56,7 +56,7 @@ struct _udevPrivate {
     bool privileged;
 };

-static virNodeDeviceDriverStatePtr driverState = NULL;
+static virNodeDeviceDriverStatePtr driverState;

 static int udevStrToLong_ull(char const *s,
                              char **end_ptr,
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index 4cea9cf..911079e 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -134,7 +134,7 @@ struct _virNWFilterIfaceLock {
 };


-static bool threadsTerminate = false;
+static bool threadsTerminate;


 int
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 762c185..3d3e422 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -817,8 +817,8 @@ void virNetServerRemoveShutdownInhibition(virNetServerPtr srv)



-static sig_atomic_t sigErrors = 0;
-static int sigLastErrno = 0;
+static sig_atomic_t sigErrors;
+static int sigLastErrno;
 static int sigWrite = -1;

 static void
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 352f1ab..f96be50 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -641,7 +641,7 @@ virSecuritySELinuxGenSecurityLabel(virSecurityManagerPtr mgr,
         if (!baselabel) {
             if (def->virtType == VIR_DOMAIN_VIRT_QEMU) {
                 if (data->alt_domain_context == NULL) {
-                    static bool warned = false;
+                    static bool warned;
                     if (!warned) {
                         VIR_WARN("SELinux policy does not define a domain type for QEMU TCG. "
                                  "Guest startup may be denied due to missing 'execmem' privilege "
-- 
1.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]