On 2021/11/10 18:16, Markus Armbruster wrote:
Yanan Wang <wangyana...@huawei.com> writes:

Checkpatch.pl reports errors like below for commit 9e8e393bb7. Fix it.
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 <wangyana...@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..3627fe61ad 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){ {0} };
      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){ {0} };
      unsigned int num_dies = 2;
      int i;
Why not

        SMPTestData *data = &(SMPTestData){};

?

Much simpler. Having tested {} format, it also works in zeroing the structure.
And it seems to have been mostly used in qemu. I will update.

The original double-layer braces tried to satisfy a clang compile warning:
"suggest braces around initialization of subobject [-Werror,-Wmissing-braces]". But I assume {} *without* explicit 0 in it just won't trigger the warning. (?)

Thanks,
Yanan


Reply via email to