summaryrefslogtreecommitdiff
path: root/cfg.mk
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2014-11-17 16:39:48 -0700
committerEric Blake <eblake@redhat.com>2014-11-19 08:20:39 -0700
commiteb9093763f59db1626f54b5e5c678d0c42290f45 (patch)
tree636910af8c957a5f95b4441ef8c2fdb8422198a4 /cfg.mk
parent2aa167cafd507730890c54dc577fff0968ee7386 (diff)
downloadlibvirt-eb9093763f59db1626f54b5e5c678d0c42290f45.tar.gz
maint: forbid 'int foo = true'
I noticed this while working on qemuDomainGetBlockInfo. Assigning a bool value to an int variable compiles fine, but raises red flags on the maintenance front as it becomes too easy to assign -1 or 2 or any other non-bool value to the same variable. * cfg.mk (sc_prohibit_int_assign_bool): New rule. * src/conf/snapshot_conf.c (virDomainSnapshotRedefinePrep): Fix offenders. * src/qemu/qemu_driver.c (qemuDomainGetBlockInfo) (qemuDomainSnapshotCreateXML): Likewise. * src/test/test_driver.c (testDomainSnapshotAlignDisks): Likewise. * src/util/vircgroup.c (virCgroupSupportsCpuBW): Likewise. * src/util/virpci.c (virPCIDeviceBindToStub): Likewise. * src/util/virutil.c (virIsCapableVport): Likewise. * tools/virsh-domain-monitor.c (cmdDomMemStat): Likewise. * tools/virsh-domain.c (cmdBlockResize, cmdScreenshot) (cmdInjectNMI, cmdSendKey, cmdSendProcessSignal) (cmdDetachInterface): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'cfg.mk')
-rw-r--r--cfg.mk6
1 files changed, 6 insertions, 0 deletions
diff --git a/cfg.mk b/cfg.mk
index f188645e20..c49f4f3a02 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -584,6 +584,12 @@ sc_prohibit_loop_var_decl:
halt='declare loop iterators outside the for statement' \
$(_sc_search_regexp)
+# Use 'bool', not 'int', when assigning true or false
+sc_prohibit_int_assign_bool:
+ @prohibit='\<int\>.*= *(true|false)' \
+ halt='use bool type for boolean values' \
+ $(_sc_search_regexp)
+
# Many of the function names below came from this filter:
# git grep -B2 '\<_('|grep -E '\.c- *[[:alpha:]_][[:alnum:]_]* ?\(.*[,;]$' \
# |sed 's/.*\.c- *//'|perl -pe 's/ ?\(.*//'|sort -u \