From patchwork Mon Jul 30 18:30:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 951257 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41fSnR0KZ0z9s1R; Tue, 31 Jul 2018 04:31:06 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fkCwg-0002tg-NV; Mon, 30 Jul 2018 18:31:02 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fkCwf-0002sM-D3 for fwts-devel@lists.ubuntu.com; Mon, 30 Jul 2018 18:31:01 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fkCwf-0006rf-3r; Mon, 30 Jul 2018 18:31:01 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 2/7] fwts_uefi.h: replace _Pragmas with abstracted pragma macros Date: Mon, 30 Jul 2018 19:30:54 +0100 Message-Id: <20180730183059.28039-3-colin.king@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730183059.28039-1-colin.king@canonical.com> References: <20180730183059.28039-1-colin.king@canonical.com> MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/lib/include/fwts_uefi.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h index 686af8d2..1dc34a94 100644 --- a/src/lib/include/fwts_uefi.h +++ b/src/lib/include/fwts_uefi.h @@ -20,10 +20,8 @@ #ifndef __FWTS_UEFI_H__ #define __FWTS_UEFI_H__ -#if defined(__GNUC__) && (__GNUC__ > 7) -_Pragma("GCC diagnostic push") -_Pragma("GCC diagnostic ignored \"-Wpacked-not-aligned\"") -#endif +PRAGMA_PUSH +PRAGMA_PACK_WARN_OFF #define FWTS_UEFI_LOAD_OPTION_ACTIVE 0x00000001 #define FWTS_UEFI_LOAD_OPTION_FORCE_RECONNECT 0x00000002 @@ -661,8 +659,6 @@ char *fwts_uefi_attribute_info(uint32_t attr); bool fwts_uefi_efivars_iface_exist(void); -#if defined(__GNUC__) && (__GNUC__ > 7) -_Pragma("GCC diagnostic pop") -#endif +PRAGMA_POP #endif From patchwork Mon Jul 30 18:30:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 951261 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41fSnR0QKTz9s2M; Tue, 31 Jul 2018 04:31:06 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fkCwh-0002uT-Sx; Mon, 30 Jul 2018 18:31:03 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fkCwf-0002st-Ru for fwts-devel@lists.ubuntu.com; Mon, 30 Jul 2018 18:31:01 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fkCwf-0006rj-It; Mon, 30 Jul 2018 18:31:01 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 3/7] Wrap ACPI_ROOT_OBJECT with PRAGMA_NULL_PTR_MATH for clang builds Date: Mon, 30 Jul 2018 19:30:55 +0100 Message-Id: <20180730183059.28039-4-colin.king@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730183059.28039-1-colin.king@canonical.com> References: <20180730183059.28039-1-colin.king@canonical.com> MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King The ACPI_ROOT_OBJECT uses a gcc-ism with null pointer arithmetic which makes clang choke, so add a pragma to disable this warning for non-gcc builds. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/acpi/madt/madt.c | 3 +++ src/sbbr/acpitables/acpitables.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/acpi/madt/madt.c b/src/acpi/madt/madt.c index 883d5847..bd2669b6 100644 --- a/src/acpi/madt/madt.c +++ b/src/acpi/madt/madt.c @@ -401,8 +401,11 @@ static int madt_init(fwts_framework *fw) if (fwts_acpica_init(fw) != FWTS_OK) return FWTS_ERROR; +PRAGMA_PUSH +PRAGMA_NULL_PTR_MATH AcpiWalkNamespace(0x0c, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, madt_processor_handler, NULL, NULL, NULL); +PRAGMA_POP AcpiGetDevices("ACPI0007", madt_processor_handler, NULL, NULL); return (spec_data) ? FWTS_OK : FWTS_ERROR; diff --git a/src/sbbr/acpitables/acpitables.c b/src/sbbr/acpitables/acpitables.c index d40c164d..72ce743c 100644 --- a/src/sbbr/acpitables/acpitables.c +++ b/src/sbbr/acpitables/acpitables.c @@ -98,9 +98,12 @@ static int acpi_table_sbbr_namespace_check_test1(fwts_framework *fw) if (fwts_acpica_init(fw) != FWTS_OK) return FWTS_ERROR; +PRAGMA_PUSH +PRAGMA_NULL_PTR_MATH /* Searching for all processor devices in the namespace. */ AcpiWalkNamespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, processor_handler, NULL, NULL, (void **)&error_count); +PRAGMA_POP /* Deinitializing ACPICA, if we don't call this the terminal will break on exit. */ fwts_acpica_deinit(); From patchwork Mon Jul 30 18:30:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 951259 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41fSnR0G4Pz9s0R; Tue, 31 Jul 2018 04:31:06 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fkCwi-0002uY-14; Mon, 30 Jul 2018 18:31:04 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fkCwg-0002tE-Co for fwts-devel@lists.ubuntu.com; Mon, 30 Jul 2018 18:31:02 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fkCwg-0006ro-1J; Mon, 30 Jul 2018 18:31:02 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 4/7] lib/src/fwts_acpi_tables: disable clang warning Date: Mon, 30 Jul 2018 19:30:56 +0100 Message-Id: <20180730183059.28039-5-colin.king@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730183059.28039-1-colin.king@canonical.com> References: <20180730183059.28039-1-colin.king@canonical.com> MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King clang warns when we take the address of an object inside a packed structure. Disable this warning as I believe this is OK for architectures that perform this operation. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/lib/src/fwts_acpi_tables.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c index c7ba59be..f28ed60a 100644 --- a/src/lib/src/fwts_acpi_tables.c +++ b/src/lib/src/fwts_acpi_tables.c @@ -393,10 +393,13 @@ static int fwts_acpi_handle_fadt( /* Determine FACS addr and load it. * Will ignore the missing FACS in the hardware-reduced mode. */ +PRAGMA_PUSH +PRAGMA_PACK_WARN_OFF result = fwts_acpi_handle_fadt_tables(fw, fadt, "FACS", "FIRMWARE_CTRL", "X_FIRMWARE_CTRL", &fadt->firmware_control, &fadt->x_firmware_ctrl, provenance); +PRAGMA_POP if (result != FWTS_OK) { if ((result == FWTS_NULL_POINTER) && fwts_acpi_is_reduced_hardware(fadt)) { @@ -408,12 +411,15 @@ static int fwts_acpi_handle_fadt( } } /* Determine DSDT addr and load it */ +PRAGMA_PUSH +PRAGMA_PACK_WARN_OFF if (fwts_acpi_handle_fadt_tables(fw, fadt, "DSDT", "DSTD", "X_DSDT", &fadt->dsdt, &fadt->x_dsdt, provenance) != FWTS_OK) { fwts_log_error(fw, "Failed to load DSDT."); return FWTS_ERROR; } +PRAGMA_POP return FWTS_OK; } From patchwork Mon Jul 30 18:30:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 951264 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41fSnX0LTbz9ryl; Tue, 31 Jul 2018 04:31:12 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fkCwm-0002xN-Un; Mon, 30 Jul 2018 18:31:08 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fkCwg-0002tY-UN for fwts-devel@lists.ubuntu.com; Mon, 30 Jul 2018 18:31:02 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fkCwg-0006sM-GA; Mon, 30 Jul 2018 18:31:02 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 5/7] lib: fwts_coreboot_cbmem.c: initialize all fields in array of structs Date: Mon, 30 Jul 2018 19:30:57 +0100 Message-Id: <20180730183059.28039-6-colin.king@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730183059.28039-1-colin.king@canonical.com> References: <20180730183059.28039-1-colin.king@canonical.com> MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King This gcc'ism needs to be changed so that clang will cleanly build without warnings. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/lib/src/fwts_coreboot_cbmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/src/fwts_coreboot_cbmem.c b/src/lib/src/fwts_coreboot_cbmem.c index ae9276d9..3add0871 100644 --- a/src/lib/src/fwts_coreboot_cbmem.c +++ b/src/lib/src/fwts_coreboot_cbmem.c @@ -267,7 +267,7 @@ static ssize_t memconsole_coreboot_read(struct cbmem_console *con, char *buf, si struct seg { /* describes ring buffer segments in logical order */ uint32_t phys; /* physical offset from start of mem buffer */ uint32_t len; /* length of segment */ - } seg[2] = { {0}, {0} }; + } seg[2] = { { 0, 0 }, { 0, 0 } }; size_t done = 0; unsigned int i; From patchwork Mon Jul 30 18:30:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 951262 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41fSnS4dcjz9s2x; Tue, 31 Jul 2018 04:31:08 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fkCwk-0002v4-3p; Mon, 30 Jul 2018 18:31:06 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fkCwh-0002tz-8z for fwts-devel@lists.ubuntu.com; Mon, 30 Jul 2018 18:31:03 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fkCwg-0006sQ-VJ; Mon, 30 Jul 2018 18:31:03 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 6/7] uefi: uefirtauthvar: don't logically or a constant operand. Date: Mon, 30 Jul 2018 19:30:58 +0100 Message-Id: <20180730183059.28039-7-colin.king@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730183059.28039-1-colin.king@canonical.com> References: <20180730183059.28039-1-colin.king@canonical.com> MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King Cast constant operands to bool type so that the logical or does not result in a clang warning. Fixes clang build warning: uefi/uefirtauthvar/uefirtauthvar.c:148:65: error: use of logical '||' with constant operand [-Werror,-Wconstant-logical-operand] Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/uefi/uefirtauthvar/uefirtauthvar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c index c2031741..7384ae3d 100644 --- a/src/uefi/uefirtauthvar/uefirtauthvar.c +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c @@ -145,9 +145,9 @@ static int uefirtauthvar_deinit(fwts_framework *fw) static int check_fw_support(fwts_framework *fw, uint64_t status) { if ((status == EFI_INVALID_PARAMETER) && - ((attributes & FWTS_UEFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) || - (attributes & FWTS_UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) || - (attributes & FWTS_UEFI_VARIABLE_APPEND_WRITE))) { + ((bool)(attributes & FWTS_UEFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) || + (bool)(attributes & FWTS_UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) || + (bool)(attributes & FWTS_UEFI_VARIABLE_APPEND_WRITE))) { fwts_uefi_print_status_info(fw, status); fwts_skipped(fw, "EFI_INVALID_PARAMETER shall be returned, " From patchwork Mon Jul 30 18:30:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 951263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41fSnS5xsVz9s37; Tue, 31 Jul 2018 04:31:08 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fkCwk-0002vA-5I; Mon, 30 Jul 2018 18:31:06 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fkCwh-0002uK-Nw for fwts-devel@lists.ubuntu.com; Mon, 30 Jul 2018 18:31:03 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fkCwh-0006sU-EN; Mon, 30 Jul 2018 18:31:03 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 7/7] dmi: dmicheck: remove redundant array fwts_dmi_chassis_type Date: Mon, 30 Jul 2018 19:30:59 +0100 Message-Id: <20180730183059.28039-8-colin.king@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730183059.28039-1-colin.king@canonical.com> References: <20180730183059.28039-1-colin.king@canonical.com> MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King Array fwts_dmi_chassis_type is only being used to find the maximum number of chassis types. Remove this array and the fwts_chassis_type_map struct declaration and replace with a macro for the maximum number of chassis types. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/dmi/dmicheck/dmicheck.c | 48 +---------------------------------- src/lib/include/fwts_smbios.h | 3 +++ 2 files changed, 4 insertions(+), 47 deletions(-) diff --git a/src/dmi/dmicheck/dmicheck.c b/src/dmi/dmicheck/dmicheck.c index a911b437..89288ade 100644 --- a/src/dmi/dmicheck/dmicheck.c +++ b/src/dmi/dmicheck/dmicheck.c @@ -77,11 +77,6 @@ typedef struct { uint16_t new; } fwts_dmi_version; -typedef struct { - const char *name; - uint8_t original; -} fwts_chassis_type_map; - typedef struct { uint8_t type; uint8_t offset; @@ -212,46 +207,6 @@ static const char *uuid_patterns[] = { NULL, }; -static const fwts_chassis_type_map fwts_dmi_chassis_type[] = { - { "Invalid", FWTS_SMBIOS_CHASSIS_INVALID }, - { "Other", FWTS_SMBIOS_CHASSIS_OTHER }, - { "Unknown", FWTS_SMBIOS_CHASSIS_UNKNOWN }, - { "Desktop", FWTS_SMBIOS_CHASSIS_DESKTOP }, - { "Low Profile Desktop",FWTS_SMBIOS_CHASSIS_LOW_PROFILE_DESKTOP }, - { "Pizza Box", FWTS_SMBIOS_CHASSIS_PIZZA_BOX }, - { "Mini Tower", FWTS_SMBIOS_CHASSIS_MINI_TOWER }, - { "Chassis Tower", FWTS_SMBIOS_CHASSIS_TOWER }, - { "Portable", FWTS_SMBIOS_CHASSIS_PORTABLE }, - { "Laptop", FWTS_SMBIOS_CHASSIS_LAPTOP }, - { "Notebook", FWTS_SMBIOS_CHASSIS_NOTEBOOK }, - { "Handheld", FWTS_SMBIOS_CHASSIS_HANDHELD }, - { "Docking Station", FWTS_SMBIOS_CHASSIS_DOCKING_STATION }, - { "All In One", FWTS_SMBIOS_CHASSIS_ALL_IN_ONE }, - { "Sub Notebook", FWTS_SMBIOS_CHASSIS_SUB_NOTEBOOK }, - { "Space Saving", FWTS_SMBIOS_CHASSIS_SPACE_SAVING }, - { "Lunch Box", FWTS_SMBIOS_CHASSIS_LUNCH_BOX}, - { "Server Chassis", FWTS_SMBIOS_CHASSIS_MAIN_SERVER_CHASSIS }, - { "Expansion Chassis", FWTS_SMBIOS_CHASSIS_EXPANISON_CHASSIS }, - { "Sub Chassis", FWTS_SMBIOS_CHASSIS_SUB_CHASSIS }, - { "Bus Expansion Chassis", FWTS_SMBIOS_CHASSIS_BUS_EXPANSION_CHASSIS }, - { "Peripheral Chassis", FWTS_SMBIOS_CHASSIS_PERIPHERAL_CHASSIS }, - { "Raid Chassis", FWTS_SMBIOS_CHASSIS_RAID_CHASSIS }, - { "Rack Mount Chassis", FWTS_SMBIOS_CHASSIS_RACK_MOUNT_CHASSIS }, - { "Sealed Case PC", FWTS_SMBIOS_CHASSIS_SEALED_CASE_PC }, - { "Multi System Chassis",FWTS_SMBIOS_CHASSIS_MULTI_SYSTEM_CHASSIS }, - { "Compact PCI", FWTS_SMBIOS_CHASSIS_COMPACT_PCI }, - { "Advanced TCA", FWTS_SMBIOS_CHASSIS_ADVANCED_TCA }, - { "Blade", FWTS_SMBIOS_CHASSIS_BLADE }, - { "Enclosure", FWTS_SMBIOS_CHASSIS_BLADE_ENCLOSURE }, - { "Tablet", FWTS_SMBIOS_CHASSIS_TABLET }, - { "Convertible", FWTS_SMBIOS_CHASSIS_CONVERTIBLE }, - { "Detachable", FWTS_SMBIOS_CHASSIS_DETACHABLE }, - { "IoT Gateway", FWTS_SMBIOS_CHASSIS_IOT_GATEWAY }, - { "Embedded PC", FWTS_SMBIOS_CHASSIS_EMBEDDED_PC }, - { "Mini PC", FWTS_SMBIOS_CHASSIS_MINI_PC }, - { "Stick PC", FWTS_SMBIOS_CHASSIS_STICK_PC }, -}; - /* Remapping table from buggy version numbers to correct values */ static const fwts_dmi_version dmi_versions[] = { { 0x021f, 0x0203 }, @@ -1180,8 +1135,7 @@ static void dmicheck_entry(fwts_framework *fw, dmi_str_check(fw, table, addr, "Manufacturer", hdr, 0x4); dmi_min_max_mask_uint8_check(fw, table, addr, "Chassis Type", hdr, 0x5, 0x1, 0x24, 0x0, 0x7f); - if ((data[5] & ~0x80) >= - (sizeof(fwts_dmi_chassis_type) / sizeof(fwts_chassis_type_map))) { + if ((data[5] & ~0x80) > FWTS_SMBIOS_CHASSIS_MAX) { fwts_failed(fw, LOG_LEVEL_HIGH, DMI_INVALID_HARDWARE_ENTRY, "Incorrect Chassis Type " "SMBIOS Type 3 reports 0x%" PRIx8, diff --git a/src/lib/include/fwts_smbios.h b/src/lib/include/fwts_smbios.h index a8bbf08b..f977bb8e 100644 --- a/src/lib/include/fwts_smbios.h +++ b/src/lib/include/fwts_smbios.h @@ -65,6 +65,9 @@ #define FWTS_SMBIOS_CHASSIS_MINI_PC (0x23) #define FWTS_SMBIOS_CHASSIS_STICK_PC (0x24) +/* Always update this to the last FWTS_SMBIOS_CHASSIS type */ +#define FWTS_SMBIOS_CHASSIS_MAX (FWTS_SMBIOS_CHASSIS_STICK_PC) + typedef enum { FWTS_SMBIOS_UNKNOWN = -1, FWTS_SMBIOS_DMI_LEGACY = 0,