[PATCH] xen/arm: efi-boot misra rule 4.1 fix

Stefano Stabellini posted 1 patch 1 year, 5 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
[PATCH] xen/arm: efi-boot misra rule 4.1 fix
Posted by Stefano Stabellini 1 year, 5 months ago
We have 3 violations of MISRA C Rule 4.1 ("Octal and hexadecimal escape
sequences shall be terminated") in xen/arch/arm/efi/efi-boot.h. Fix
them.

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>

diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
index 43a836c3a7..822c0a1462 100644
--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -542,7 +542,7 @@ static void __init efi_arch_handle_module(const struct file *file,
 
     if ( file == &ramdisk )
     {
-        char ramdisk_compat[] = "multiboot,ramdisk\0multiboot,module";
+        char ramdisk_compat[] = "multiboot,ramdisk\0" "multiboot,module";
         node = fdt_add_subnode(fdt, chosen, "ramdisk");
         if ( node < 0 )
             blexit(L"Unable to add ramdisk FDT node.");
@@ -555,7 +555,7 @@ static void __init efi_arch_handle_module(const struct file *file,
     }
     else if ( file == &xsm )
     {
-        char xsm_compat[] = "xen,xsm-policy\0multiboot,module";
+        char xsm_compat[] = "xen,xsm-policy\0" "multiboot,module";
         node = fdt_add_subnode(fdt, chosen, "xsm");
         if ( node < 0 )
             blexit(L"Unable to add xsm FDT node.");
@@ -568,7 +568,7 @@ static void __init efi_arch_handle_module(const struct file *file,
     }
     else if ( file == &kernel )
     {
-        char kernel_compat[] = "multiboot,kernel\0multiboot,module";
+        char kernel_compat[] = "multiboot,kernel\0" "multiboot,module";
         node = fdt_add_subnode(fdt, chosen, "kernel");
         if ( node < 0 )
             blexit(L"Unable to add dom0 FDT node.");
Re: [PATCH] xen/arm: efi-boot misra rule 4.1 fix
Posted by Luca Fancellu 1 year, 5 months ago

> On 9 Dec 2022, at 00:41, Stefano Stabellini <sstabellini@kernel.org> wrote:
> 
> We have 3 violations of MISRA C Rule 4.1 ("Octal and hexadecimal escape
> sequences shall be terminated") in xen/arch/arm/efi/efi-boot.h. Fix
> them.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>

Hi Stefano,

I’ve checked also with coverity and it solves the violation.

Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>


Re: [PATCH] xen/arm: efi-boot misra rule 4.1 fix
Posted by Jan Beulich 1 year, 5 months ago
On 09.12.2022 01:41, Stefano Stabellini wrote:
> We have 3 violations of MISRA C Rule 4.1 ("Octal and hexadecimal escape
> sequences shall be terminated") in xen/arch/arm/efi/efi-boot.h. Fix
> them.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>

While I certainly agree, I wonder if you don't want to correct style
(missing blank line after every one of these declarations) as well as
data placement (all three should imo be static __initconst) at the
same time.

Jan

> --- a/xen/arch/arm/efi/efi-boot.h
> +++ b/xen/arch/arm/efi/efi-boot.h
> @@ -542,7 +542,7 @@ static void __init efi_arch_handle_module(const struct file *file,
>  
>      if ( file == &ramdisk )
>      {
> -        char ramdisk_compat[] = "multiboot,ramdisk\0multiboot,module";
> +        char ramdisk_compat[] = "multiboot,ramdisk\0" "multiboot,module";
>          node = fdt_add_subnode(fdt, chosen, "ramdisk");
>          if ( node < 0 )
>              blexit(L"Unable to add ramdisk FDT node.");
> @@ -555,7 +555,7 @@ static void __init efi_arch_handle_module(const struct file *file,
>      }
>      else if ( file == &xsm )
>      {
> -        char xsm_compat[] = "xen,xsm-policy\0multiboot,module";
> +        char xsm_compat[] = "xen,xsm-policy\0" "multiboot,module";
>          node = fdt_add_subnode(fdt, chosen, "xsm");
>          if ( node < 0 )
>              blexit(L"Unable to add xsm FDT node.");
> @@ -568,7 +568,7 @@ static void __init efi_arch_handle_module(const struct file *file,
>      }
>      else if ( file == &kernel )
>      {
> -        char kernel_compat[] = "multiboot,kernel\0multiboot,module";
> +        char kernel_compat[] = "multiboot,kernel\0" "multiboot,module";
>          node = fdt_add_subnode(fdt, chosen, "kernel");
>          if ( node < 0 )
>              blexit(L"Unable to add dom0 FDT node.");
>
Re: [PATCH] xen/arm: efi-boot misra rule 4.1 fix
Posted by Julien Grall 1 year, 5 months ago
Hi,

On 09/12/2022 09:04, Jan Beulich wrote:
> On 09.12.2022 01:41, Stefano Stabellini wrote:
>> We have 3 violations of MISRA C Rule 4.1 ("Octal and hexadecimal escape
>> sequences shall be terminated") in xen/arch/arm/efi/efi-boot.h. Fix
>> them.
>>
>> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
> 
> While I certainly agree, I wonder if you don't want to correct style
> (missing blank line after every one of these declarations) as well as
> data placement (all three should imo be static __initconst) at the
> same time.

+1. And use 'const' as well :).

Cheers,

-- 
Julien Grall