Let's make a rule out of it and document it. This is based on few sources: 1) Most of the code [1] used spaces after casts, so the patch to change it this way rather than the other way around is smaller 2) I asked the first libvirt developer on my left when deciding, they preferred spaces 3) My own preference. 4) The fact that this is clearly the superior way of casting =D [1] 54.85% is more than 50%, plus it is increasing as it was 52.96% during the first draft of this clean-up. Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> --- cfg.mk | 6 ++++++ docs/hacking.html.in | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/cfg.mk b/cfg.mk index 902178dd1c3a..967f99202481 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_require_space_after_cast: + @prohibit='(\([a-zA-Z _]+ \*+|\(((signed|unsigned|long|short|int|char|s?size_t|void) ?)+|switch \(\(vir[a-zA-Z]*Type)\)([^ );,])' \ + in_vc_files='*\.[chx]$$' \ + halt='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..df3821aa3084 100644 --- a/docs/hacking.html.in +++ b/docs/hacking.html.in @@ -579,6 +579,15 @@ int foo(int wizz); // Good </pre> + <p> + There must be a single 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 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list