[PATCH 2/4] xen/common: time: Fix MISRA C 2012 Rule 8.7 violation

Xenia Ragiadakou posted 4 patches 3 years, 7 months ago
There is a newer version of this series
[PATCH 2/4] xen/common: time: Fix MISRA C 2012 Rule 8.7 violation
Posted by Xenia Ragiadakou 3 years, 7 months ago
The variable __mon_lengths is referenced only in time.c.
Change its linkage from external to internal by adding the storage-class
specifier static to its definitions.

Also, this patch resolves indirectly a MISRA C 2012 Rule 8.4 violation warning.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
---
 xen/common/time.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/common/time.c b/xen/common/time.c
index 22379f4ae2..92f7b72464 100644
--- a/xen/common/time.c
+++ b/xen/common/time.c
@@ -28,7 +28,7 @@
   ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
 
 /* How many days are in each month.  */
-const unsigned short int __mon_lengths[2][12] = {
+static const unsigned short int __mon_lengths[2][12] = {
     /* Normal years.  */
     {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
     /* Leap years.  */
-- 
2.34.1
Re: [PATCH 2/4] xen/common: time: Fix MISRA C 2012 Rule 8.7 violation
Posted by Julien Grall 3 years, 7 months ago
Hi Xenia,

On 05/07/2022 22:02, Xenia Ragiadakou wrote:
> The variable __mon_lengths is referenced only in time.c.
> Change its linkage from external to internal by adding the storage-class
> specifier static to its definitions.
> 
> Also, this patch resolves indirectly a MISRA C 2012 Rule 8.4 violation warning.
> 
> Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,

> ---
>   xen/common/time.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/common/time.c b/xen/common/time.c
> index 22379f4ae2..92f7b72464 100644
> --- a/xen/common/time.c
> +++ b/xen/common/time.c
> @@ -28,7 +28,7 @@
>     ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
>   
>   /* How many days are in each month.  */
> -const unsigned short int __mon_lengths[2][12] = {
> +static const unsigned short int __mon_lengths[2][12] = {
>       /* Normal years.  */
>       {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
>       /* Leap years.  */

-- 
Julien Grall