Let's make a rule out of it and document it.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
cfg.mk | 6 ++++++
docs/hacking.html.in | 9 +++++++++
2 files changed, 15 insertions(+)
diff --git a/cfg.mk b/cfg.mk
index 902178dd1c3a..5f75338aac04 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1050,6 +1050,12 @@ sc_prohibit_backslash_alignment:
halt='Do not attempt to right-align backslashes' \
$(_sc_search_regexp)
+sc_prohibit_space_after_cast:
+ @prohibit='(\([a-zA-Z _]+
\*+|\(((signed|unsigned|long|short|int|char|[a-zA-Z]+_t|void|struct) ?)+|switch
\(\(vir[a-zA-Z]*Type)\)[[:space:]]+([^ );,{=\\A-Z])' \
+ in_vc_files='*\.[chx]$$' \
+ halt='Do not use space after cast' \
+ $(_sc_search_regexp)
+
# We don't use this feature of maint.mk.
prev_version_file = /dev/null
diff --git a/docs/hacking.html.in b/docs/hacking.html.in
index fbeea3eb751d..bf6f80c0d217 100644
--- a/docs/hacking.html.in
+++ b/docs/hacking.html.in
@@ -579,6 +579,15 @@
int foo(int wizz); // Good
</pre>
+ <p>
+ There must not be any whitespace immediately following a cast to any
+ type. E.g.
+ </p>
+ <pre>
+ foo = (int) bar; // Bad
+ foo = (int)bar; // Good
+</pre>
+
<h2><a id="comma">Commas</a></h2>
<p>
--
2.17.0