xen: Give compile.h header guards
PATCH 1/1 xen: Give compile.h header guards
---
CC: Anthony PERARD <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
--- xen/include/xen/compile.h.in | 3 +++ xen/tools/process-banner.sed | 5 +++++ 2 files changed, 8 insertions(+)
xen/include/xen/compile.h.in +3 -0
@@ -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@@"
xen/tools/process-banner.sed +5 -0
@@ -12,3 +12,8 @@ s_(.*)_"\1\\n"_ # Trailing \ on all but the final line. $!s_$_ \\_ + +# Append closing header guard +$a\ +\ +#endif /* XEN_COMPILE_H */
base-commit: 6fc02ebdd053856221f37ba5306232ac1575332d
prerequisite-patch-id: 7bc1c498ba2c9c4a4939a56a0006f820f47f2a66
Signature · 1 line
2.39.5
Quoted 1 line · Andrew Cooper
Signed-off-by Andrew Cooper <[email protected]>
Is this to please Misra in some way?
Quoted 12 lines
xen/include/xen/compile.h.in +3
-0@@ -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@@"
xen/tools/process-banner.sed s_(.*)_"\1\\n"_ · line 19
Quoted 8 lines
xen/tools/process-banner.sed +5
-0@@ -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
Quoted 5 lines · Jan Beulich
Quoted 1 line · Andrew Cooper
Signed-off-by Andrew Cooper <[email protected]>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.
Quoted 32 lines
Quoted 12 lines
xen/include/xen/compile.h.in +3
-0@@ -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@@"xen/tools/process-banner.sed s_(.*)_"\1\\n"_ · line 19
Quoted 8 lines
xen/tools/process-banner.sed +5
-0@@ -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
Signature · 4 lines
Nicola Vetrini, B.Sc. Software Engineer BUGSENG (https://bugseng.com) LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
Quoted 29 lines · Jan Beulich
Quoted 1 line · Andrew Cooper
Signed-off-by Andrew Cooper <[email protected]>Is this to please Misra in some way?
Quoted 12 lines
xen/include/xen/compile.h.in +3
-0@@ -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@@"xen/tools/process-banner.sed s_(.*)_"\1\\n"_ · line 19
Quoted 8 lines
xen/tools/process-banner.sed +5
-0@@ -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
Quoted 6 lines
#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.)
While I agree with Jan that this is kind of ugly, it is a unique case and I would prefer an ugly but simple solution than a more complex solution. This would be different if we were talking about a widespread pattern, in which case the price for complexity would be worth it.
My 2 cents in this case are in favor of the simplest approach. I would ack this patch.
Quoted 37 lines · Stefano Stabellini
Quoted 29 lines · Jan Beulich
Quoted 1 line · Andrew Cooper
Signed-off-by Andrew Cooper <[email protected]>Is this to please Misra in some way?
Quoted 12 lines
xen/include/xen/compile.h.in +3
-0@@ -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@@"xen/tools/process-banner.sed s_(.*)_"\1\\n"_ · line 19
Quoted 8 lines
xen/tools/process-banner.sed +5
-0@@ -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
Quoted 6 lines
#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.)
Quoted 7 lines
While I agree with Jan that this is kind of ugly, it is a unique case and I would prefer an ugly but simple solution than a more complex solution. This would be different if we were talking about a widespread pattern, in which case the price for complexity would be worth it.
My 2 cents in this case are in favor of the simplest approach. I would ack this patch.
Feel free to do so; my comment was not meant as a plain objection, but more as a suggestion. The one thing I would ask for is a non-empty description, though.
Jan
Stefano Stabellini
Reviewed-byQuoted 43 lines · Jan Beulich
Quoted 42 lines · Stefano Stabellini
Quoted 29 lines · Jan Beulich
Quoted 1 line · Andrew Cooper
Signed-off-by Andrew Cooper <[email protected]>Is this to please Misra in some way?
Quoted 12 lines
xen/include/xen/compile.h.in +3
-0@@ -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@@"xen/tools/process-banner.sed s_(.*)_"\1\\n"_ · line 19
Quoted 8 lines
xen/tools/process-banner.sed +5
-0@@ -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
Quoted 6 lines
#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.)
While I agree with Jan that this is kind of ugly, it is a unique case and I would prefer an ugly but simple solution than a more complex solution. This would be different if we were talking about a widespread pattern, in which case the price for complexity would be worth it.
Quoted 6 lines
Quoted 2 lines
My 2 cents in this case are in favor of the simplest approach. I would ack this patch.
Feel free to do so; my comment was not meant as a plain objection, but more as a suggestion. The one thing I would ask for is a non-empty description, though.
Fair enough. Andrew, please add a better commit message. With that:
Quoted 19 lines · Andrew Cooper
Signed-off-by Andrew Cooper <[email protected]>---
CC: Anthony PERARD <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>--- xen/include/xen/compile.h.in | 3 +++ xen/tools/process-banner.sed | 5 +++++ 2 files changed, 8 insertions(+)xen/include/xen/compile.h.in +0
-0
xen/include/xen/compile.h.in line 3
Quoted 3 lines
xen/include/xen/compile.h.in +3
-0@@ -1,3 +1,6 @@ +#ifndef XEN_COMPILE_H +#define XEN_COMPILE_H +
Why not follow CODING_STYLE ?
OT: Maybe while on it, why not add SPDX comments too ?
Quoted 17 lines
xen/include/xen/compile.h.in +0
-0#define XEN_COMPILE_DATE "@@date@@" #define XEN_COMPILE_TIME "@@time@@" #define XEN_COMPILE_BY "@@whoami@@"xen/tools/process-banner.sed +5
-0@@ -12,3 +12,8 @@ s_(.*)_"\1\\n"_ # Trailing \ on all but the final line. $!s_$_ \\_ + +# Append closing header guard +$a\ +\ +#endif /* XEN_COMPILE_H */
Quoted 6 lines
base-commit:
6fc02ebdd053856221f37ba5306232ac1575332d
prerequisite-patch-id:7bc1c498ba2c9c4a4939a56a0006f820f47f2a66--
2.39.5
Frediano