On 29/08/23 08:50, Jan Beulich wrote:
On 28.08.2023 15:20, Simone Ballarin wrote:
Add inclusion guards to address violations of
MISRA C:2012 Directive 4.10 ("Precautions shall be taken in order
to prevent the contents of a header file being included more than
once").
Also C files, if included somewhere, need to comply with the guideline.
Mechanical change.
Signed-off-by: Simone Ballarin <simone.balla...@bugseng.com>
---
xen/common/compat/grant_table.c | 7 +++++++
xen/common/coverage/gcc_4_7.c | 5 +++++
xen/common/decompress.h | 5 +++++
xen/common/event_channel.h | 5 +++++
xen/common/multicall.c | 5 +++++
5 files changed, 27 insertions(+)
As already said in reply to another patch, imo .c files shouldn't gain such
guards. These are commonly referred to as "header guards" for a reason.
This is the MISRA's definition of "header file" (MISRA C:2012 Revision
1, Appendix J):
"A header file is any file that is the subject of a #include
directive.
Note: the filename extension is not significant."
So, the guards are required if we want to comply with the directive,
otherwise we can raise a deviation.
The danger of multi-inclusion also exists for .c files, why do you want
to avoid guards for them?
--- a/xen/common/compat/grant_table.c
+++ b/xen/common/compat/grant_table.c
@@ -3,6 +3,10 @@
*
*/
+
Nit: No double blank lines please.
+#ifndef __COMMON_COMPAT_GRANT_TABLE_C__
+#define __COMMON_COMPAT_GRANT_TABLE_C__
+
#include <xen/hypercall.h>
#include <compat/grant_table.h>
@@ -331,6 +335,9 @@ int compat_grant_table_op(
return rc;
}
+
Again here (at least).
Jan
--
Simone Ballarin, M.Sc.
Field Application Engineer, BUGSENG (https://bugseng.com)