All of lore.kernel.org
 help / color / mirror / Atom feed
* [XEN PATCH] ns16550: remove partial explicit initializer
@ 2023-12-05 16:31 Nicola Vetrini
  2023-12-05 20:12 ` Andrew Cooper
  2023-12-06  9:01 ` Jan Beulich
  0 siblings, 2 replies; 4+ messages in thread
From: Nicola Vetrini @ 2023-12-05 16:31 UTC (permalink / raw)
  To: xen-devel
  Cc: consulting, Nicola Vetrini, Andrew Cooper, George Dunlap,
	Jan Beulich, Julien Grall, Stefano Stabellini, Wei Liu

The initializer of 'ns16550_com' violates MISRA C Rule 9.3
because it explicitly initializes only the first element of the array,
but the semantics is the same if the explicit initialization is
omitted.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
In the context of the rule ("Arrays shall not be partially initialized"),
the initialization shall either be fully explicit or implicit.
---
 xen/drivers/char/ns16550.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index ddf2a48be6e7..a21c1d8c3402 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -73,7 +73,7 @@ static struct ns16550 {
     bool msi;
     const struct ns16550_config_param *param; /* Points into .init.*! */
 #endif
-} ns16550_com[2] = { { 0 } };
+} ns16550_com[2] = { };
 
 #ifdef NS16550_PCI
 struct ns16550_config {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [XEN PATCH] ns16550: remove partial explicit initializer
  2023-12-05 16:31 [XEN PATCH] ns16550: remove partial explicit initializer Nicola Vetrini
@ 2023-12-05 20:12 ` Andrew Cooper
  2023-12-06  9:01 ` Jan Beulich
  1 sibling, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2023-12-05 20:12 UTC (permalink / raw)
  To: Nicola Vetrini, xen-devel
  Cc: consulting, George Dunlap, Jan Beulich, Julien Grall,
	Stefano Stabellini, Wei Liu

On 05/12/2023 4:31 pm, Nicola Vetrini wrote:
> The initializer of 'ns16550_com' violates MISRA C Rule 9.3
> because it explicitly initializes only the first element of the array,
> but the semantics is the same if the explicit initialization is
> omitted.
>
> No functional change.
>
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [XEN PATCH] ns16550: remove partial explicit initializer
  2023-12-05 16:31 [XEN PATCH] ns16550: remove partial explicit initializer Nicola Vetrini
  2023-12-05 20:12 ` Andrew Cooper
@ 2023-12-06  9:01 ` Jan Beulich
  2023-12-06 10:14   ` Nicola Vetrini
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2023-12-06  9:01 UTC (permalink / raw)
  To: Nicola Vetrini
  Cc: consulting, Andrew Cooper, George Dunlap, Julien Grall,
	Stefano Stabellini, Wei Liu, xen-devel

On 05.12.2023 17:31, Nicola Vetrini wrote:
> --- a/xen/drivers/char/ns16550.c
> +++ b/xen/drivers/char/ns16550.c
> @@ -73,7 +73,7 @@ static struct ns16550 {

With the variable even being static, ...

>      bool msi;
>      const struct ns16550_config_param *param; /* Points into .init.*! */
>  #endif
> -} ns16550_com[2] = { { 0 } };
> +} ns16550_com[2] = { };

... what use is the initializer in the first place?

Jan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [XEN PATCH] ns16550: remove partial explicit initializer
  2023-12-06  9:01 ` Jan Beulich
@ 2023-12-06 10:14   ` Nicola Vetrini
  0 siblings, 0 replies; 4+ messages in thread
From: Nicola Vetrini @ 2023-12-06 10:14 UTC (permalink / raw)
  To: Jan Beulich
  Cc: consulting, Andrew Cooper, George Dunlap, Julien Grall,
	Stefano Stabellini, Wei Liu, xen-devel

On 2023-12-06 10:01, Jan Beulich wrote:
> On 05.12.2023 17:31, Nicola Vetrini wrote:
>> --- a/xen/drivers/char/ns16550.c
>> +++ b/xen/drivers/char/ns16550.c
>> @@ -73,7 +73,7 @@ static struct ns16550 {
> 
> With the variable even being static, ...
> 
>>      bool msi;
>>      const struct ns16550_config_param *param; /* Points into .init.*! 
>> */
>>  #endif
>> -} ns16550_com[2] = { { 0 } };
>> +} ns16550_com[2] = { };
> 
> ... what use is the initializer in the first place?
> 
> Jan

I understood it as a visual cue that the array was initialized, as it 
was before. I don't have a specific preference one way or another, but I 
see this has already been committed.

-- 
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-06 10:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-05 16:31 [XEN PATCH] ns16550: remove partial explicit initializer Nicola Vetrini
2023-12-05 20:12 ` Andrew Cooper
2023-12-06  9:01 ` Jan Beulich
2023-12-06 10:14   ` Nicola Vetrini

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.