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>
This commit is contained in:
Eric Blake
2014-11-17 16:39:48 -07:00
parent 2aa167cafd
commit eb9093763f
9 changed files with 20 additions and 14 deletions

View File

@@ -298,7 +298,7 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
virDomainMemoryStatStruct stats[VIR_DOMAIN_MEMORY_STAT_NR];
unsigned int nr_stats;
size_t i;
int ret = false;
bool ret = false;
int rv = 0;
int period = -1;
bool config = vshCommandOptBool(cmd, "config");