diff mbox series

[XEN,10/13] xen/efi: address violations of MISRA C:2012 Directive 4.10

Message ID 7726a38c4bf15a94b9bbcbc465bd499f94067ddc.1693228255.git.simone.ballarin@bugseng.com (mailing list archive)
State Superseded
Headers show
Series address violations of MISRA C:2012 Directive 4.10 | expand

Commit Message

Simone Ballarin Aug. 28, 2023, 1:20 p.m. UTC
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.ballarin@bugseng.com>
---
 xen/common/efi/efi.h     | 5 +++++
 xen/common/efi/runtime.c | 6 ++++++
 2 files changed, 11 insertions(+)

Comments

Stefano Stabellini Aug. 28, 2023, 10:42 p.m. UTC | #1
On Mon, 28 Aug 2023, 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.ballarin@bugseng.com>
> ---
>  xen/common/efi/efi.h     | 5 +++++
>  xen/common/efi/runtime.c | 6 ++++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/xen/common/efi/efi.h b/xen/common/efi/efi.h
> index c02fbb7b69..cef9381d30 100644
> --- a/xen/common/efi/efi.h
> +++ b/xen/common/efi/efi.h
> @@ -1,3 +1,6 @@
> +#ifndef __COMMON_EFI_EFI_H__
> +#define __COMMON_EFI_EFI_H__
> +
>  #include <asm/efibind.h>
>  #include <efi/efidef.h>
>  #include <efi/efierr.h>
> @@ -51,3 +54,5 @@ void free_ebmalloc_unused_mem(void);
>  
>  const void *pe_find_section(const void *image, const UINTN image_size,
>                              const CHAR16 *section_name, UINTN *size_out);
> +
> +#endif /* __COMMON_EFI_EFI_H__ */
> diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
> index 5cb7504c96..fb6fd17ba3 100644
> --- a/xen/common/efi/runtime.c
> +++ b/xen/common/efi/runtime.c
> @@ -6,6 +6,10 @@
>  #include <xen/irq.h>
>  #include <xen/time.h>
>  
> +#ifndef __COMMON_EFI_RUNTIME_C__
> +#define __COMMON_EFI_RUNTIME_C__

Shouldn't this be at the top of the file?


>  DEFINE_XEN_GUEST_HANDLE(CHAR16);
>  
>  struct efi_rs_state {
> @@ -704,3 +708,5 @@ int efi_runtime_call(struct xenpf_efi_runtime_call *op)
>      return rc;
>  }
>  #endif
> +
> +#endif /* __COMMON_EFI_RUNTIME_C__ */
> -- 
> 2.34.1
>
Jan Beulich Aug. 29, 2023, 6:47 a.m. UTC | #2
On 29.08.2023 00:42, Stefano Stabellini wrote:
> On Mon, 28 Aug 2023, Simone Ballarin wrote:
>> --- a/xen/common/efi/runtime.c
>> +++ b/xen/common/efi/runtime.c
>> @@ -6,6 +6,10 @@
>>  #include <xen/irq.h>
>>  #include <xen/time.h>
>>  
>> +#ifndef __COMMON_EFI_RUNTIME_C__
>> +#define __COMMON_EFI_RUNTIME_C__
> 
> Shouldn't this be at the top of the file?

Imo .c files shouldn't gain guards in the first place.

Jan
diff mbox series

Patch

diff --git a/xen/common/efi/efi.h b/xen/common/efi/efi.h
index c02fbb7b69..cef9381d30 100644
--- a/xen/common/efi/efi.h
+++ b/xen/common/efi/efi.h
@@ -1,3 +1,6 @@ 
+#ifndef __COMMON_EFI_EFI_H__
+#define __COMMON_EFI_EFI_H__
+
 #include <asm/efibind.h>
 #include <efi/efidef.h>
 #include <efi/efierr.h>
@@ -51,3 +54,5 @@  void free_ebmalloc_unused_mem(void);
 
 const void *pe_find_section(const void *image, const UINTN image_size,
                             const CHAR16 *section_name, UINTN *size_out);
+
+#endif /* __COMMON_EFI_EFI_H__ */
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index 5cb7504c96..fb6fd17ba3 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -6,6 +6,10 @@ 
 #include <xen/irq.h>
 #include <xen/time.h>
 
+#ifndef __COMMON_EFI_RUNTIME_C__
+#define __COMMON_EFI_RUNTIME_C__
+
+
 DEFINE_XEN_GUEST_HANDLE(CHAR16);
 
 struct efi_rs_state {
@@ -704,3 +708,5 @@  int efi_runtime_call(struct xenpf_efi_runtime_call *op)
     return rc;
 }
 #endif
+
+#endif /* __COMMON_EFI_RUNTIME_C__ */