diff mbox series

[v2,3/7] tests/style: check for mixups of bool constants with int variables

Message ID 20220704152303.760983-4-berrange@redhat.com
State New
Headers show
Series tests: introduce a tree-wide code style checking facility | expand

Commit Message

Daniel P. Berrangé July 4, 2022, 3:22 p.m. UTC
The 'true' and 'false' constants should only ever be used with the
'bool' type, never 'int'.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/style.mak | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/tests/style.mak b/tests/style.mak
index 32c7e706ba..ae658395c9 100644
--- a/tests/style.mak
+++ b/tests/style.mak
@@ -22,3 +22,9 @@ 
 
 include tests/style-infra.mak
 include tests/style-excludes.mak
+
+# Use 'bool', not 'int', when assigning true or false
+sc_int_assign_bool:
+	@prohibit='\<int\>.*= *(true|false)\b' \
+	halt='use bool type for boolean values' \
+	$(_sc_search_regexp)