maint: add syntax check to prohibit static zero init

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>
This commit is contained in:
Eric Blake 2014-10-28 12:22:03 -06:00
parent ec81cf8942
commit 85f2d0dd55
2 changed files with 11 additions and 2 deletions

8
cfg.mk
View File

@ -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' \

View 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);