]> xenbits.xensource.com Git - libvirt.git/commitdiff
maint: add syntax check to prohibit static zero init
authorEric Blake <eblake@redhat.com>
Tue, 28 Oct 2014 18:22:03 +0000 (12:22 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 29 Oct 2014 15:55:09 +0000 (09:55 -0600)
Now that all offenders have been cleaned, turn on a syntax-check
rule to prevent future offenders.

* cfg.mk (sc_prohibit_static_zero_init): New rule.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Avoid false
positive.

Signed-off-by: Eric Blake <eblake@redhat.com>
cfg.mk
src/qemu/qemu_driver.c

diff --git a/cfg.mk b/cfg.mk
index 682687a3e7d81b9fa9bf19d2a5689badab28dbd6..927240b83dfab5837db11c432d1421fd66962886 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -962,6 +962,14 @@ sc_prohibit_paren_brace:
        halt='Put space between closing parenthesis and opening brace'  \
          $(_sc_search_regexp)
 
+# C guarantees that static variables are zero initialized, and some compilers
+# waste space by sticking explicit initializers in .data instead of .bss
+sc_prohibit_static_zero_init:
+       @prohibit='\bstatic\b.*= *(0[^xX0-9]|NULL|false)'               \
+       in_vc_files='\.[chx](\.in)?$$'                                  \
+       halt='static variables do not need explicit zero initialization'\
+         $(_sc_search_regexp)
+
 # FreeBSD exports the "devname" symbol which produces a warning.
 sc_prohibit_devname:
        @prohibit='\bdevname\b' \
index 373daab7768337dfeac2dfe5ef4babc3303af00e..2eaf77d0b29f7509fa891e5468674c436a8cacb8 100644 (file)
@@ -15671,8 +15671,9 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
              * that back into the return status of this API call.  */
             while (1) {
                 /* Poll every 50ms */
-                static struct timespec ts = { .tv_sec = 0,
-                                              .tv_nsec = 50 * 1000 * 1000ull };
+                static struct timespec ts = {
+                    .tv_sec = 0,
+                    .tv_nsec = 50 * 1000 * 1000ull };
                 virDomainBlockJobInfo dummy;
 
                 qemuDomainObjEnterMonitor(driver, vm);