From patchwork Tue Jan 8 18:11:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 210469 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id BB7F02C008F for ; Wed, 9 Jan 2013 05:11:22 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Tsddw-0004Gi-7L; Tue, 08 Jan 2013 18:11:20 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Tsddu-0004Fz-DG for fwts-devel@lists.ubuntu.com; Tue, 08 Jan 2013 18:11:18 +0000 Received: from cpc3-craw6-2-0-cust180.croy.cable.virginmedia.com ([77.100.248.181] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1Tsddu-00028c-9u for fwts-devel@lists.ubuntu.com; Tue, 08 Jan 2013 18:11:18 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] acpi: method: use a helper function for MethodReturnNullObj errors Date: Tue, 8 Jan 2013 18:11:17 +0000 Message-Id: <1357668677-17955-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.8.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King Add and use a helper function for conditions where a null object is returned. Signed-off-by: Colin Ian King Acked-by: Keng-Yu Lin Acked-by: Ivan Hu --- src/acpi/method/method.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c index 371fcb5..2014755 100644 --- a/src/acpi/method/method.c +++ b/src/acpi/method/method.c @@ -298,6 +298,20 @@ static void method_passed_sane_uint64( } /* + * method_failed_null_return() + * helper function to report often used failed NULL object return + */ +static void method_failed_null_object( + fwts_framework *fw, + const char *name, + const char *type) +{ + fwts_failed(fw, LOG_LEVEL_MEDIUM, "MethodReturnNullObj", + "%s returned a NULL object, and did not " + "return %s.", name, type); +} + +/* * method_init() * initialize ACPI */ @@ -518,10 +532,8 @@ static int method_check_type__( { ACPI_OBJECT *obj; - if ((buf == NULL) || (buf->Pointer == NULL)){ - fwts_failed(fw, LOG_LEVEL_MEDIUM, "MethodReturnNullObj", - "Method %s returned a NULL object, and did not " - "return %s.", name, type_name); + if ((buf == NULL) || (buf->Pointer == NULL)) { + method_failed_null_object(fw, name, type_name); return FWTS_ERROR; } @@ -762,11 +774,10 @@ static void method_test_HID_return( FWTS_UNUSED(private); if (obj == NULL) { - fwts_failed(fw, LOG_LEVEL_MEDIUM, "MethodReturnNullObj", - "Method %s returned a NULL object, and did not " - "return a buffer or integer.", name); + method_failed_null_object(fw, name, "a buffer or integer"); return; } + switch (obj->Type) { case ACPI_TYPE_STRING: if (obj->String.Pointer) { @@ -873,11 +884,10 @@ static void method_test_SUB_return( FWTS_UNUSED(private); if (obj == NULL) { - fwts_failed(fw, LOG_LEVEL_MEDIUM, "MethodReturnNullObj", - "Method %s returned a NULL object, and did not " - "return a buffer or integer.", name); + method_failed_null_object(fw, name, "a buffer or integer"); return; } + if (obj->Type == ACPI_TYPE_STRING) if (obj->String.Pointer) { if (method_valid_HID_string(obj->String.Pointer)) @@ -928,12 +938,11 @@ static void method_test_UID_return( FWTS_UNUSED(buf); FWTS_UNUSED(private); - if (obj == NULL){ - fwts_failed(fw, LOG_LEVEL_MEDIUM, "MethodReturnNullObj", - "%s returned a NULL object, and did not " - "return a buffer or integer.", name); + if (obj == NULL) { + method_failed_null_object(fw, name, "a buffer or integer"); return; } + switch (obj->Type) { case ACPI_TYPE_STRING: if (obj->String.Pointer) @@ -4618,13 +4627,11 @@ static void method_test_DDC_return( FWTS_UNUSED(buf); - if (obj == NULL){ - fwts_failed(fw, LOG_LEVEL_MEDIUM, - "MethodReturnNullObj", - "Method %s returned a NULL object, and did not " - "return a buffer or integer.", name); + if (obj == NULL) { + method_failed_null_object(fw, name, "a buffer or integer"); return; } + switch (obj->Type) { case ACPI_TYPE_BUFFER: if (requested != obj->Buffer.Length) {