On 06/20/14 12:00, Gao, Liming wrote:
> Hi, all
> 
>   -Wno-missing-braces option is used to disable warning when the
> initialized value without braces is set into structure. To remove this
> option can detect such wrong case in source code. This patch remove it
> from the default GCC compiler option in
> BaseTools/Conf/tools_def.template. Please help review it.

(1) The patch makes sense to me, because a human should arguably prefer

                   int b[2][2] = { { 0, 1 }, { 2, 3 } };

over

                   int a[2][2] = { 0, 1, 2, 3 };

It could be a little inconvenient for machine generated code though.
(Especially that the warning will be treated as an error.) But I guess
it should be fine.

(2) The patch removes the flag from two GCC defines (GCC_ALL_CC_FLAGS
and GCC44_ALL_CC_FLAGS). In my edk2 clone there's a third, similar flag:
"*_ELFGCC_X64_CC_FLAGS". Did you leave that out deliberately?

(3) Other compilers seem to retain -Wno-missing-braces (eg. XCLANG,
XCODE). Is that intentional, or are they not modified only because it's
hard to test them? (I don't mind if the latter is the case, I'd just
like to understand.)

(4) In order to test the patch, I grabbed my existing
"Conf/tools_def.txt" and removed all instances of -Wno-missing-braces.

Then I tried to build OVMF (for both Ia32 and X64), and also
(cross-build) "ArmVExpress-FVP-AArch64" and
"ArmVExpress-RTSM-AEMv8Ax4-foundation".

The change triggers a few build errors in OVMF, and many more in the ARM
packages. Please see my attached fixes. I propose that these patches be
applied first (after review), before committing & syncing this BaseTools
change.

Thanks
Laszlo

From 05b1aae9a64b47692c58c1485cab903057ee64fc Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Fri, 20 Jun 2014 15:02:32 +0200
Subject: [PATCH 1/4] ArmPkg: add missing braces to aggregate and/or union
 initializers

Lack of these braces causes build errors when -Wno-missing-braces is
absent. Spelling out more braces also helps understanding the code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 ArmPkg/Drivers/CpuDxe/CpuMpCore.c             | 2 +-
 ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ArmPkg/Drivers/CpuDxe/CpuMpCore.c b/ArmPkg/Drivers/CpuDxe/CpuMpCore.c
index 49bc25c..04cfa6c 100644
--- a/ArmPkg/Drivers/CpuDxe/CpuMpCore.c
+++ b/ArmPkg/Drivers/CpuDxe/CpuMpCore.c
@@ -29,9 +29,9 @@ ARM_PROCESSOR_TABLE mArmProcessorTableTemplate = {
     EFI_ARM_PROCESSOR_TABLE_OEM_TABLE_ID,
     EFI_ARM_PROCESSOR_TABLE_OEM_REVISION,
     EFI_ARM_PROCESSOR_TABLE_CREATOR_ID,
     EFI_ARM_PROCESSOR_TABLE_CREATOR_REVISION,
-    0,
+    { 0 }, // Identifier
     0
   },   //ARM Processor table header
   0,   // Number of entries in ARM processor Table
   NULL // ARM Processor Table
diff --git a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
index aae9582..ede23ef 100644
--- a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
+++ b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
@@ -65,12 +65,12 @@ typedef struct {
 } SEMIHOST_DEVICE_PATH;
 
 SEMIHOST_DEVICE_PATH gDevicePath = {
   {
-    { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, sizeof (VENDOR_DEVICE_PATH), 0 },
+    { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0 } },
     EFI_CALLER_ID_GUID
   },
-  { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof (EFI_DEVICE_PATH_PROTOCOL), 0}
+  { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 } }
 };
 
 typedef struct {
   LIST_ENTRY    Link;
-- 
1.8.3.1

From a139f440837bc15d1920d90bed779e721a1fe008 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Fri, 20 Jun 2014 15:02:32 +0200
Subject: [PATCH 2/4] ArmPlatformPkg: add missing braces to aggregate and/or
 union initializers

Lack of these braces causes build errors when -Wno-missing-braces is
absent. Spelling out more braces also helps understanding the code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 .../Library/NorFlashArmVExpressLib/NorFlashArmVExpress.c   |  8 ++++----
 .../Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c    | 14 +++++++++-----
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c           | 14 +++++++++-----
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpress.c
index 6a0b319..070d517 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpress.c
@@ -25,30 +25,30 @@ NOR_FLASH_DESCRIPTION mNorFlashDevices[NOR_FLASH_DEVICE_COUNT] = {
     ARM_VE_SMB_NOR0_BASE,
     ARM_VE_SMB_NOR0_BASE,
     SIZE_256KB * 255,
     SIZE_256KB,
-    {0xE7223039, 0x5836, 0x41E1, 0xB5, 0x42, 0xD7, 0xEC, 0x73, 0x6C, 0x5E, 0x59}
+    {0xE7223039, 0x5836, 0x41E1, {0xB5, 0x42, 0xD7, 0xEC, 0x73, 0x6C, 0x5E, 0x59}}
   },
   { // BootMon non-volatile storage
     ARM_VE_SMB_NOR0_BASE,
     ARM_VE_SMB_NOR0_BASE + SIZE_256KB * 255,
     SIZE_64KB * 4,
     SIZE_64KB,
-    {0x02118005, 0x9DA7, 0x443A, 0x92, 0xD5, 0x78, 0x1F, 0x02, 0x2A, 0xED, 0xBB}
+    {0x02118005, 0x9DA7, 0x443A, {0x92, 0xD5, 0x78, 0x1F, 0x02, 0x2A, 0xED, 0xBB}}
   },
   { // UEFI
     ARM_VE_SMB_NOR1_BASE,
     ARM_VE_SMB_NOR1_BASE,
     SIZE_256KB * 255,
     SIZE_256KB,
-    {0x1F15DA3C, 0x37FF, 0x4070, 0xB4, 0x71, 0xBB, 0x4A, 0xF1, 0x2A, 0x72, 0x4A}
+    {0x1F15DA3C, 0x37FF, 0x4070, {0xB4, 0x71, 0xBB, 0x4A, 0xF1, 0x2A, 0x72, 0x4A}}
   },
   { // UEFI Variable Services non-volatile storage
     ARM_VE_SMB_NOR1_BASE,
     ARM_VE_SMB_NOR1_BASE + SIZE_256KB * 255,
     SIZE_64KB * 3, //FIXME: Set 3 blocks because I did not succeed to copy 4 blocks into the ARM Versatile Express NOR Flash in the last NOR Flash. It should be 4 blocks
     SIZE_64KB,
-    {0xCC2CBF29, 0x1498, 0x4CDD, 0x81, 0x71, 0xF8, 0xB6, 0xB4, 0x1D, 0x09, 0x09}
+    {0xCC2CBF29, 0x1498, 0x4CDD, {0x81, 0x71, 0xF8, 0xB6, 0xB4, 0x1D, 0x09, 0x09}}
   }
 };
 
 EFI_STATUS
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
index b423364..77591a3 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
@@ -42,9 +42,9 @@ LCD_INSTANCE mLcdTemplate = {
     0, // Version
     0, // HorizontalResolution
     0, // VerticalResolution
     PixelBltOnly, // PixelFormat
-    0, // PixelInformation
+    { 0 }, // PixelInformation
     0, // PixelsPerScanLine
   },
   {
     0, // MaxMode;
@@ -63,20 +63,24 @@ LCD_INSTANCE mLcdTemplate = {
   { // DevicePath
     {
       {
         HARDWARE_DEVICE_PATH, HW_VENDOR_DP,
-        (UINT8) (sizeof(VENDOR_DEVICE_PATH)),
-        (UINT8) ((sizeof(VENDOR_DEVICE_PATH)) >> 8),
+        {
+          (UINT8) (sizeof(VENDOR_DEVICE_PATH)),
+          (UINT8) ((sizeof(VENDOR_DEVICE_PATH)) >> 8)
+        }
       },
       // Hardware Device Path for Lcd
       EFI_CALLER_ID_GUID // Use the driver's GUID
     },
 
     {
       END_DEVICE_PATH_TYPE,
       END_ENTIRE_DEVICE_PATH_SUBTYPE,
-      sizeof(EFI_DEVICE_PATH_PROTOCOL),
-      0
+      {
+        sizeof(EFI_DEVICE_PATH_PROTOCOL),
+        0
+      }
     }
   },
   (EFI_EVENT) NULL // ExitBootServicesEvent
 };
diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
index 4fac201..4ea627f 100644
--- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
+++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
@@ -85,18 +85,22 @@ NOR_FLASH_INSTANCE  mNorFlashInstanceTemplate = {
     {
       {
         HARDWARE_DEVICE_PATH,
         HW_VENDOR_DP,
-        (UINT8)( sizeof(VENDOR_DEVICE_PATH)      ),
-        (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8),
+        {
+          (UINT8)( sizeof(VENDOR_DEVICE_PATH)      ),
+          (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8)
+        }
       },
-      { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, // GUID ... NEED TO BE FILLED
+      { 0x0 }, // GUID ... NEED TO BE FILLED
     },
     {
       END_DEVICE_PATH_TYPE,
       END_ENTIRE_DEVICE_PATH_SUBTYPE,
-      sizeof (EFI_DEVICE_PATH_PROTOCOL),
-      0
+      {
+        sizeof (EFI_DEVICE_PATH_PROTOCOL),
+        0
+      }
     }
     } // DevicePath
 };
 
-- 
1.8.3.1

From c76abc1825492111b0d28c1379f1391979454e53 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Fri, 20 Jun 2014 15:02:32 +0200
Subject: [PATCH 3/4] EmbeddedPkg: add missing braces to aggregate and/or union
 initializers

Lack of these braces causes build errors when -Wno-missing-braces is
absent. Spelling out more braces also helps understanding the code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c | 6 ++++--
 EmbeddedPkg/SerialDxe/SerialIo.c                                 | 6 +++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
index 04ad9c0..9e85f4f 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
+++ b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
@@ -45,10 +45,12 @@ STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate =
   }, // Node1
   {
     END_DEVICE_PATH_TYPE,
     END_ENTIRE_DEVICE_PATH_SUBTYPE,
-    sizeof (EFI_DEVICE_PATH_PROTOCOL),
-    0
+    {
+      sizeof (EFI_DEVICE_PATH_PROTOCOL),
+      0
+    } // Length[2]
   } // End
 };
 
 EFI_STATUS
diff --git a/EmbeddedPkg/SerialDxe/SerialIo.c b/EmbeddedPkg/SerialDxe/SerialIo.c
index 288f353..a0b227e 100644
--- a/EmbeddedPkg/SerialDxe/SerialIo.c
+++ b/EmbeddedPkg/SerialDxe/SerialIo.c
@@ -36,20 +36,20 @@ typedef struct {
 } SIMPLE_TEXT_OUT_DEVICE_PATH;
 
 SIMPLE_TEXT_OUT_DEVICE_PATH mDevicePath = {
   {
-    { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, sizeof (VENDOR_DEVICE_PATH), 0},
+    { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0 } },
     EFI_CALLER_ID_GUID // Use the drivers GUID
   },
   {
-    { MESSAGING_DEVICE_PATH, MSG_UART_DP, sizeof (UART_DEVICE_PATH), 0},
+    { MESSAGING_DEVICE_PATH, MSG_UART_DP, { sizeof (UART_DEVICE_PATH), 0 } },
     0,        // Reserved
     FixedPcdGet64 (PcdUartDefaultBaudRate),   // BaudRate
     FixedPcdGet8 (PcdUartDefaultDataBits),    // DataBits
     FixedPcdGet8 (PcdUartDefaultParity),      // Parity (N)
     FixedPcdGet8 (PcdUartDefaultStopBits)     // StopBits
   },
-  { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof (EFI_DEVICE_PATH_PROTOCOL), 0}
+  { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 } }
 };
 
 EFI_HANDLE  gHandle = NULL;
 
-- 
1.8.3.1

From c429c4ca19774da8fe232b60be8879f0aca65e94 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Fri, 20 Jun 2014 15:02:32 +0200
Subject: [PATCH 4/4] OvmfPkg: add missing braces to aggregate and/or union
 initializers

Lack of these braces causes build errors when -Wno-missing-braces is
absent. Spelling out more braces also helps understanding the code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbInfo.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbInfo.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbInfo.c
index 72845f9..62f9158 100644
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbInfo.c
+++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbInfo.c
@@ -89,19 +89,23 @@ EFI_FVB_MEDIA_INFO  mPlatformFvbMediaInfo[] = {
         0,
       },  // Reserved[1]
       2,  // Revision
       {
-       (FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
-        FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
-        FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
-        FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdOvmfFirmwareBlockSize),
-        FixedPcdGet32 (PcdOvmfFirmwareBlockSize),
-      }
+        {
+          (FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
+           FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
+           FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
+           FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdOvmfFirmwareBlockSize),
+          FixedPcdGet32 (PcdOvmfFirmwareBlockSize),
+        }
+      } // BlockMap[1]
     },
     {
-      0,
-      0
-    }
+      {
+        0,
+        0
+      }
+    }  // End[1]
   }
 };
 
 EFI_STATUS
-- 
1.8.3.1

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
edk2-buildtools-devel mailing list
edk2-buildtools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-buildtools-devel

Reply via email to