All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simone Ballarin <simone.ballarin@bugseng.com>
To: Julien Grall <julien.grall.oss@gmail.com>
Cc: Bertrand Marquis <bertrand.marquis@arm.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	consulting@bugseng.com, sstabellini@kernel.org,
	xen-devel@lists.xenproject.org
Subject: Re: [XEN PATCH 03/13] xen/arm: address violations of MISRA C:2012 Directive 4.10
Date: Wed, 30 Aug 2023 14:53:08 +0200	[thread overview]
Message-ID: <8d82e827-6ad9-4695-5ec0-65c65b79b055@bugseng.com> (raw)
In-Reply-To: <CAJ=z9a2hnjCAkGN_YtCQRh8ZcyMMawxBhF8LOwgrQ5-nML1chg@mail.gmail.com>

On 29/08/23 00:10, Julien Grall wrote:
> Hi,
> 
> On Mon, 28 Aug 2023 at 09:20, Simone Ballarin <simone.ballarin@bugseng.com>
> wrote:
> 
>> Add or move 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").
>>
>> Inclusion guards must appear at the beginning of the headers
>> (comments are permitted anywhere).
>>
>> Mechanical change.
>>
>> Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
>> ---
>>   xen/arch/arm/efi/efi-boot.h          | 6 ++++++
>>   xen/arch/arm/include/asm/hypercall.h | 6 +++---
>>   xen/arch/arm/include/asm/iocap.h     | 6 +++---
>>   3 files changed, 12 insertions(+), 6 deletions(-)
>>
>> diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
>> index 1c3640bb65..aba522ead5 100644
>> --- a/xen/arch/arm/efi/efi-boot.h
>> +++ b/xen/arch/arm/efi/efi-boot.h
>> @@ -3,6 +3,10 @@
>>    * is intended to be included by common/efi/boot.c _only_, and
>>    * therefore can define arch specific global variables.
>>    */
>> +
>> +#ifndef __ARM_EFI_EFI_BOOT_H__
>> +#define __ARM_EFI_EFI_BOOT_H__
>> +
>>   #include <xen/device_tree.h>
>>   #include <xen/libfdt/libfdt.h>
>>   #include <asm/setup.h>
>> @@ -1003,6 +1007,8 @@ static void __init efi_arch_flush_dcache_area(const
>> void *vaddr, UINTN size)
>>       __flush_dcache_area(vaddr, size);
>>   }
>>
>> +#endif /* __ARM_EFI_EFI_BOOT_H__*/
>> +
>>   /*
>>    * Local variables:
>>    * mode: C
>> diff --git a/xen/arch/arm/include/asm/hypercall.h
>> b/xen/arch/arm/include/asm/hypercall.h
>> index ccd26c5184..4f4d96f1f2 100644
>> --- a/xen/arch/arm/include/asm/hypercall.h
>> +++ b/xen/arch/arm/include/asm/hypercall.h
>> @@ -1,10 +1,10 @@
>> +#ifndef __ASM_ARM_HYPERCALL_H__
>> +#define __ASM_ARM_HYPERCALL_H__
>> +
>>   #ifndef __XEN_HYPERCALL_H__
>>   #error "asm/hypercall.h should not be included directly - include
>> xen/hypercall.h instead"
>>   #endif
>>
>> -#ifndef __ASM_ARM_HYPERCALL_H__
>> -#define __ASM_ARM_HYPERCALL_H__
>> -
> 
> 
> I understand that you are trying to fix a misra violation. However, this
> feels like it was done on purpose.
> 
> With the new change, you would not always check that the file were included
> at the correct place. I am not against this change but this ought to be
> explained.
I don't think the semantics have changed. Please correct me if I'm wrong.

With this change, the only situation where the check is not performed is 
when __ASM_ARM_HYPERCALL_H__ is defined (i.e. the file has already been 
successfully included). This implies that if __ASM_ARM_HYPERCALL_H__ is 
defined, then __XEN_HYPERCALL_H__ is also defined, so the check would be 
useless.

The same thing happened with the code before the change: if I include 
the file after xen/hypercall.h, the check will always succeed.

> 
> 
>>   #include <public/domctl.h> /* for arch_do_domctl */
>>
>>   long subarch_do_domctl(struct xen_domctl *domctl, struct domain *d,
>> diff --git a/xen/arch/arm/include/asm/iocap.h
>> b/xen/arch/arm/include/asm/iocap.h
>> index 276fefbc59..4db1b16839 100644
>> --- a/xen/arch/arm/include/asm/iocap.h
>> +++ b/xen/arch/arm/include/asm/iocap.h
>> @@ -1,10 +1,10 @@
>> -#ifndef __X86_IOCAP_H__
>> -#define __X86_IOCAP_H__
>> +#ifndef __ASM_ARM_IOCAP_H__
>> +#define __ASM_ARM_IOCAP_H__
>>
>>   #define cache_flush_permitted(d)                        \
>>       (!rangeset_is_empty((d)->iomem_caps))
>>
>> -#endif
>> +#endif /* __ASM_ARM_IOCAP_H__ */
> 
> 
> I don’t understand how this is related to the rest of the patch. You wrote
> that inclusion must appear first and this is the case here.
> 
> However the name is technically not correct. Is this really related to
> directive 4.10? If so, this should be clarified in the commit message. If
> not, then I think this should be in a separate commit.
>

Yes, you are right. This is not correlated to this series. I will put it 
on a separate commit.

> Cheers,
> 
> 
>>
>>   /*
>>    * Local variables:
>> --
>> 2.34.1
>>
>>
> 

-- 
Simone Ballarin, M.Sc.

Field Application Engineer, BUGSENG (https://bugseng.com)



  reply	other threads:[~2023-08-30 12:53 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-28 13:19 [XEN PATCH 00/13] address violations of MISRA C:2012 Directive 4.10 Simone Ballarin
2023-08-28 13:19 ` [XEN PATCH 01/13] misra: add deviation for headers that explicitly avoid guards Simone Ballarin
2023-08-28 21:59   ` Stefano Stabellini
2023-08-28 22:32     ` Stefano Stabellini
2023-08-30  8:47       ` Simone Ballarin
2023-08-29  6:33   ` Jan Beulich
2023-08-30  8:46     ` Simone Ballarin
2023-08-28 13:19 ` [XEN PATCH 02/13] automation/eclair: add text-based deviation for empty headers Simone Ballarin
2023-08-28 22:00   ` Stefano Stabellini
2023-08-30 10:25     ` Simone Ballarin
2023-08-29  6:35   ` Jan Beulich
2023-08-30 11:27     ` Simone Ballarin
2023-08-28 13:20 ` [XEN PATCH 03/13] xen/arm: address violations of MISRA C:2012 Directive 4.10 Simone Ballarin
2023-08-28 22:02   ` Stefano Stabellini
2023-08-28 22:10   ` Julien Grall
2023-08-30 12:53     ` Simone Ballarin [this message]
2023-08-30 13:01       ` Jan Beulich
2023-08-30 13:06         ` Simone Ballarin
2023-08-28 13:20 ` [XEN PATCH 04/13] xen/x86: " Simone Ballarin
2023-08-28 22:11   ` Stefano Stabellini
2023-08-29 13:21   ` Jan Beulich
2023-08-28 13:20 ` [XEN PATCH 05/13] automation/eclair: add deviation for usercopy.c Simone Ballarin
2023-08-28 22:27   ` Stefano Stabellini
2023-08-29  6:41     ` Jan Beulich
2023-08-30 14:47     ` Simone Ballarin
2023-08-31  1:56       ` Stefano Stabellini
2023-08-31  9:24         ` Jan Beulich
2023-09-04 12:43     ` Luca Fancellu
2023-08-28 13:20 ` [XEN PATCH 06/13] x86/EFI: address violations of MISRA C:2012 Directive 4.10 Simone Ballarin
2023-08-28 22:28   ` Stefano Stabellini
2023-08-29 13:27   ` Jan Beulich
2023-08-30 15:16     ` Simone Ballarin
2023-08-28 13:20 ` [XEN PATCH 07/13] x86/asm: " Simone Ballarin
2023-08-28 22:30   ` Stefano Stabellini
2023-08-30 15:23     ` Simone Ballarin
2023-08-29  6:44   ` Jan Beulich
2023-08-28 13:20 ` [XEN PATCH 08/13] x86/mm: " Simone Ballarin
2023-08-28 22:35   ` Stefano Stabellini
2023-08-28 13:20 ` [XEN PATCH 09/13] xen/common: " Simone Ballarin
2023-08-28 22:41   ` Stefano Stabellini
2023-08-29  6:50   ` Jan Beulich
2023-08-31 10:08     ` Simone Ballarin
2023-08-31 11:10       ` Jan Beulich
2023-08-31 12:54         ` Simone Ballarin
2023-08-31 13:05           ` Jan Beulich
2023-08-31 13:30             ` Simone Ballarin
2023-09-05 22:18               ` Stefano Stabellini
2023-09-06  6:28                 ` Jan Beulich
2023-09-06  7:35                 ` Simone Ballarin
2023-08-28 13:20 ` [XEN PATCH 10/13] xen/efi: " Simone Ballarin
2023-08-28 22:42   ` Stefano Stabellini
2023-08-29  6:47     ` Jan Beulich
2023-08-28 13:20 ` [XEN PATCH 11/13] xen/sched: " Simone Ballarin
2023-08-28 22:43   ` Stefano Stabellini
2023-08-30 14:54   ` George Dunlap
2023-08-28 13:20 ` [XEN PATCH 12/13] xen: " Simone Ballarin
2023-08-28 22:51   ` Stefano Stabellini
2023-08-31 12:18     ` Simone Ballarin
2023-08-31 12:25       ` Jan Beulich
2023-09-05 22:27       ` Stefano Stabellini
2023-09-06  6:32         ` Jan Beulich
2023-09-07  1:12           ` Stefano Stabellini
2023-08-29  6:54   ` Jan Beulich
2023-08-28 13:20 ` [XEN PATCH 13/13] x86/asm: " Simone Ballarin
2023-08-28 22:45   ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8d82e827-6ad9-4695-5ec0-65c65b79b055@bugseng.com \
    --to=simone.ballarin@bugseng.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=bertrand.marquis@arm.com \
    --cc=consulting@bugseng.com \
    --cc=julien.grall.oss@gmail.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.