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='\.*= *(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 \ diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 1f83b2c2a6..c2caf3311c 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -1182,7 +1182,7 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain, virDomainSnapshotDefPtr def = *defptr; int ret = -1; int align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; - int align_match = true; + bool align_match = true; char uuidstr[VIR_UUID_STRING_BUFLEN]; virDomainSnapshotObjPtr other; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a84fd479e7..74d1bdc639 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10933,7 +10933,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom, struct stat sb; int idx; int format; - int activeFail = false; + bool activeFail = false; virQEMUDriverConfigPtr cfg = NULL; char *alias = NULL; char *buf = NULL; @@ -13809,7 +13809,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, unsigned int parse_flags = VIR_DOMAIN_SNAPSHOT_PARSE_DISKS; virDomainSnapshotObjPtr other = NULL; int align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; - int align_match = true; + bool align_match = true; virQEMUDriverConfigPtr cfg = NULL; virCapsPtr caps = NULL; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index d7844bdeae..4b7fea1639 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6835,7 +6835,7 @@ testDomainSnapshotAlignDisks(virDomainObjPtr vm, unsigned int flags) { int align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; - int align_match = true; + bool align_match = true; if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) { align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 9bbe694a98..166f4dc727 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -3908,7 +3908,7 @@ bool virCgroupSupportsCpuBW(virCgroupPtr cgroup) { char *path = NULL; - int ret = false; + bool ret = false; if (!cgroup) return false; diff --git a/src/util/virpci.c b/src/util/virpci.c index f60d0fa640..cd78212a00 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1182,7 +1182,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *stubDriverName) { int result = -1; - int reprobe = false; + bool reprobe = false; char *stubDriverPath = NULL; char *driverLink = NULL; char *path = NULL; /* reused for different purposes */ diff --git a/src/util/virutil.c b/src/util/virutil.c index 88c8baf46d..9c40317d09 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -1995,7 +1995,7 @@ virIsCapableVport(const char *sysfs_prefix, { char *scsi_host_path = NULL; char *fc_host_path = NULL; - int ret = false; + bool ret = false; if (virAsprintf(&fc_host_path, "%s/host%d/%s", diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 4e434f89d0..259400ffa8 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -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"); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index a7e91511e9..d48765aeb2 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2640,7 +2640,7 @@ cmdBlockResize(vshControl *ctl, const vshCmd *cmd) const char *path = NULL; unsigned long long size = 0; unsigned int flags = 0; - int ret = false; + bool ret = false; if (vshCommandOptStringReq(ctl, cmd, "path", (const char **) &path) < 0) return false; @@ -5163,7 +5163,7 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd) virStreamPtr st = NULL; unsigned int screen = 0; unsigned int flags = 0; /* currently unused */ - int ret = false; + bool ret = false; bool created = false; bool generated = false; char *mime = NULL; @@ -7615,7 +7615,7 @@ static bool cmdInjectNMI(vshControl *ctl, const vshCmd *cmd) { virDomainPtr dom; - int ret = true; + bool ret = true; if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -7678,7 +7678,7 @@ static bool cmdSendKey(vshControl *ctl, const vshCmd *cmd) { virDomainPtr dom; - int ret = false; + bool ret = false; const char *codeset_option; int codeset; unsigned int holdtime = 0; @@ -7809,7 +7809,7 @@ static bool cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd) { virDomainPtr dom; - int ret = false; + bool ret = false; const char *pidstr; const char *signame; long long pid_value; @@ -10592,7 +10592,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd) int diff_mac; size_t i; int ret; - int functionReturn = false; + bool functionReturn = false; unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT; bool current = vshCommandOptBool(cmd, "current"); bool config = vshCommandOptBool(cmd, "config");