qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 2/2] tests/unit/test-smp-parse: Fix a check-patch complain


From: Andrew Jones
Subject: Re: [PATCH v2 2/2] tests/unit/test-smp-parse: Fix a check-patch complain
Date: Thu, 11 Nov 2021 09:43:52 +0100

On Thu, Nov 11, 2021 at 10:44:29AM +0800, Yanan Wang wrote:
> Checkpatch.pl reports errors like below for commit 9e8e393bb7.
> Let's fix it with a simpler format.
> ERROR: space required after that close brace '}'
> +    SMPTestData *data = &(SMPTestData){{ }};
> 
> Fixes: 9e8e393bb7 ("tests/unit: Add an unit test for smp parsing")
> Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
> ---
>  tests/unit/test-smp-parse.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c
> index 872512aa37..7805a34b29 100644
> --- a/tests/unit/test-smp-parse.c
> +++ b/tests/unit/test-smp-parse.c
> @@ -514,7 +514,7 @@ static void test_generic(void)
>      Object *obj = smp_test_machine_init();
>      MachineState *ms = MACHINE(obj);
>      MachineClass *mc = MACHINE_GET_CLASS(obj);
> -    SMPTestData *data = &(SMPTestData){{ }};
> +    SMPTestData *data = &(SMPTestData){};
>      int i;
>  
>      for (i = 0; i < ARRAY_SIZE(data_generic_valid); i++) {
> @@ -548,7 +548,7 @@ static void test_with_dies(void)
>      Object *obj = smp_test_machine_init();
>      MachineState *ms = MACHINE(obj);
>      MachineClass *mc = MACHINE_GET_CLASS(obj);
> -    SMPTestData *data = &(SMPTestData){{ }};
> +    SMPTestData *data = &(SMPTestData){};
>      unsigned int num_dies = 2;
>      int i;
>  
> -- 
> 2.19.1
>

I just did some googling to refresh my memory on this, because I recall
{0} being recommended at some point. From what I can tell, {} is ok for
gcc, maybe also clang, but {0} is ANSI. The reasoning was that {} should
not be empty, and since element names are not required, '0' is enough to
assign the first element to zero. Also, as it's not required to list
each element, then that's enough for the whole struct. That said, {}
seems to be more popular, so we can probably assume the tools we support
also support it.

Reviewed-by: Andrew Jones <drjones@redhat.com>

Thanks,
drew




reply via email to

[Prev in Thread] Current Thread [Next in Thread]