Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1AF92EB64DA for ; Fri, 14 Jul 2023 13:44:52 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.563652.881003 (Exim 4.92) (envelope-from ) id 1qKJ5n-0007v7-8b; Fri, 14 Jul 2023 13:44:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 563652.881003; Fri, 14 Jul 2023 13:44:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qKJ5n-0007v0-5E; Fri, 14 Jul 2023 13:44:19 +0000 Received: by outflank-mailman (input) for mailman id 563652; Fri, 14 Jul 2023 13:44:18 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qKJ5m-0007uu-FE for xen-devel@lists.xenproject.org; Fri, 14 Jul 2023 13:44:18 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 85dda14e-224c-11ee-8611-37d641c3527e; Fri, 14 Jul 2023 15:44:15 +0200 (CEST) Received: from [192.168.1.100] (unknown [37.163.94.163]) by support.bugseng.com (Postfix) with ESMTPSA id 551DA4EE0739; Fri, 14 Jul 2023 15:44:14 +0200 (CEST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 85dda14e-224c-11ee-8611-37d641c3527e Message-ID: <77b82911-a6c1-d23f-e42b-132d928e6603@bugseng.com> Date: Fri, 14 Jul 2023 15:44:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] xen/ACPI: Remove the acpi_string type To: Andrew Cooper , Xen-devel Cc: George Dunlap , Jan Beulich , Stefano Stabellini , Wei Liu , Julien Grall , Roberto Bagnara References: <20230714130411.3055187-1-andrew.cooper3@citrix.com> Content-Language: en-US From: Nicola Vetrini In-Reply-To: <20230714130411.3055187-1-andrew.cooper3@citrix.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 14/07/23 15:04, Andrew Cooper wrote: > Typedef-ing a naked pointer like this an anti-pattern which is best avoided. s/this an/this is an/ > Furthermore, it's bad to pass a string literate in a mutable type. Delete the s/literate/literal/ > type entirely, and replace it with a plain 'const char *'. > > This highlights two futher bugs. acpi_get_table() already had a mismatch in > types between it's declaration and definition, and we have declarations for > acpi_get_handle() and acpi_get_table_header() but no definition at all (nor > any callers). > > This fixes violations of MISRA Rule 7.4: > > A string literal shall not be assigned to an object unless the object's type > is "pointer to const-qualified char". > > and of Rule 8.3: > > All declarations of an object or function shall use the same names and type > qualifiers. > > and of Rule 8.6: > > An identifier with external linkage shall have exactly one external > definition. The choice of rules looks good to me, but perhaps Roberto has some additional insight on this. > > No functional change. > > Signed-off-by: Andrew Cooper > --- > CC: George Dunlap > CC: Jan Beulich > CC: Stefano Stabellini > CC: Wei Liu > CC: Julien Grall > CC: Roberto Bagnara > CC: Nicola Vetrini > > Roberto/Nicola: Please double check my choice of rules here, and point out any > others that I may have missed. > --- > xen/drivers/acpi/tables/tbxface.c | 4 ++-- > xen/include/acpi/acpixf.h | 13 ++----------- > xen/include/acpi/actypes.h | 1 - > 3 files changed, 4 insertions(+), 14 deletions(-) > > diff --git a/xen/drivers/acpi/tables/tbxface.c b/xen/drivers/acpi/tables/tbxface.c > index 21b2e5eae1c7..204d66caea48 100644 > --- a/xen/drivers/acpi/tables/tbxface.c > +++ b/xen/drivers/acpi/tables/tbxface.c > @@ -164,7 +164,7 @@ acpi_initialize_tables(struct acpi_table_desc * initial_table_array, > * > *****************************************************************************/ > acpi_status __init > -acpi_get_table(char *signature, > +acpi_get_table(const char *signature, > acpi_native_uint instance, struct acpi_table_header **out_table) > { > acpi_native_uint i; > @@ -220,7 +220,7 @@ acpi_get_table(char *signature, > * > *****************************************************************************/ > acpi_status __init > -acpi_get_table_phys(acpi_string signature, acpi_native_uint instance, > +acpi_get_table_phys(const char *signature, acpi_native_uint instance, > acpi_physical_address *addr, acpi_native_uint *len) > { > acpi_native_uint i, j; > diff --git a/xen/include/acpi/acpixf.h b/xen/include/acpi/acpixf.h > index ba74908f0478..8b70154b8f96 100644 > --- a/xen/include/acpi/acpixf.h > +++ b/xen/include/acpi/acpixf.h > @@ -69,25 +69,16 @@ acpi_status acpi_load_tables(void); > acpi_status acpi_load_table(struct acpi_table_header *table_ptr); > > acpi_status > -acpi_get_table_header(acpi_string signature, > - acpi_native_uint instance, > - struct acpi_table_header *out_table_header); > - > -acpi_status > -acpi_get_table(acpi_string signature, > +acpi_get_table(const char *signature, > acpi_native_uint instance, struct acpi_table_header **out_table); > > acpi_status > -acpi_get_table_phys(acpi_string signature, acpi_native_uint instance, > +acpi_get_table_phys(const char *signature, acpi_native_uint instance, > acpi_physical_address *addr, acpi_native_uint *len); > /* > * Namespace and name interfaces > */ > acpi_status > -acpi_get_handle(acpi_handle parent, > - acpi_string pathname, acpi_handle * ret_handle); > - > -acpi_status > acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags); > > acpi_status > diff --git a/xen/include/acpi/actypes.h b/xen/include/acpi/actypes.h > index f3e95abc3ab3..7023863d0349 100644 > --- a/xen/include/acpi/actypes.h > +++ b/xen/include/acpi/actypes.h > @@ -281,7 +281,6 @@ typedef acpi_native_uint acpi_size; > */ > typedef u32 acpi_status; /* All ACPI Exceptions */ > typedef u32 acpi_name; /* 4-byte ACPI name */ > -typedef char *acpi_string; /* Null terminated ASCII string */ > typedef void *acpi_handle; /* Actually a ptr to a NS Node */ > > struct uint64_struct { -- Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)