[PATCH v3 02/35] cfg.mk: variable initialization when declared with cleanup macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A variable, which is never assigned a value in the function, might get
passed into the cleanup function which may or may not raise any errors.

To maintain the correct usage, the variable must be initialized, either
with a value or with NULL. This syntax-check rule takes care of that.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@xxxxxxxxx>
---
 cfg.mk | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/cfg.mk b/cfg.mk
index 6bebd0a..196d1b2 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1057,6 +1057,17 @@ sc_prohibit_backslash_alignment:
 	halt='Do not attempt to right-align backslashes' \
 	  $(_sc_search_regexp)
 
+# Some syntax rules pertaining to the usage of cleanup macros
+# implementing GNU C's cleanup attribute
+
+# Rule to ensure that varibales declared using a cleanup macro are
+# always initialized.
+sc_require_attribute_cleanup_initialization:
+	@prohibit='VIR_AUTO(FREE|PTR)\(.+\) [^=]+;' \
+	in_vc_files='\.[chx]$$' \
+	halt='variable declared with a cleanup macro must be initialized' \
+	  $(_sc_search_regexp)
+
 # We don't use this feature of maint.mk.
 prev_version_file = /dev/null
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux