[PATCH 1/4] cfg.mk: Introduce syntax-check rule for incorrect indentation or empty for first line in function body

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

 



Signed-off-by: Shi Lei <shi_lei@xxxxxxxxxxxxxx>
---
 cfg.mk | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/cfg.mk b/cfg.mk
index 609ae86..a43cb1c 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -702,6 +702,17 @@ sc_preprocessor_indentation:
 	  echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
 	fi
 
+# Use 4 spaces rather than TAB for indentation for those top-level
+# function bodies. Doesn't catch all cases, but it helps.
+sc_indentation_for_function_body:
+	@for f in $$($(VC_LIST_EXCEPT) | grep -E '\.[ch](\.in)?$$'); do \
+	  grep -n -A1 '^{$$' $$f | grep '^[0-9]\{1,\}-' \
+      | grep -v '^[0-9]\{1,\}-[ ]\{4\}\S' | grep -v '^[0-9]\{1,\}-\([#}/]\|.*:\)' \
+      | $(SED) -ne "s#\(^[0-9]\{1,\}\)-#$$f:\1:#gp" | grep . && \
+	  { echo '$(ME): incorrect indentation or empty for first line in function body' 1>&2; \
+	    exit 1; } \
+	done || :
+
 # Enforce similar spec file indentation style, by running cppi on a
 # (comment-only) C file that mirrors the same layout as the spec file.
 sc_spec_indentation:
-- 
2.17.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