From patchwork Wed May 26 19:04:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1484243 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 4Fr0jm6jN2z9sRK for ; Thu, 27 May 2021 05:04: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 1llyp8-0002xc-C5; Wed, 26 May 2021 19:04:10 +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 1llyp6-0002xO-J7 for fwts-devel@lists.ubuntu.com; Wed, 26 May 2021 19:04:08 +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 1llyp5-00028n-U7; Wed, 26 May 2021 19:04:08 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH][V2] lib: fwts_acpi_tables: constify read-only function arguments Date: Wed, 26 May 2021 13:04:05 -0600 Message-Id: <20210526190405.1269962-1-alex.hung@canonical.com> X-Mailer: git-send-email 2.31.1 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: Colin Ian King Signed-off-by: Alex Hung Acked-by: Ivan Hu Acked-by: Colin Ian King --- src/lib/include/fwts_acpi_tables.h | 36 ++++++++++++++++--------- src/lib/src/fwts_acpi_tables.c | 42 +++++++++++++++--------------- 2 files changed, 45 insertions(+), 33 deletions(-) diff --git a/src/lib/include/fwts_acpi_tables.h b/src/lib/include/fwts_acpi_tables.h index 8ed65841..11670ae0 100644 --- a/src/lib/include/fwts_acpi_tables.h +++ b/src/lib/include/fwts_acpi_tables.h @@ -63,23 +63,35 @@ static int name ## _init (fwts_framework *fw) \ int fwts_acpi_load_tables(fwts_framework *fw); int fwts_acpi_free_tables(void); -int fwts_acpi_find_table(fwts_framework *fw, const char *name, const uint32_t which, fwts_acpi_table_info **info); -int fwts_acpi_find_table_by_addr(fwts_framework *fw, const uint64_t addr, fwts_acpi_table_info **info); +int fwts_acpi_find_table(fwts_framework *fw, const char *name, const uint32_t which, + fwts_acpi_table_info **info); +int fwts_acpi_find_table_by_addr(fwts_framework *fw, const uint64_t addr, + fwts_acpi_table_info **info); int fwts_acpi_get_table(fwts_framework *fw, const uint32_t index, fwts_acpi_table_info **info); bool fwts_acpi_obj_find(fwts_framework *fw, const char *obj_name); fwts_bool fwts_acpi_is_reduced_hardware(fwts_framework *fw); -void fwts_acpi_reserved_zero_(fwts_framework *fw, const char *table, const char *field, uint64_t value, uint8_t size, bool *passed); -void fwts_acpi_reserved_zero_array(fwts_framework *fw, const char *table, const char *field, uint8_t* data, uint8_t length, bool *passed); -void fwts_acpi_reserved_bits_(fwts_framework *fw, const char *table, const char *field, uint64_t value, uint8_t size, uint8_t min, uint8_t max, bool *passed); -void fwts_acpi_reserved_type(fwts_framework *fw, const char *table, uint8_t value, uint8_t min, uint8_t reserved, bool *passed); -bool fwts_acpi_table_length(fwts_framework *fw, const char *table, uint32_t length, uint32_t size); -bool fwts_acpi_structure_length(fwts_framework *fw, const char *table, uint8_t type, uint32_t actual_length, uint32_t struct_length); -bool fwts_acpi_structure_length_zero(fwts_framework *fw, const char *table, uint16_t length, uint32_t offset); -bool fwts_acpi_structure_range(fwts_framework *fw, const char *table, uint32_t table_length, uint32_t offset); -void fwts_acpi_fixed_value(fwts_framework *fw, fwts_log_level level, const char *table, const char *field, uint8_t actual, uint8_t must_be, bool *passed); -void fwts_acpi_space_id(fwts_framework *fw, const char *table, const char *field, bool *passed, uint8_t actual, uint8_t num_type, ...); +void fwts_acpi_reserved_zero_(fwts_framework *fw, const char *table, const char *field, + const uint64_t value, const uint8_t size, bool *passed); +void fwts_acpi_reserved_zero_array(fwts_framework *fw, const char *table, const char *field, + const uint8_t* data, const uint8_t length, bool *passed); +void fwts_acpi_reserved_bits_(fwts_framework *fw, const char *table, const char *field, + const uint64_t value, const uint8_t size, const uint8_t min, const uint8_t max, bool *passed); +void fwts_acpi_reserved_type(fwts_framework *fw, const char *table, const uint8_t value, + const uint8_t min, const uint8_t reserved, bool *passed); +bool fwts_acpi_table_length(fwts_framework *fw, const char *table, const uint32_t length, + const uint32_t size); +bool fwts_acpi_structure_length(fwts_framework *fw, const char *table, const uint8_t type, + const uint32_t actual_length, const uint32_t struct_length); +bool fwts_acpi_structure_length_zero(fwts_framework *fw, const char *table, + const uint16_t length, const uint32_t offset); +bool fwts_acpi_structure_range(fwts_framework *fw, const char *table, const uint32_t table_length, + const uint32_t offset); +void fwts_acpi_fixed_value(fwts_framework *fw, const fwts_log_level level, const char *table, + const char *field, const uint8_t actual, const uint8_t must_be, bool *passed); +void fwts_acpi_space_id(fwts_framework *fw, const char *table, const char *field, bool *passed, + const uint8_t actual, const uint8_t num_type, ...); uint32_t fwts_get_acpi_version(fwts_framework *fw); diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c index e69dc04e..58732201 100644 --- a/src/lib/src/fwts_acpi_tables.c +++ b/src/lib/src/fwts_acpi_tables.c @@ -1432,8 +1432,8 @@ void fwts_acpi_reserved_zero_( fwts_framework *fw, const char *table, const char *field, - uint64_t value, - uint8_t size, + const uint64_t value, + const uint8_t size, bool *passed) { if (value != 0) { @@ -1476,8 +1476,8 @@ void fwts_acpi_reserved_zero_array( fwts_framework *fw, const char *table, const char *field, - uint8_t* data, - uint8_t length, + const uint8_t* data, + const uint8_t length, bool *passed) { uint32_t value = 0; @@ -1507,11 +1507,11 @@ void fwts_acpi_reserved_zero_array( */ void fwts_acpi_fixed_value( fwts_framework *fw, - fwts_log_level level, + const fwts_log_level level, const char *table, const char *field, - uint8_t actual, - uint8_t must_be, + const uint8_t actual, + const uint8_t must_be, bool *passed) { char label[20]; @@ -1535,10 +1535,10 @@ void fwts_acpi_reserved_bits_( fwts_framework *fw, const char *table, const char *field, - uint64_t value, - uint8_t size, - uint8_t min, - uint8_t max, + const uint64_t value, + const uint8_t size, + const uint8_t min, + const uint8_t max, bool *passed) { uint64_t mask = 0; @@ -1586,9 +1586,9 @@ void fwts_acpi_reserved_bits_( void fwts_acpi_reserved_type( fwts_framework *fw, const char *table, - uint8_t value, - uint8_t min, - uint8_t reserved, + const uint8_t value, + const uint8_t min, + const uint8_t reserved, bool *passed) { if (value < min || value >= reserved) { @@ -1648,8 +1648,8 @@ void fwts_acpi_space_id( const char *table, const char *field, bool *passed, - uint8_t actual, - uint8_t num_type, + const uint8_t actual, + const uint8_t num_type, ...) { bool matched = false; @@ -1705,8 +1705,8 @@ void fwts_acpi_space_id( bool fwts_acpi_table_length( fwts_framework *fw, const char *table, - uint32_t length, - uint32_t size) + const uint32_t length, + const uint32_t size) { if (length < size) { char label[30]; @@ -1729,9 +1729,9 @@ bool fwts_acpi_table_length( bool fwts_acpi_structure_length( fwts_framework *fw, const char *table, - uint8_t type, - uint32_t actual_length, - uint32_t struct_length) + const uint8_t type, + const uint32_t actual_length, + const uint32_t struct_length) { if (actual_length != struct_length) { char label[30];