]> xenbits.xensource.com Git - libvirt.git/commitdiff
maint: avoid static zero init in tests
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.

* tests/eventtest.c: Fix initialization.
* tests/testutils.c: Likewise.
* tests/virhostdevtest.c: Likewise.
* tests/virportallocatortest.c: Likewise.
* tests/virscsitest.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
tests/eventtest.c
tests/testutils.c
tests/virhostdevtest.c
tests/virportallocatortest.c
tests/virscsitest.c

index 2cfa0c61e0f9f58904dff4e7f62dd6c5c8994c87..87b49d3315c249b130e41bcad92478e6bf341c12 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * eventtest.c: Test the libvirtd event loop impl
  *
- * Copyright (C) 2009, 2011-2013 Red Hat, Inc.
+ * Copyright (C) 2009, 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
@@ -116,9 +116,9 @@ testTimer(int timer, void *data)
 
 static pthread_mutex_t eventThreadMutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t eventThreadRunCond = PTHREAD_COND_INITIALIZER;
-static int eventThreadRunOnce = 0;
+static int eventThreadRunOnce;
 static pthread_cond_t eventThreadJobCond = PTHREAD_COND_INITIALIZER;
-static int eventThreadJobDone = 0;
+static int eventThreadJobDone;
 
 
 ATTRIBUTE_NORETURN static void *eventThreadLoop(void *data ATTRIBUTE_UNUSED) {
index dd65fe86b8ac1d0f1d5c06d6ce36e81da4f89138..9d6980f9ce24e5e869cb70d57c14cb99689802f2 100644 (file)
@@ -74,20 +74,20 @@ static unsigned int testVerbose = -1;
 static unsigned int testExpensive = -1;
 
 #ifdef TEST_OOM
-static unsigned int testOOM = 0;
+static unsigned int testOOM;
 static unsigned int testOOMStart = -1;
 static unsigned int testOOMEnd = -1;
-static unsigned int testOOMTrace = 0;
+static unsigned int testOOMTrace;
 # ifdef TEST_OOM_TRACE
 void *testAllocStack[30];
 int ntestAllocStack;
 # endif
 #endif
-static bool testOOMActive = false;
+static bool testOOMActive;
 
-static size_t testCounter = 0;
-static size_t testStart = 0;
-static size_t testEnd = 0;
+static size_t testCounter;
+static size_t testStart;
+static size_t testEnd;
 
 char *progname;
 
index de4cdde904127891aa070c262e6c810ae4eb98db..1e93819ce70400f60aa667725f57bde3b6e82922 100644 (file)
@@ -53,7 +53,7 @@ static const unsigned char *uuid =
 static int nhostdevs = 3;
 static virDomainHostdevDefPtr hostdevs[] = {NULL, NULL, NULL};
 static virPCIDevicePtr dev[] = {NULL, NULL, NULL};
-static virHostdevManagerPtr mgr = NULL;
+static virHostdevManagerPtr mgr;
 
 static void
 myCleanup(void)
index 96d2ade8754f90ca14e0771fea503d0d24ab7ab4..ef503ceeb0cd6e89df6c3eea01a753726e782eea 100644 (file)
@@ -36,7 +36,7 @@
 #  include <netinet/in.h>
 #  include <stdio.h>
 
-static bool host_has_ipv6 = false;
+static bool host_has_ipv6;
 static int (*realsocket)(int domain, int type, int protocol);
 
 static void init_syms(void)
index b4ed5e9b08684707f571f14c7f01c0be25c3e765..a86ca28f4edec1f11c2f95a24480c06570fa94bd 100644 (file)
@@ -34,7 +34,7 @@
 VIR_LOG_INIT("tests.scsitest");
 
 static const char *abs_top_srcdir;
-static char *virscsi_prefix = NULL;
+static char *virscsi_prefix;
 
 static int
 test1(const void *data ATTRIBUTE_UNUSED)