From patchwork Fri May 14 19:21:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1478647 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fhdgz5sbCz9sWQ for ; Sat, 15 May 2021 05:22: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 1lhdNr-00030m-G3; Fri, 14 May 2021 19:22:03 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lhdNp-0002zx-0Q for fwts-devel@lists.ubuntu.com; Fri, 14 May 2021 19:22:01 +0000 Received: from d75-158-101-9.abhsia.telus.net ([75.158.101.9] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lhdNo-0007BA-Bx; Fri, 14 May 2021 19:22:00 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH 2/6] acpi: refactor length check by fwts_acpi_structure_length_check Date: Fri, 14 May 2021 13:21:51 -0600 Message-Id: <20210514192155.593354-2-alex.hung@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210514192155.593354-1-alex.hung@canonical.com> References: <20210514192155.593354-1-alex.hung@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" Signed-off-by: Alex Hung Acked-by: Ivan Hu Acked-by: Colin Ian King --- src/acpi/hmat/hmat.c | 7 +------ src/acpi/pptt/pptt.c | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/acpi/hmat/hmat.c b/src/acpi/hmat/hmat.c index 8a06f8b1..01b76100 100644 --- a/src/acpi/hmat/hmat.c +++ b/src/acpi/hmat/hmat.c @@ -182,13 +182,8 @@ static int hmat_test1(fwts_framework *fw) break; } - if (entry->length != type_length) { + if (!fwts_acpi_structure_length_check(fw, "HMAT", entry->type, entry->length, type_length)) { passed = false; - fwts_failed(fw, LOG_LEVEL_CRITICAL, - "HMATBadSubtableLength", - "HMAT subtable Type 0x%2.2" PRIx8 " should have " - "length 0x%2.2" PRIx8 ", got 0x%2.2" PRIx8, - entry->type, entry->length, type_length); break; } diff --git a/src/acpi/pptt/pptt.c b/src/acpi/pptt/pptt.c index c436ab82..8656e979 100644 --- a/src/acpi/pptt/pptt.c +++ b/src/acpi/pptt/pptt.c @@ -146,13 +146,8 @@ static int pptt_test1(fwts_framework *fw) break; } - if (entry->length != type_length) { + if (!fwts_acpi_structure_length_check(fw, "PPTT", entry->type, entry->length, type_length)) { passed = false; - fwts_failed(fw, LOG_LEVEL_CRITICAL, - "PPTTBadSubtableLength", - "PPTT subtable Type 0x%2.2" PRIx8 " should have " - "length 0x%2.2" PRIx8 ", got 0x%2.2" PRIx8, - entry->type, type_length, entry->length); break; }