From patchwork Fri May 15 20:15:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1291622 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=) 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-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49P0Bk2jRYz9sTS; Sat, 16 May 2020 06:19:57 +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 1jZgoF-0002Ik-D2; Fri, 15 May 2020 20:19:55 +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 1jZgkA-0001qk-BJ for fwts-devel@lists.ubuntu.com; Fri, 15 May 2020 20:15:42 +0000 Received: from 2.general.alexhung.us.vpn ([10.172.65.255] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jZgk9-0003fW-R1; Fri, 15 May 2020 20:15:42 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH 2/2] acpi/method/time: replace buffer size checks with function calls Date: Fri, 15 May 2020 14:15:36 -0600 Message-Id: <20200515201536.979293-2-alex.hung@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200515201536.979293-1-alex.hung@canonical.com> References: <20200515201536.979293-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: Colin Ian King Acked-by: Ivan Hu --- src/acpi/devices/time/time.c | 8 +----- src/acpi/method/method.c | 54 +++++------------------------------- 2 files changed, 8 insertions(+), 54 deletions(-) diff --git a/src/acpi/devices/time/time.c b/src/acpi/devices/time/time.c index c60264c2..4f776cf6 100644 --- a/src/acpi/devices/time/time.c +++ b/src/acpi/devices/time/time.c @@ -121,14 +121,8 @@ static void method_test_GRT_return( if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK) return; - if (obj->Buffer.Length != 16) { - fwts_failed(fw, LOG_LEVEL_CRITICAL, - "Method_GRTBadBufferSize", - "%s should return a buffer of 16 bytes, but " - "instead just returned %" PRIu32, - name, obj->Buffer.Length); + if (fwts_method_buffer_size(fw, name, obj, 16) != FWTS_OK) return; - } /* * Should sanity check this, but we can't read the diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c index 637f99bb..2fe85439 100644 --- a/src/acpi/method/method.c +++ b/src/acpi/method/method.c @@ -3137,11 +3137,7 @@ static void method_test_GTM_return( if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK) return; - if (obj->Buffer.Length != (5 * sizeof(uint32_t))) - fwts_failed(fw, LOG_LEVEL_MEDIUM, "Method_GTMBadBufferSize", - "%s should return a buffer with size of 20.", - name); - else + if (fwts_method_buffer_size(fw, name, obj, 20) == FWTS_OK) fwts_method_passed_sane(fw, name, "buffer"); } @@ -3248,14 +3244,8 @@ static void method_test_GRT_return( if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK) return; - if (obj->Buffer.Length != 16) { - fwts_failed(fw, LOG_LEVEL_MEDIUM, - "Method_GRTBadBufferSize", - "%s should return a buffer of 16 bytes, but " - "instead just returned %" PRIu32, - name, obj->Buffer.Length); + if (fwts_method_buffer_size(fw, name, obj, 16) != FWTS_OK) return; - } /* * Should sanity check this, but we can't read the @@ -3440,14 +3430,8 @@ static void method_test_NBS_return( if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK) return; - if (obj->Buffer.Length != 64) { + if (fwts_method_buffer_size(fw, name, obj, 64) != FWTS_OK) failed = true; - fwts_failed(fw, LOG_LEVEL_CRITICAL, - "Method_NBSBadBufferSize", - "%s should return a buffer of 64 bytes, but " - "instead just returned %" PRIu32, - name, obj->Buffer.Length); - } ret = (nbs_return_t *) obj->Buffer.Pointer; check_nvdimm_status(fw, name, ret->status, &failed); @@ -3479,14 +3463,8 @@ static void method_test_NCH_return( if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK) return; - if (obj->Buffer.Length != 64) { + if (fwts_method_buffer_size(fw, name, obj, 64) != FWTS_OK) failed = true; - fwts_failed(fw, LOG_LEVEL_CRITICAL, - "Method_NCHBadBufferSize", - "%s should return a buffer of 64 bytes, but " - "instead just returned %" PRIu32, - name, obj->Buffer.Length); - } ret = (nch_return_t *) obj->Buffer.Pointer; check_nvdimm_status(fw, name, ret->status, &failed); @@ -3525,14 +3503,8 @@ static void method_test_NIC_return( if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK) return; - if (obj->Buffer.Length != 64) { + if (fwts_method_buffer_size(fw, name, obj, 64) != FWTS_OK) failed = true; - fwts_failed(fw, LOG_LEVEL_CRITICAL, - "Method_NICBadBufferSize", - "%s should return a buffer of 64 bytes, but " - "instead just returned %" PRIu32, - name, obj->Buffer.Length); - } ret = (nic_return_t *) obj->Buffer.Pointer; check_nvdimm_status(fw, name, ret->status, &failed); @@ -3570,14 +3542,8 @@ static void method_test_NIH_return( if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK) return; - if (obj->Buffer.Length != 64) { + if (fwts_method_buffer_size(fw, name, obj, 64) != FWTS_OK) failed = true; - fwts_failed(fw, LOG_LEVEL_CRITICAL, - "Method_NIHBadBufferSize", - "%s should return a buffer of 64 bytes, but " - "instead just returned %" PRIu32, - name, obj->Buffer.Length); - } ret = (nih_return_t *) obj->Buffer.Pointer; check_nvdimm_status(fw, name, ret->status, &failed); @@ -3635,14 +3601,8 @@ static void method_test_NIG_return( if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK) return; - if (obj->Buffer.Length != 64) { + if (fwts_method_buffer_size(fw, name, obj, 64) != FWTS_OK) failed = true; - fwts_failed(fw, LOG_LEVEL_CRITICAL, - "Method_NIGBadBufferSize", - "%s should return a buffer of 64 bytes, but " - "instead just returned %" PRIu32, - name, obj->Buffer.Length); - } ret = (nig_return_t *) obj->Buffer.Pointer; check_nvdimm_status(fw, name, ret->status, &failed);