From nobody Mon Feb 9 10:11:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690894134193824.6135630982006; Tue, 1 Aug 2023 05:48:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.574136.899322 (Exim 4.92) (envelope-from ) id 1qQonf-0002N0-Bg; Tue, 01 Aug 2023 12:48:31 +0000 Received: by outflank-mailman (output) from mailman id 574136.899322; Tue, 01 Aug 2023 12:48:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qQonf-0002Mt-8q; Tue, 01 Aug 2023 12:48:31 +0000 Received: by outflank-mailman (input) for mailman id 574136; Tue, 01 Aug 2023 12:48:29 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qQond-0002MS-I7 for xen-devel@lists.xenproject.org; Tue, 01 Aug 2023 12:48:29 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b6a4c424-3069-11ee-b25a-6b7b168915f2; Tue, 01 Aug 2023 14:48:29 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 0CFED4EE0742; Tue, 1 Aug 2023 14:48:27 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: b6a4c424-3069-11ee-b25a-6b7b168915f2 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, michal.orzel@amd.com, xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com, consulting@bugseng.com, Nicola Vetrini , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu Subject: [XEN PATCH v2 2/3] drivers/char: address MISRA C:2012 Rule 5.3 Date: Tue, 1 Aug 2023 14:47:43 +0200 Message-Id: <69fad93eeafdceae5de1f2483015f05d1798b6be.1690893696.git.nicola.vetrini@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1690894135704100001 Content-Type: text/plain; charset="utf-8" The following strategies are adopted to deal with violations of MISRA C:2012 Rule 5.3: "An identifier declared in an inner scope shall not hide an identifier declared in an outer scope". Local variable 'ctrl' shadows a variable defined in an outer scope. Since the innermost variable is used only once after being set, it is safe to remove it entirely. The enum constant 'baud' is shadowed by local a local variable at line 1476, and renaming the enum constant avoid such conflicts. Signed-off-by: Nicola Vetrini Reviewed-by: Jan Beulich --- Changes in v2: - Renamed the enum constant instead of the local variable 'baud'. - Removed the inner variable entirely, as it serves no purpose. --- xen/drivers/char/ehci-dbgp.c | 4 +--- xen/drivers/char/ns16550.c | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c index 4d8d765122..72be4d9cc9 100644 --- a/xen/drivers/char/ehci-dbgp.c +++ b/xen/drivers/char/ehci-dbgp.c @@ -424,9 +424,7 @@ static void dbgp_issue_command(struct ehci_dbgp *dbgp, = u32 ctrl, * checks to see if ACPI or some other initialization also * reset the EHCI debug port. */ - u32 ctrl =3D readl(&dbgp->ehci_debug->control); - - if ( ctrl & DBGP_ENABLED ) + if ( readl(&dbgp->ehci_debug->control) & DBGP_ENABLED ) { cmd |=3D CMD_RUN; writel(cmd, &dbgp->ehci_regs->command); diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index 212a9c49ae..b75e7f8fa0 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -1388,7 +1388,7 @@ string_param("com1", opt_com1); string_param("com2", opt_com2); =20 enum serial_param_type { - baud, + baud_rate, clock_hz, data_bits, io_base, @@ -1416,7 +1416,7 @@ struct serial_param_var { * com_console_options for serial port com1 and com2. */ static const struct serial_param_var __initconst sp_vars[] =3D { - {"baud", baud}, + {"baud", baud_rate}, {"clock-hz", clock_hz}, {"data-bits", data_bits}, {"io-base", io_base}, @@ -1596,7 +1596,7 @@ static bool __init parse_namevalue_pairs(char *str, s= truct ns16550 *uart) =20 switch ( get_token(token, ¶m_value) ) { - case baud: + case baud_rate: uart->baud =3D simple_strtoul(param_value, NULL, 0); break; =20 --=20 2.34.1