On 2025-05-19 21:10, Jan Beulich wrote:
On 19.05.2025 15:52, Andrew Cooper wrote:
Signed-off-by: Andrew Cooper <andrew.coop...@citrix.com>

Is this to please Misra in some way?


Directive 4.10: "Precautions shall be taken in order to prevent the contents of a header file being included more than once". One approach is to special-case this file, but Andrew suggested this approach which addresses the issue directly.

--- a/xen/include/xen/compile.h.in
+++ b/xen/include/xen/compile.h.in
@@ -1,3 +1,6 @@
+#ifndef XEN_COMPILE_H
+#define XEN_COMPILE_H
+
 #define XEN_COMPILE_DATE       "@@date@@"
 #define XEN_COMPILE_TIME       "@@time@@"
 #define XEN_COMPILE_BY         "@@whoami@@"
--- a/xen/tools/process-banner.sed
+++ b/xen/tools/process-banner.sed
@@ -12,3 +12,8 @@ s_(.*)_"\1\\n"_

 # Trailing \ on all but the final line.
 $!s_$_ \\_
+
+# Append closing header guard
+$a\
+\
+#endif /* XEN_COMPILE_H */

This split of #ifndef and #endif is ugly. Can't we switch to something
more conventional, like

#define XEN_BANNER              "@@banner@@"

with the first sed invocation then replacing this by the result of
a nested sed invocation using process-banner.sed (which of course would
need adjusting some)? (Maybe the double quotes would need omitting here,
for process-banner.sed to uniformly apply them.)

Jan

--
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253

Reply via email to