]> xenbits.xensource.com Git - libvirt.git/commitdiff
maint: avoid static zero init in drivers
authorEric Blake <eblake@redhat.com>
Tue, 28 Oct 2014 18:38:04 +0000 (12:38 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 29 Oct 2014 15:55:09 +0000 (09:55 -0600)
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/libxl/libxl_driver.c: Fix initialization.
* src/lxc/lxc_controller.c: Likewise.
* src/openvz/openvz_util.c (openvzKBPerPages): Likewise.
* src/phyp/phyp_driver.c: Likewise.
* src/remote/remote_driver.c: Likewise.
* src/test/test_driver.c: Likewise.
* src/uml/uml_driver.c: Likewise.
* src/vbox/vbox_XPCOMCGlue.c: Likewise.
* src/vbox/vbox_tmpl.c: Likewise.
* src/xen/xen_driver.c: Likewise.
* src/xen/xen_hypervisor.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/libxl/libxl_driver.c
src/lxc/lxc_controller.c
src/openvz/openvz_util.c
src/phyp/phyp_driver.c
src/remote/remote_driver.c
src/test/test_driver.c
src/uml/uml_driver.c
src/vbox/vbox_XPCOMCGlue.c
src/vbox/vbox_tmpl.c
src/xen/xen_driver.c
src/xen/xen_hypervisor.c

index eeebb4f6c93a10364738a43793dcf18e6596cdc7..d2c077cddc4e82ea74aa7782d807b5826223f1be 100644 (file)
@@ -76,7 +76,7 @@ VIR_LOG_INIT("libxl.libxl_driver");
 #define XEN_SCHED_CREDIT_NPARAM   2
 
 
-static libxlDriverPrivatePtr libxl_driver = NULL;
+static libxlDriverPrivatePtr libxl_driver;
 
 /* Function declarations */
 static int
index 1861dd6fdb4800955b3921616b320f7cbd8d2913..1e4b9bc1702ab10ee5c6a927dced495e1bd09e8b 100644 (file)
@@ -819,7 +819,7 @@ static int lxcControllerClearCapabilities(void)
     return 0;
 }
 
-static bool wantReboot = false;
+static bool wantReboot;
 static virMutex lock = VIR_MUTEX_INITIALIZER;
 
 
index 42143358e3a4bdf4217574daf6d7639decf64340..8032f6aa7324c8b94f273be3526e76dee1d7a830 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * openvz_util.c: core driver methods for managing OpenVZ VEs
  *
- * Copyright (C) 2013 Red Hat, Inc.
+ * Copyright (C) 2013-2014 Red Hat, Inc.
  * Copyright (C) 2012 Guido Günther
  *
  * This library is free software; you can redistribute it and/or
@@ -39,7 +39,7 @@
 long
 openvzKBPerPages(void)
 {
-    static long kb_per_pages = 0;
+    static long kb_per_pages;
 
     if (kb_per_pages == 0) {
         kb_per_pages = sysconf(_SC_PAGESIZE);
index a56f25ddd7188e0558f04f93b94ad9e8ab329087..09617c8fe530d2ed743373b22de73da412aac2ab 100644 (file)
@@ -68,9 +68,11 @@ VIR_LOG_INIT("phyp.phyp_driver");
  * URI: phyp://user@[hmc|ivm]/managed_system
  * */
 
-static unsigned const int HMC = 0;
-static unsigned const int PHYP_IFACENAME_SIZE = 24;
-static unsigned const int PHYP_MAC_SIZE = 12;
+enum {
+    HMC = 0,
+    PHYP_IFACENAME_SIZE = 24,
+    PHYP_MAC_SIZE = 12,
+};
 
 static int
 waitsocket(int socket_fd, LIBSSH2_SESSION * session)
index b8d90ed43c10cb561580331091a7958ccd66372c..65c04d98c6412ed49ea2c34e7fc5a37e8e5619aa 100644 (file)
@@ -77,7 +77,7 @@ VIR_LOG_INIT("remote.remote_driver");
     deserializeTypedParameters(__FUNCTION__, ret_params_val, ret_params_len,  \
                                limit, params, nparams)
 
-static bool inside_daemon = false;
+static bool inside_daemon;
 
 struct private_data {
     virMutex lock;
index f435d03a87587fe4b41c11e5b33f6770d6dfbd7a..2afd6fe7f818ce1040215114bc711ab8b4b97654 100644 (file)
@@ -471,7 +471,7 @@ static const char *defaultNodeXML =
 "</device>";
 
 static const unsigned long long defaultPoolCap = (100 * 1024 * 1024 * 1024ull);
-static const unsigned long long defaultPoolAlloc = 0;
+static const unsigned long long defaultPoolAlloc;
 
 static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool);
 static int testNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info);
index 4f5f6e15ae50b2f5f0a502d3399f883550423a9a..2baf2fa916069830639cdeee1b336e0b208225b6 100644 (file)
@@ -147,7 +147,7 @@ static int umlMonitorCommand(const struct uml_driver *driver,
                              const char *cmd,
                              char **reply);
 
-static struct uml_driver *uml_driver = NULL;
+static struct uml_driver *uml_driver;
 
 static int
 umlVMFilterRebuild(virDomainObjListIterator iter, void *data)
index d0c4a15ff8ef7fc5e882da65bf05cd6a6dba2269..aaa7c607b4774cbb2dfb9a200131db38efefea44 100644 (file)
@@ -68,9 +68,9 @@ VIR_LOG_INIT("vbox.vbox_XPCOMCGlue");
 *   Global Variables                                                           *
 *******************************************************************************/
 /** The dlopen handle for VBoxXPCOMC. */
-static void *hVBoxXPCOMC = NULL;
+static void *hVBoxXPCOMC;
 /** Pointer to the VBoxXPCOMC function table. */
-static PCVBOXXPCOM pVBoxFuncs_v2_2 = NULL;
+static PCVBOXXPCOM pVBoxFuncs_v2_2;
 /** Pointer to VBoxGetXPCOMCFunctions for the loaded VBoxXPCOMC so/dylib/dll. */
 PFNVBOXGETXPCOMCFUNCTIONS g_pfnGetFunctions = NULL;
 
index acaada022956c59f6f57f70279185ec4c38dd5da..b2e9ef487069dd05cad27a4f308fe84f3e94d64e 100644 (file)
@@ -177,7 +177,7 @@ if (strUtf16) {\
  * them that way
  */
 
-static vboxGlobalData *g_pVBoxGlobalData = NULL;
+static vboxGlobalData *g_pVBoxGlobalData;
 
 #endif /* !(VBOX_API_VERSION == 2002000) */
 
index d0420507c68b236dd4273982cc24466f64cd8e52..5f7c98f010553a24c66bed8a50eb68ef2afa2530 100644 (file)
@@ -91,8 +91,8 @@ xenUnifiedDomainGetVcpusInternal(virDomainPtr dom,
                                  int maplen);
 
 
-static bool is_privileged = false;
-static virSysinfoDefPtr hostsysinfo = NULL;
+static bool is_privileged;
+static virSysinfoDefPtr hostsysinfo;
 
 static virDomainDefPtr xenGetDomainDefForID(virConnectPtr conn, int id)
 {
index d3d4aea1916bd18af8efb0cdb3f42ba5e37034fc..4be889108b7436cef4110ad81bef211f8ce2fa97 100644 (file)
@@ -126,7 +126,7 @@ typedef privcmd_hypercall_t hypercall_t;
 # define SYS_IFACE_MIN_VERS_NUMA 4
 #endif
 
-static int xen_ioctl_hypercall_cmd = 0;
+static int xen_ioctl_hypercall_cmd;
 static struct xenHypervisorVersions hv_versions = {
     .hv = 0,
     .hypervisor = 2,
@@ -134,7 +134,7 @@ static struct xenHypervisorVersions hv_versions = {
     .dom_interface = -1,
 };
 
-static int kb_per_pages = 0;
+static int kb_per_pages;
 
 /* Regular expressions used by xenHypervisorGetCapabilities, and
  * compiled once by xenHypervisorInit.  Note that these are POSIX.2