[XEN PATCH v2 05/13] xen/device-tree: fix violations of MISRA C:2012 Rule 7.2

Simone Ballarin posted 13 patches 2 years, 7 months ago
There is a newer version of this series
[XEN PATCH v2 05/13] xen/device-tree: fix violations of MISRA C:2012 Rule 7.2
Posted by Simone Ballarin 2 years, 7 months ago
From: Gianluca Luparini <gianluca.luparini@bugseng.com>

The xen sources contains violations of MISRA C:2012 Rule 7.2 whose
headline states:
"A 'u' or 'U' suffix shall be applied to all integer constants
that are represented in an unsigned type".

Add the 'U' suffix to integers literals with unsigned type and also to other
literals used in the same contexts or near violations, when their positive
nature is immediately clear. The latter changes are done for the sake of
uniformity.

Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
Signed-off-by: Gianluca Luparini <gianluca.luparini@bugseng.com>
---
Changes in v2:
- change commit title to the right one
- change commit message
- change maintainers in Cc
- remove changes in 'libfdt'
---
 xen/common/device_tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 8da1052911..0677193ab3 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -2115,7 +2115,7 @@ static void __init __unflatten_device_tree(const void *fdt,
     /* Allocate memory for the expanded device tree */
     mem = (unsigned long)_xmalloc (size + 4, __alignof__(struct dt_device_node));
 
-    ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
+    ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeefU);
 
     dt_dprintk("  unflattening %lx...\n", mem);
 
@@ -2125,7 +2125,7 @@ static void __init __unflatten_device_tree(const void *fdt,
     if ( be32_to_cpup((__be32 *)start) != FDT_END )
         printk(XENLOG_WARNING "Weird tag at end of tree: %08x\n",
                   *((u32 *)start));
-    if ( be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeef )
+    if ( be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeefU )
         printk(XENLOG_WARNING "End of tree marker overwritten: %08x\n",
                   be32_to_cpu(((__be32 *)mem)[size / 4]));
     *allnextp = NULL;
-- 
2.41.0
Re: [XEN PATCH v2 05/13] xen/device-tree: fix violations of MISRA C:2012 Rule 7.2
Posted by Julien Grall 2 years, 7 months ago
Hi,

On 05/07/2023 16:26, Simone Ballarin wrote:
> From: Gianluca Luparini <gianluca.luparini@bugseng.com>

This suggest the author is Gianluca but...

> The xen sources contains violations of MISRA C:2012 Rule 7.2 whose
> headline states:
> "A 'u' or 'U' suffix shall be applied to all integer constants
> that are represented in an unsigned type".
> 
> Add the 'U' suffix to integers literals with unsigned type and also to other
> literals used in the same contexts or near violations, when their positive
> nature is immediately clear. The latter changes are done for the sake of
> uniformity.
> 
> Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>

... the first signed-off-by is yours. So who is the author?

More generally, there tags are order chronogically. So if Gianluca is 
the author then it should be the first Signed-off-by. Then it is yours.

This will be followed-by the Acked-by/Reviewed-by tags.

The same remark goes for the rest of the series.

Cheers,

-- 
Julien Grall
Re: [XEN PATCH v2 05/13] xen/device-tree: fix violations of MISRA C:2012 Rule 7.2
Posted by Stefano Stabellini 2 years, 7 months ago
On Wed, 5 Jul 2023, Simone Ballarin wrote:
> From: Gianluca Luparini <gianluca.luparini@bugseng.com>
> 
> The xen sources contains violations of MISRA C:2012 Rule 7.2 whose
> headline states:
> "A 'u' or 'U' suffix shall be applied to all integer constants
> that are represented in an unsigned type".
> 
> Add the 'U' suffix to integers literals with unsigned type and also to other
> literals used in the same contexts or near violations, when their positive
> nature is immediately clear. The latter changes are done for the sake of
> uniformity.
> 
> Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
> Signed-off-by: Gianluca Luparini <gianluca.luparini@bugseng.com>

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


> ---
> Changes in v2:
> - change commit title to the right one
> - change commit message
> - change maintainers in Cc
> - remove changes in 'libfdt'
> ---
>  xen/common/device_tree.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
> index 8da1052911..0677193ab3 100644
> --- a/xen/common/device_tree.c
> +++ b/xen/common/device_tree.c
> @@ -2115,7 +2115,7 @@ static void __init __unflatten_device_tree(const void *fdt,
>      /* Allocate memory for the expanded device tree */
>      mem = (unsigned long)_xmalloc (size + 4, __alignof__(struct dt_device_node));
>  
> -    ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
> +    ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeefU);
>  
>      dt_dprintk("  unflattening %lx...\n", mem);
>  
> @@ -2125,7 +2125,7 @@ static void __init __unflatten_device_tree(const void *fdt,
>      if ( be32_to_cpup((__be32 *)start) != FDT_END )
>          printk(XENLOG_WARNING "Weird tag at end of tree: %08x\n",
>                    *((u32 *)start));
> -    if ( be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeef )
> +    if ( be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeefU )
>          printk(XENLOG_WARNING "End of tree marker overwritten: %08x\n",
>                    be32_to_cpu(((__be32 *)mem)[size / 4]));
>      *allnextp = NULL;
> -- 
> 2.41.0
>
Re: [XEN PATCH v2 05/13] xen/device-tree: fix violations of MISRA C:2012 Rule 7.2
Posted by Luca Fancellu 2 years, 7 months ago

> On 5 Jul 2023, at 16:26, Simone Ballarin <simone.ballarin@bugseng.com> wrote:
> 
> From: Gianluca Luparini <gianluca.luparini@bugseng.com>
> 
> The xen sources contains violations of MISRA C:2012 Rule 7.2 whose
> headline states:
> "A 'u' or 'U' suffix shall be applied to all integer constants
> that are represented in an unsigned type".
> 
> Add the 'U' suffix to integers literals with unsigned type and also to other
> literals used in the same contexts or near violations, when their positive
> nature is immediately clear. The latter changes are done for the sake of
> uniformity.
> 
> Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
> Signed-off-by: Gianluca Luparini <gianluca.luparini@bugseng.com>

Looks good to me

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

> ---
> Changes in v2:
> - change commit title to the right one
> - change commit message
> - change maintainers in Cc
> - remove changes in 'libfdt'
> ---
> xen/common/device_tree.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
> index 8da1052911..0677193ab3 100644
> --- a/xen/common/device_tree.c
> +++ b/xen/common/device_tree.c
> @@ -2115,7 +2115,7 @@ static void __init __unflatten_device_tree(const void *fdt,
>     /* Allocate memory for the expanded device tree */
>     mem = (unsigned long)_xmalloc (size + 4, __alignof__(struct dt_device_node));
> 
> -    ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
> +    ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeefU);
> 
>     dt_dprintk("  unflattening %lx...\n", mem);
> 
> @@ -2125,7 +2125,7 @@ static void __init __unflatten_device_tree(const void *fdt,
>     if ( be32_to_cpup((__be32 *)start) != FDT_END )
>         printk(XENLOG_WARNING "Weird tag at end of tree: %08x\n",
>                   *((u32 *)start));
> -    if ( be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeef )
> +    if ( be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeefU )
>         printk(XENLOG_WARNING "End of tree marker overwritten: %08x\n",
>                   be32_to_cpu(((__be32 *)mem)[size / 4]));
>     *allnextp = NULL;
> -- 
> 2.41.0
> 
>