diff mbox series

[XEN,02/13] automation/eclair: add text-based deviation for empty headers

Message ID 96e9ca524ed8191bfd5ee1230e8d581c50e299f5.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:19 p.m. UTC
This patch adds a text-based deviation for Directive 4.10:
"Precautions shall be taken in order to prevent the contents of
a header file being included more than once"

Headers starting with the following comment are not supposed to
comply with the directive:
"/* empty */"

These headers should be empty, therefore they pose no risk if included
more than once.

Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
---
 automation/eclair_analysis/ECLAIR/deviations.ecl | 1 +
 1 file changed, 1 insertion(+)

Comments

Stefano Stabellini Aug. 28, 2023, 10 p.m. UTC | #1
On Mon, 28 Aug 2023, Simone Ballarin wrote:
> This patch adds a text-based deviation for Directive 4.10:
> "Precautions shall be taken in order to prevent the contents of
> a header file being included more than once"
> 
> Headers starting with the following comment are not supposed to
> comply with the directive:
> "/* empty */"
> 
> These headers should be empty, therefore they pose no risk if included
> more than once.
> 
> Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>

Acked-by: Stefano Stabellini <sstabellini@kernel.org>

However I think we should also update rules.rst and/or update
docs/misra/safe.json


> ---
>  automation/eclair_analysis/ECLAIR/deviations.ecl | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl
> index 5f068377fa..2681a4cff5 100644
> --- a/automation/eclair_analysis/ECLAIR/deviations.ecl
> +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
> @@ -80,6 +80,7 @@ inline functions."
>  
>  -doc_begin="This header file is autogenerated or empty, therefore it poses no
>  risk if included more than once."
> +-config=MC3R1.D4.10,reports+={safe, "first_area(text(^/\\* empty \\*/$, begin-1))"}
>  -file_tag+={empty_header, "^xen/arch/arm/efi/runtime\\.h$"}
>  -file_tag+={autogen_headers, "^xen/include/xen/compile\\.h$||^xen/include/generated/autoconf.h$||^xen/include/xen/hypercall-defs.h$"}
>  -config=MC3R1.D4.10,reports+={safe, "all_area(all_loc(file(empty_header||autogen_headers)))"}
> -- 
> 2.34.1
>
Jan Beulich Aug. 29, 2023, 6:35 a.m. UTC | #2
On 28.08.2023 15:19, Simone Ballarin wrote:
> --- a/automation/eclair_analysis/ECLAIR/deviations.ecl
> +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
> @@ -80,6 +80,7 @@ inline functions."
>  
>  -doc_begin="This header file is autogenerated or empty, therefore it poses no
>  risk if included more than once."

While unrelated to, the change at hand, I still have a question on this:
How come it is deemed universally safe to multi-include generated headers.
I would have said that whether that's safe depends on the nature of the
generated code in the header. Only truly empty ones are uniformly safe to
include any number of times.

Jan

> +-config=MC3R1.D4.10,reports+={safe, "first_area(text(^/\\* empty \\*/$, begin-1))"}
>  -file_tag+={empty_header, "^xen/arch/arm/efi/runtime\\.h$"}
>  -file_tag+={autogen_headers, "^xen/include/xen/compile\\.h$||^xen/include/generated/autoconf.h$||^xen/include/xen/hypercall-defs.h$"}
>  -config=MC3R1.D4.10,reports+={safe, "all_area(all_loc(file(empty_header||autogen_headers)))"}
Simone Ballarin Aug. 30, 2023, 10:25 a.m. UTC | #3
On 29/08/23 00:00, Stefano Stabellini wrote:
> On Mon, 28 Aug 2023, Simone Ballarin wrote:
>> This patch adds a text-based deviation for Directive 4.10:
>> "Precautions shall be taken in order to prevent the contents of
>> a header file being included more than once"
>>
>> Headers starting with the following comment are not supposed to
>> comply with the directive:
>> "/* empty */"
>>
>> These headers should be empty, therefore they pose no risk if included
>> more than once.
>>
>> Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
> 
> Acked-by: Stefano Stabellini <sstabellini@kernel.org>
> 
> However I think we should also update rules.rst and/or update
> docs/misra/safe.json

I will do it in the next submission.
> 
> 
>> ---
>>   automation/eclair_analysis/ECLAIR/deviations.ecl | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl
>> index 5f068377fa..2681a4cff5 100644
>> --- a/automation/eclair_analysis/ECLAIR/deviations.ecl
>> +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
>> @@ -80,6 +80,7 @@ inline functions."
>>   
>>   -doc_begin="This header file is autogenerated or empty, therefore it poses no
>>   risk if included more than once."
>> +-config=MC3R1.D4.10,reports+={safe, "first_area(text(^/\\* empty \\*/$, begin-1))"}
>>   -file_tag+={empty_header, "^xen/arch/arm/efi/runtime\\.h$"}
>>   -file_tag+={autogen_headers, "^xen/include/xen/compile\\.h$||^xen/include/generated/autoconf.h$||^xen/include/xen/hypercall-defs.h$"}
>>   -config=MC3R1.D4.10,reports+={safe, "all_area(all_loc(file(empty_header||autogen_headers)))"}
>> -- 
>> 2.34.1
>>
>
Simone Ballarin Aug. 30, 2023, 11:27 a.m. UTC | #4
On 29/08/23 08:35, Jan Beulich wrote:
> On 28.08.2023 15:19, Simone Ballarin wrote:
>> --- a/automation/eclair_analysis/ECLAIR/deviations.ecl
>> +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
>> @@ -80,6 +80,7 @@ inline functions."
>>   
>>   -doc_begin="This header file is autogenerated or empty, therefore it poses no
>>   risk if included more than once."
> 
> While unrelated to, the change at hand, I still have a question on this:
> How come it is deemed universally safe to multi-include generated headers.
> I would have said that whether that's safe depends on the nature of the
> generated code in the header. Only truly empty ones are uniformly safe to
> include any number of times.

Yes, I agree with you. The mere fact that a file is auto-generated does 
not imply anything, moreover, this deviation is not even reported in 
rule.rst. In the next series, I'll drop it.

> 
> Jan
> 
>> +-config=MC3R1.D4.10,reports+={safe, "first_area(text(^/\\* empty \\*/$, begin-1))"}
>>   -file_tag+={empty_header, "^xen/arch/arm/efi/runtime\\.h$"}
>>   -file_tag+={autogen_headers, "^xen/include/xen/compile\\.h$||^xen/include/generated/autoconf.h$||^xen/include/xen/hypercall-defs.h$"}
>>   -config=MC3R1.D4.10,reports+={safe, "all_area(all_loc(file(empty_header||autogen_headers)))"}
>
diff mbox series

Patch

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl
index 5f068377fa..2681a4cff5 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -80,6 +80,7 @@  inline functions."
 
 -doc_begin="This header file is autogenerated or empty, therefore it poses no
 risk if included more than once."
+-config=MC3R1.D4.10,reports+={safe, "first_area(text(^/\\* empty \\*/$, begin-1))"}
 -file_tag+={empty_header, "^xen/arch/arm/efi/runtime\\.h$"}
 -file_tag+={autogen_headers, "^xen/include/xen/compile\\.h$||^xen/include/generated/autoconf.h$||^xen/include/xen/hypercall-defs.h$"}
 -config=MC3R1.D4.10,reports+={safe, "all_area(all_loc(file(empty_header||autogen_headers)))"}