[PATCH] Fix null_gass initializer for older versions of gcc (LP: #1549429)

Colin King colin.king at canonical.com
Wed Feb 24 18:38:17 UTC 2016


From: Colin Ian King <colin.king at canonical.com>

const fwts_acpi_gas null_gas = { 0 } causes a build failure with
older compilers, such as gcc 4.6 (on Trusty):

acpi/fadt/fadt.c: In function 'acpi_table_check_fadt_reduced_hardware':
acpi/fadt/fadt.c:447:2: error: missing initializer
  [-Werror=missing-field-initializers]
acpi/fadt/fadt.c:447:2: error: (near initialization for
  'null_gas.register_bit_width') [-Werror=missing-field-initializers]

make null_gas a static const - this will then be initialized as all
zeros just once at run time and it is compatible with older versions
of gcc too. Note this is a read-only struct, so this is fine to init
like this

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/acpi/fadt/fadt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/acpi/fadt/fadt.c b/src/acpi/fadt/fadt.c
index 6dc324e..4dba8f1 100644
--- a/src/acpi/fadt/fadt.c
+++ b/src/acpi/fadt/fadt.c
@@ -444,7 +444,7 @@ static void acpi_table_check_fadt_reduced_hardware(fwts_framework *fw)
 	const char *IS_NOT = "IS NOT";
 	bool rhw;
 	bool passed;
-	const fwts_acpi_gas null_gas = { 0 };
+	static const fwts_acpi_gas null_gas;
 	uint32_t flag_mask;
 
 	rhw = fwts_acpi_is_reduced_hardware(fadt);
-- 
2.7.0




More information about the fwts-devel mailing list