From patchwork Tue Dec 20 08:50:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077637 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 01F6BC10F1E for ; Tue, 20 Dec 2022 08:51:26 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466593.725504 (Exim 4.92) (envelope-from ) id 1p7YLF-000200-LU; Tue, 20 Dec 2022 08:51:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466593.725504; Tue, 20 Dec 2022 08:51:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YLF-0001zt-IX; Tue, 20 Dec 2022 08:51:17 +0000 Received: by outflank-mailman (input) for mailman id 466593; Tue, 20 Dec 2022 08:51:16 +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 1p7YLE-0001kV-6i for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:16 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 757efa25-8043-11ed-91b6-6bf2151ebd3b; Tue, 20 Dec 2022 09:51:14 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F1496AD7; Tue, 20 Dec 2022 00:51:54 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B1EA23F71A; Tue, 20 Dec 2022 00:51:12 -0800 (PST) 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: 757efa25-8043-11ed-91b6-6bf2151ebd3b From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Volodymyr Babchuk Subject: [RFC PATCH 01/18] arm: cppcheck: misra rule 20.7 deviations for alternative.h Date: Tue, 20 Dec 2022 08:50:43 +0000 Message-Id: <20221220085100.22848-2-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck reports violations of rule 20.7 in two macros of alternative.h. The first one is in the __ALT_PTR macro where cppcheck wants to have parentheses on the second operand of a member access operator, which is not allowed from the c language syntax, furthermore, the macro parameter is never used as an expression, hence we can suppress the finding. The second finding is in the __ALTERNATIVE_CFG macro, where cppcheck wants to have parentheses on the macro arguments, but the macro parameters are never used as expressions and are used only for text substitution, so cppcheck is not taking into account the context of use of the macro arguments and adding parenthesis would break the code, so we can suppress the finding. No error was shown by eclair and coverity for those lines. Signed-off-by: Luca Fancellu --- docs/misra/false-positive-cppcheck.json | 14 ++++++++++++++ xen/arch/arm/include/asm/alternative.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/docs/misra/false-positive-cppcheck.json b/docs/misra/false-positive-cppcheck.json index 5d4da2ce6170..5e7d9377f60b 100644 --- a/docs/misra/false-positive-cppcheck.json +++ b/docs/misra/false-positive-cppcheck.json @@ -3,6 +3,20 @@ "content": [ { "id": "SAF-0-false-positive-cppcheck", + "violation-id": "misra-c2012-20.7", + "tool-version": "2.7", + "name": "R20.7 second operand of member-access operator", + "text": "The second operand of a member access operator shall be a name of a member of the type pointed to, so in this particular case it is wrong to use parentheses on the macro parameter." + }, + { + "id": "SAF-1-false-positive-cppcheck", + "violation-id": "misra-c2012-20.7", + "tool-version": "2.7", + "name": "R20.7 C macro parameters used only for text substitution", + "text": "The macro parameters used in this case are not part of an expression, they are used for text substitution." + }, + { + "id": "SAF-2-false-positive-cppcheck", "violation-id": "", "tool-version": "", "name": "Sentinel", diff --git a/xen/arch/arm/include/asm/alternative.h b/xen/arch/arm/include/asm/alternative.h index 1eb4b60fbb3e..9d4dc53bb0c6 100644 --- a/xen/arch/arm/include/asm/alternative.h +++ b/xen/arch/arm/include/asm/alternative.h @@ -20,6 +20,7 @@ struct alt_instr { }; /* Xen: helpers used by common code. */ +/* SAF-0-false-positive-cppcheck R20.7 member-access operator */ #define __ALT_PTR(a,f) ((void *)&(a)->f + (a)->f) #define ALT_ORIG_PTR(a) __ALT_PTR(a, orig_offset) #define ALT_REPL_PTR(a) __ALT_PTR(a, alt_offset) @@ -58,6 +59,7 @@ int apply_alternatives(const struct alt_instr *start, const struct alt_instr *en * * Alternatives with callbacks do not generate replacement instructions. */ +/* SAF-1-false-positive-cppcheck R20.7 argument for text substitution */ #define __ALTERNATIVE_CFG(oldinstr, newinstr, feature, cfg_enabled, cb) \ ".if "__stringify(cfg_enabled)" == 1\n" \ "661:\n\t" \ From patchwork Tue Dec 20 08:50:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077638 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 79EA2C3DA79 for ; Tue, 20 Dec 2022 08:51:27 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466594.725515 (Exim 4.92) (envelope-from ) id 1p7YLG-0002GN-UP; Tue, 20 Dec 2022 08:51:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466594.725515; Tue, 20 Dec 2022 08:51:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YLG-0002GG-R1; Tue, 20 Dec 2022 08:51:18 +0000 Received: by outflank-mailman (input) for mailman id 466594; Tue, 20 Dec 2022 08:51:17 +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 1p7YLE-0001kV-Ve for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:16 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 76185c53-8043-11ed-91b6-6bf2151ebd3b; Tue, 20 Dec 2022 09:51:15 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 15A56FEC; Tue, 20 Dec 2022 00:51:56 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 40C9A3F71A; Tue, 20 Dec 2022 00:51:14 -0800 (PST) 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: 76185c53-8043-11ed-91b6-6bf2151ebd3b From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [RFC PATCH 02/18] arm: cppcheck: misra rule 20.7 deviation on processor.h Date: Tue, 20 Dec 2022 08:50:44 +0000 Message-Id: <20221220085100.22848-3-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found a violation of rule 20.7 for the macro __DECL_REG, but the macro parameters are never used as an expression, they are used for text substitution and adding parenthesis would break the code. Cppcheck is not taking into account the context of use of the macro argument, so we can suppress the finding. Eclair and coverity does not report this finding. Signed-off-by: Luca Fancellu --- xen/arch/arm/include/asm/arm64/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/include/asm/arm64/processor.h b/xen/arch/arm/include/asm/arm64/processor.h index c749f80ad91b..aacbe5d4d538 100644 --- a/xen/arch/arm/include/asm/arm64/processor.h +++ b/xen/arch/arm/include/asm/arm64/processor.h @@ -4,7 +4,7 @@ #ifndef __ASSEMBLY__ /* Anonymous union includes both 32- and 64-bit names (e.g., r0/x0). */ - +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define __DECL_REG(n64, n32) union { \ uint64_t n64; \ uint32_t n32; \ From patchwork Tue Dec 20 08:50:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077639 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 272B2C4332F for ; Tue, 20 Dec 2022 08:51:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466595.725526 (Exim 4.92) (envelope-from ) id 1p7YLI-0002XN-9R; Tue, 20 Dec 2022 08:51:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466595.725526; Tue, 20 Dec 2022 08:51:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YLI-0002Wy-3p; Tue, 20 Dec 2022 08:51:20 +0000 Received: by outflank-mailman (input) for mailman id 466595; Tue, 20 Dec 2022 08:51:18 +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 1p7YLF-0001kV-Vr for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:17 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 76c3abbb-8043-11ed-91b6-6bf2151ebd3b; Tue, 20 Dec 2022 09:51:16 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2DE2113D5; Tue, 20 Dec 2022 00:51:57 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 595C53F71A; Tue, 20 Dec 2022 00:51:15 -0800 (PST) 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: 76c3abbb-8043-11ed-91b6-6bf2151ebd3b From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [RFC PATCH 03/18] arm: cppcheck: misra rule 20.7 deviation on asm_defns.h Date: Tue, 20 Dec 2022 08:50:45 +0000 Message-Id: <20221220085100.22848-4-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found violations of rule 20.7 for the macros RODATA_STR() and ASM_INT(), but the macro parameters are never used as an expression, they are used for text subtitution and cppcheck is not taking into account the context of use for them, so we can suppress the finding. Eclair and coverity does not report these findings. Signed-off-by: Luca Fancellu --- xen/arch/arm/include/asm/asm_defns.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/arm/include/asm/asm_defns.h b/xen/arch/arm/include/asm/asm_defns.h index 29a9dbb002fa..9bf4cf8891f5 100644 --- a/xen/arch/arm/include/asm/asm_defns.h +++ b/xen/arch/arm/include/asm/asm_defns.h @@ -22,11 +22,13 @@ # error "unknown ARM variant" #endif +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define RODATA_STR(label, msg) \ .pushsection .rodata.str, "aMS", %progbits, 1 ; \ label: .asciz msg; \ .popsection +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define ASM_INT(label, val) \ .p2align 2; \ label: .long (val); \ From patchwork Tue Dec 20 08:50:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077640 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 2D84FC4167B for ; Tue, 20 Dec 2022 08:51:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466596.725533 (Exim 4.92) (envelope-from ) id 1p7YLI-0002bN-Lq; Tue, 20 Dec 2022 08:51:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466596.725533; Tue, 20 Dec 2022 08:51:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YLI-0002ay-EM; Tue, 20 Dec 2022 08:51:20 +0000 Received: by outflank-mailman (input) for mailman id 466596; Tue, 20 Dec 2022 08:51:19 +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 1p7YLG-0001kV-WC for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:18 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 7762080d-8043-11ed-91b6-6bf2151ebd3b; Tue, 20 Dec 2022 09:51:17 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4765B1688; Tue, 20 Dec 2022 00:51:58 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 71BC33F71A; Tue, 20 Dec 2022 00:51:16 -0800 (PST) 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: 7762080d-8043-11ed-91b6-6bf2151ebd3b From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [RFC PATCH 04/18] arm: cppcheck: misra rule 20.7 deviation on config.h Date: Tue, 20 Dec 2022 08:50:46 +0000 Message-Id: <20221220085100.22848-5-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found violations of rule 20.7 for the macros ENTRY(), GLOBAL(), END() and ENDPROC(), but the macro parameters are never used as an expression, they are used for text substitution but cppcheck is not taking into account the context of them, so we can suppress the findings. Eclair and coverity does not report these findings. Signed-off-by: Luca Fancellu --- xen/arch/arm/include/asm/config.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/arch/arm/include/asm/config.h b/xen/arch/arm/include/asm/config.h index 0fefed1b8aa9..c4843ddffe24 100644 --- a/xen/arch/arm/include/asm/config.h +++ b/xen/arch/arm/include/asm/config.h @@ -54,15 +54,19 @@ /* Linkage for ARM */ #ifdef __ASSEMBLY__ #define ALIGN .align 2 +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define ENTRY(name) \ .globl name; \ ALIGN; \ name: +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define GLOBAL(name) \ .globl name; \ name: +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define END(name) \ .size name, .-name +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define ENDPROC(name) \ .type name, %function; \ END(name) From patchwork Tue Dec 20 08:50:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077641 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 3E022C10F1E for ; Tue, 20 Dec 2022 08:51:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466597.725539 (Exim 4.92) (envelope-from ) id 1p7YLJ-0002kQ-3m; Tue, 20 Dec 2022 08:51:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466597.725539; Tue, 20 Dec 2022 08:51:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YLI-0002jT-R9; Tue, 20 Dec 2022 08:51:20 +0000 Received: by outflank-mailman (input) for mailman id 466597; Tue, 20 Dec 2022 08:51:19 +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 1p7YLH-0001kP-Og for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:19 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 785671f4-8043-11ed-8fd4-01056ac49cbb; Tue, 20 Dec 2022 09:51:19 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 613F513D5; Tue, 20 Dec 2022 00:51:59 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8AFEE3F71A; Tue, 20 Dec 2022 00:51:17 -0800 (PST) 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: 785671f4-8043-11ed-8fd4-01056ac49cbb From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [RFC PATCH 05/18] arm: cppcheck: fix misra rule 20.7 on arm/include/asm/string.h Date: Tue, 20 Dec 2022 08:50:47 +0000 Message-Id: <20221220085100.22848-6-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found a violation of rule 20.7 for the macro memset about missing parenthesis for the "n" argument, while the parenthesis are not mandatory because the argument is never used in an expression, adding them will not harm code and readability, so fix the finding adding parenthesis for the argument. Eclair and coverity does not report this finding. Signed-off-by: Luca Fancellu --- xen/arch/arm/include/asm/string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/include/asm/string.h b/xen/arch/arm/include/asm/string.h index b485e4904419..f1c87d215b0b 100644 --- a/xen/arch/arm/include/asm/string.h +++ b/xen/arch/arm/include/asm/string.h @@ -30,7 +30,7 @@ void __memzero(void *ptr, size_t n); #define memset(p, v, n) \ ({ \ - void *__p = (p); size_t __n = n; \ + void *__p = (p); size_t __n = (n); \ if ((__n) != 0) { \ if (__builtin_constant_p((v)) && (v) == 0) \ __memzero((__p),(__n)); \ From patchwork Tue Dec 20 08:50:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077642 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 98DC3C4332F for ; Tue, 20 Dec 2022 08:51:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466598.725559 (Exim 4.92) (envelope-from ) id 1p7YLL-0003Nb-AT; Tue, 20 Dec 2022 08:51:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466598.725559; Tue, 20 Dec 2022 08:51:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YLL-0003NR-5E; Tue, 20 Dec 2022 08:51:23 +0000 Received: by outflank-mailman (input) for mailman id 466598; Tue, 20 Dec 2022 08:51:21 +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 1p7YLI-0001kP-UJ for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:20 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 78fea8da-8043-11ed-8fd4-01056ac49cbb; Tue, 20 Dec 2022 09:51:20 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7BE642F4; Tue, 20 Dec 2022 00:52:00 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A51A63F71A; Tue, 20 Dec 2022 00:51:18 -0800 (PST) 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: 78fea8da-8043-11ed-8fd4-01056ac49cbb From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [RFC PATCH 06/18] public: cppcheck: misra rule 20.7 on public/arch-arm.h Date: Tue, 20 Dec 2022 08:50:48 +0000 Message-Id: <20221220085100.22848-7-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found violations of rule 20.7 for the macros ___DEFINE_XEN_GUEST_HANDLE, set_xen_guest_handle_raw and __DECL_REG. For the first and third finding, the macro parameters are never used in an expression, cppcheck is not taking into account the context where the arguments are used, so we can suppress the findings. For the set_xen_guest_handle_raw, the argument is not involved in any expression but it doesn't harm the code or readability to have parenthesis on it, so fix it. Eclair and coverity does not report these findings. Signed-off-by: Luca Fancellu --- xen/include/public/arch-arm.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 1528ced5097a..7afc0d1ca23d 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -156,6 +156,7 @@ #define uint64_aligned_t uint64_t __attribute__((aligned(8))) #ifndef __ASSEMBLY__ +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ typedef union { type *p; unsigned long q; } \ __guest_handle_ ## name; \ @@ -180,7 +181,7 @@ do { \ __typeof__(&(hnd)) _sxghr_tmp = &(hnd); \ _sxghr_tmp->q = 0; \ - _sxghr_tmp->p = val; \ + _sxghr_tmp->p = (val); \ } while ( 0 ) #define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val) @@ -206,6 +207,7 @@ typedef uint64_t xen_ulong_t; } #else /* Non-gcc sources must always use the proper 64-bit name (e.g., x0). */ +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define __DECL_REG(n64, n32) uint64_t n64 #endif From patchwork Tue Dec 20 08:50:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077643 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 D2A31C10F1E for ; Tue, 20 Dec 2022 08:51:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466599.725564 (Exim 4.92) (envelope-from ) id 1p7YLL-0003QG-LS; Tue, 20 Dec 2022 08:51:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466599.725564; Tue, 20 Dec 2022 08:51:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YLL-0003On-EY; Tue, 20 Dec 2022 08:51:23 +0000 Received: by outflank-mailman (input) for mailman id 466599; Tue, 20 Dec 2022 08:51:22 +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 1p7YLK-0001kP-77 for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:22 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 79cc520f-8043-11ed-8fd4-01056ac49cbb; Tue, 20 Dec 2022 09:51:21 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CA52B13D5; Tue, 20 Dec 2022 00:52:01 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C02AB3F71A; Tue, 20 Dec 2022 00:51:19 -0800 (PST) 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: 79cc520f-8043-11ed-8fd4-01056ac49cbb From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [RFC PATCH 07/18] xen: cppcheck: misra rule 20.7 deviation on compiler.h Date: Tue, 20 Dec 2022 08:50:49 +0000 Message-Id: <20221220085100.22848-8-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found a violation of rule 20.7 for the macro sizeof_field, but the parenthesis cannot be applied on the second operand of a member access operator, hence we can suppress the finding. Eclair and coverity does not report this finding. Signed-off-by: Luca Fancellu --- xen/include/xen/compiler.h | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h index a5631303348b..301ba55d6ecc 100644 --- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -115,6 +115,7 @@ * @TYPE: The structure containing the field of interest * @MEMBER: The field to return the size of */ +/* SAF-0-false-positive-cppcheck R20.7 member-access operator */ #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L From patchwork Tue Dec 20 08:50:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077644 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 53125C4332F for ; Tue, 20 Dec 2022 08:51:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466600.725580 (Exim 4.92) (envelope-from ) id 1p7YLN-0003t6-FD; Tue, 20 Dec 2022 08:51:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466600.725580; Tue, 20 Dec 2022 08:51:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YLN-0003s5-3M; Tue, 20 Dec 2022 08:51:25 +0000 Received: by outflank-mailman (input) for mailman id 466600; Tue, 20 Dec 2022 08:51:23 +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 1p7YLL-0001kP-MS for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:23 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 7aa15c4f-8043-11ed-8fd4-01056ac49cbb; Tue, 20 Dec 2022 09:51:22 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 242B8FEC; Tue, 20 Dec 2022 00:52:03 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1A7AA3F71A; Tue, 20 Dec 2022 00:51:20 -0800 (PST) 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: 7aa15c4f-8043-11ed-8fd4-01056ac49cbb From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [RFC PATCH 08/18] xen: cppcheck: misra rule 20.7 deviation on init.h Date: Tue, 20 Dec 2022 08:50:50 +0000 Message-Id: <20221220085100.22848-9-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found violations of rule 20.7 for the macros __init_call, presmp_initcall, __initcall and __exitcall. For the first one, the macro parameter is never used as an expression, it is used for text substitution but cppcheck is not taking into account the context of use of the argument, so we can suppress the finding. For the other findings, the argument is not used as an expression, but adding parenthesis doesn't harm the code or the readability, hence add parenthesis on the argument. Eclair and coverity does not report these findings. Signed-off-by: Luca Fancellu --- xen/include/xen/init.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xen/include/xen/init.h b/xen/include/xen/init.h index 0af0e234ec80..7c072b7c8cf8 100644 --- a/xen/include/xen/init.h +++ b/xen/include/xen/init.h @@ -15,6 +15,7 @@ #define __initconstrel __section(".init.rodata.rel") #define __exitdata __used_section(".exit.data") #define __initsetup __used_section(".init.setup") +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define __init_call(lvl) __used_section(".initcall" lvl ".init") #define __exit_call __used_section(".exitcall.exit") @@ -65,11 +66,11 @@ typedef int (*initcall_t)(void); typedef void (*exitcall_t)(void); #define presmp_initcall(fn) \ - const static initcall_t __initcall_##fn __init_call("presmp") = fn + const static initcall_t __initcall_##fn __init_call("presmp") = (fn) #define __initcall(fn) \ - const static initcall_t __initcall_##fn __init_call("1") = fn + const static initcall_t __initcall_##fn __init_call("1") = (fn) #define __exitcall(fn) \ - static exitcall_t __exitcall_##fn __exit_call = fn + static exitcall_t __exitcall_##fn __exit_call = (fn) void do_presmp_initcalls(void); void do_initcalls(void); From patchwork Tue Dec 20 08:50:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077646 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 7D90CC10F1E for ; Tue, 20 Dec 2022 08:51:35 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466601.725590 (Exim 4.92) (envelope-from ) id 1p7YLO-0004Dh-PP; Tue, 20 Dec 2022 08:51:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466601.725590; Tue, 20 Dec 2022 08:51:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YLO-0004D0-Iu; Tue, 20 Dec 2022 08:51:26 +0000 Received: by outflank-mailman (input) for mailman id 466601; Tue, 20 Dec 2022 08:51:25 +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 1p7YLM-0001kP-U7 for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:24 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 7b6174c3-8043-11ed-8fd4-01056ac49cbb; Tue, 20 Dec 2022 09:51:24 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 73D4F13D5; Tue, 20 Dec 2022 00:52:04 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 687123F71A; Tue, 20 Dec 2022 00:51:22 -0800 (PST) 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: 7b6174c3-8043-11ed-8fd4-01056ac49cbb From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [RFC PATCH 09/18] xen: cppcheck: misra rule 20.7 deviation on kconfig.h Date: Tue, 20 Dec 2022 08:50:51 +0000 Message-Id: <20221220085100.22848-10-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found a violation of rule 20.7 for the macro __config_enabled but the preprocessor branch where this macro is defined should not be analysed by cppcheck when CPPCHECK macro is defined, hence this is a false positive of the tool and we can safely suppress the finding. Eclair and coverity does not report this finding. Signed-off-by: Luca Fancellu --- docs/misra/false-positive-cppcheck.json | 7 +++++++ xen/include/xen/kconfig.h | 1 + 2 files changed, 8 insertions(+) diff --git a/docs/misra/false-positive-cppcheck.json b/docs/misra/false-positive-cppcheck.json index 5e7d9377f60b..c8ee3c0c6317 100644 --- a/docs/misra/false-positive-cppcheck.json +++ b/docs/misra/false-positive-cppcheck.json @@ -17,6 +17,13 @@ }, { "id": "SAF-2-false-positive-cppcheck", + "violation-id": "misra-c2012-20.7", + "tool-version": "2.7", + "name": "R20.7 on preprocessor branch that should be disabled", + "text": "This preprocessor branch should be disabled when CPPCHECK macro is active, so there should not be violation." + }, + { + "id": "SAF-3-false-positive-cppcheck", "violation-id": "", "tool-version": "", "name": "Sentinel", diff --git a/xen/include/xen/kconfig.h b/xen/include/xen/kconfig.h index a717b0819c2e..92373c018950 100644 --- a/xen/include/xen/kconfig.h +++ b/xen/include/xen/kconfig.h @@ -23,6 +23,7 @@ #define __ARG_PLACEHOLDER_1 0, #define config_enabled(cfg) _config_enabled(cfg) #define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value) +/* SAF-2-false-positive-cppcheck R20.7 but cppcheck should not check here */ #define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0) #define ___config_enabled(__ignored, val, ...) val From patchwork Tue Dec 20 08:50:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077645 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 2E435C3DA79 for ; Tue, 20 Dec 2022 08:51:35 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466602.725595 (Exim 4.92) (envelope-from ) id 1p7YLP-0004Id-Ak; Tue, 20 Dec 2022 08:51:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466602.725595; Tue, 20 Dec 2022 08:51:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YLP-0004Hy-1S; Tue, 20 Dec 2022 08:51:27 +0000 Received: by outflank-mailman (input) for mailman id 466602; Tue, 20 Dec 2022 08:51:26 +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 1p7YLO-0001kV-6P for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:26 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 7bd94a8b-8043-11ed-91b6-6bf2151ebd3b; Tue, 20 Dec 2022 09:51:25 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C38651688; Tue, 20 Dec 2022 00:52:05 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B7C8B3F71A; Tue, 20 Dec 2022 00:51:23 -0800 (PST) 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: 7bd94a8b-8043-11ed-91b6-6bf2151ebd3b From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [RFC PATCH 10/18] xen: cppcheck: misra rule 20.7 deviation on types.h Date: Tue, 20 Dec 2022 08:50:52 +0000 Message-Id: <20221220085100.22848-11-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found a violation of rule 20.7 for the macro DECLARE_BITMAP, but the macro parameter is used as variable identifier, so it is safe to suppress the finding and don't put parenthesis. Eclair and coverity does not report this finding. Signed-off-by: Luca Fancellu --- xen/include/xen/types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/include/xen/types.h b/xen/include/xen/types.h index 03f0fe612ed9..c734a52f24b1 100644 --- a/xen/include/xen/types.h +++ b/xen/include/xen/types.h @@ -7,6 +7,7 @@ #define BITS_TO_LONGS(bits) \ (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG) +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define DECLARE_BITMAP(name,bits) \ unsigned long name[BITS_TO_LONGS(bits)] From patchwork Tue Dec 20 08:50:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077647 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 7646DC4332F for ; Tue, 20 Dec 2022 08:51:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466605.725611 (Exim 4.92) (envelope-from ) id 1p7YLS-00050Y-Ua; Tue, 20 Dec 2022 08:51:30 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466605.725611; Tue, 20 Dec 2022 08:51:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YLS-0004yp-Nr; Tue, 20 Dec 2022 08:51:30 +0000 Received: by outflank-mailman (input) for mailman id 466605; Tue, 20 Dec 2022 08:51:29 +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 1p7YLQ-0001kP-ET for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:28 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 7cf44f55-8043-11ed-8fd4-01056ac49cbb; Tue, 20 Dec 2022 09:51:26 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1EF40FEC; Tue, 20 Dec 2022 00:52:07 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 13AF73F71A; Tue, 20 Dec 2022 00:51:24 -0800 (PST) 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: 7cf44f55-8043-11ed-8fd4-01056ac49cbb From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [RFC PATCH 11/18] xen: cppcheck: misra rule 20.7 deviation on xmalloc.h Date: Tue, 20 Dec 2022 08:50:53 +0000 Message-Id: <20221220085100.22848-12-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found violations of rule 20.7 for the macros xmalloc, xzalloc, xmalloc_array, xzalloc_array, xzalloc_flex_struct and xmalloc_flex_struct. In all the cases the macro parameters are never used as an expression, so it is safe to suppress the findings. Eclair and coverity does not report these findings. Signed-off-by: Luca Fancellu --- xen/include/xen/xmalloc.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xen/include/xen/xmalloc.h b/xen/include/xen/xmalloc.h index 16979a117c6a..5bf440502c20 100644 --- a/xen/include/xen/xmalloc.h +++ b/xen/include/xen/xmalloc.h @@ -10,7 +10,9 @@ */ /* Allocate space for typed object. */ +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type))) +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define xzalloc(_type) ((_type *)_xzalloc(sizeof(_type), __alignof__(_type))) /* @@ -30,15 +32,19 @@ }) /* Allocate space for array of typed objects. */ +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define xmalloc_array(_type, _num) \ ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num)) +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define xzalloc_array(_type, _num) \ ((_type *)_xzalloc_array(sizeof(_type), __alignof__(_type), _num)) /* Allocate space for a structure with a flexible array of typed objects. */ +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define xzalloc_flex_struct(type, field, nr) \ ((type *)_xzalloc(offsetof(type, field[nr]), __alignof__(type))) +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define xmalloc_flex_struct(type, field, nr) \ ((type *)_xmalloc(offsetof(type, field[nr]), __alignof__(type))) From patchwork Tue Dec 20 08:50:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077648 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 B01A5C10F1E for ; Tue, 20 Dec 2022 08:51:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466606.725615 (Exim 4.92) (envelope-from ) id 1p7YLT-00054U-K1; Tue, 20 Dec 2022 08:51:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466606.725615; Tue, 20 Dec 2022 08:51: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 1p7YLT-000538-5P; Tue, 20 Dec 2022 08:51:31 +0000 Received: by outflank-mailman (input) for mailman id 466606; Tue, 20 Dec 2022 08:51: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 1p7YLQ-0001kV-J0 for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:28 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 7d4575f3-8043-11ed-91b6-6bf2151ebd3b; Tue, 20 Dec 2022 09:51:27 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 392AD13D5; Tue, 20 Dec 2022 00:52:08 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 62E6A3F71A; Tue, 20 Dec 2022 00:51:26 -0800 (PST) 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: 7d4575f3-8043-11ed-91b6-6bf2151ebd3b From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [RFC PATCH 12/18] arm: cppcheck: misra rule 20.7 deviation on asm/arm64/sysregs.h Date: Tue, 20 Dec 2022 08:50:54 +0000 Message-Id: <20221220085100.22848-13-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found a violation of rule 20.7 for the macro WRITE_SYSREG64, the macro parameter "v" is never used in an expression, but adding parenthesis to it doesn't harm the code or the readability, so add parenthesis to it. Eclair and coverity does not report this finding. Signed-off-by: Luca Fancellu --- xen/arch/arm/include/asm/arm64/sysregs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/include/asm/arm64/sysregs.h b/xen/arch/arm/include/asm/arm64/sysregs.h index 463899951414..3f709d26a299 100644 --- a/xen/arch/arm/include/asm/arm64/sysregs.h +++ b/xen/arch/arm/include/asm/arm64/sysregs.h @@ -461,7 +461,7 @@ /* Access to system registers */ #define WRITE_SYSREG64(v, name) do { \ - uint64_t _r = v; \ + uint64_t _r = (v); \ asm volatile("msr "__stringify(name)", %0" : : "r" (_r)); \ } while (0) #define READ_SYSREG64(name) ({ \ From patchwork Tue Dec 20 08:50:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077649 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 BDC4EC10F1E for ; Tue, 20 Dec 2022 08:51:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466608.725623 (Exim 4.92) (envelope-from ) id 1p7YLV-0005LU-PM; Tue, 20 Dec 2022 08:51:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466608.725623; Tue, 20 Dec 2022 08:51:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YLU-0005H5-9Z; Tue, 20 Dec 2022 08:51:32 +0000 Received: by outflank-mailman (input) for mailman id 466608; Tue, 20 Dec 2022 08:51:29 +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 1p7YLR-0001kP-OY for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:29 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 7e493ca0-8043-11ed-8fd4-01056ac49cbb; Tue, 20 Dec 2022 09:51:29 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 52F90FEC; Tue, 20 Dec 2022 00:52:09 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7D32F3F71A; Tue, 20 Dec 2022 00:51:27 -0800 (PST) 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: 7e493ca0-8043-11ed-8fd4-01056ac49cbb From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [RFC PATCH 13/18] public/x86: cppcheck: misra rule 20.7 deviation on hvm/save.h Date: Tue, 20 Dec 2022 08:50:55 +0000 Message-Id: <20221220085100.22848-14-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found a violation of rule 20.7 for the macro XEN_HVM_VIOAPIC, but the first macro argument is never used as an expression, cppcheck is not taking into account the context of use for it, so we can suppress the finding. Eclair and coverity does not report this finding. Signed-off-by: Luca Fancellu --- xen/include/public/arch-x86/hvm/save.h | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/include/public/arch-x86/hvm/save.h b/xen/include/public/arch-x86/hvm/save.h index 7ecacadde165..08f221483dc8 100644 --- a/xen/include/public/arch-x86/hvm/save.h +++ b/xen/include/public/arch-x86/hvm/save.h @@ -366,6 +366,7 @@ union vioapic_redir_entry #define VIOAPIC_NUM_PINS 48 /* 16 ISA IRQs, 32 non-legacy PCI IRQS. */ +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define XEN_HVM_VIOAPIC(name, cnt) \ struct name { \ uint64_t base_address; \ From patchwork Tue Dec 20 08:50:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077650 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 A0D41C4332F for ; Tue, 20 Dec 2022 08:51:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466610.725631 (Exim 4.92) (envelope-from ) id 1p7YLX-0005gt-2L; Tue, 20 Dec 2022 08:51:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466610.725631; Tue, 20 Dec 2022 08:51:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YLV-0005bU-Uf; Tue, 20 Dec 2022 08:51:33 +0000 Received: by outflank-mailman (input) for mailman id 466610; Tue, 20 Dec 2022 08:51:30 +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 1p7YLS-0001kP-PS for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:30 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 7ee2d949-8043-11ed-8fd4-01056ac49cbb; Tue, 20 Dec 2022 09:51:30 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6BD0E13D5; Tue, 20 Dec 2022 00:52:10 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9701D3F71A; Tue, 20 Dec 2022 00:51:28 -0800 (PST) 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: 7ee2d949-8043-11ed-8fd4-01056ac49cbb From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [RFC PATCH 14/18] public/x86: cppcheck: misra rule 20.7 deviation on xen-x86_32.h Date: Tue, 20 Dec 2022 08:50:56 +0000 Message-Id: <20221220085100.22848-15-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found violations of rule 20.7 for the macros ___DEFINE_XEN_GUEST_HANDLE, set_xen_guest_handle_raw, __DECL_REG_LO8 and __DECL_REG_LO16. For set_xen_guest_handle_raw, while the "val" argument is never used in an expression, it doesn't harm the code or the readability to add parenthesis, so add them to the argument. For the other findings, the macro parameters are never used as an expression, cppcheck is not taking into account the context for their use, so we can suppress the finding. Eclair and coverity does not report these findings. Signed-off-by: Luca Fancellu --- xen/include/public/arch-x86/xen-x86_32.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xen/include/public/arch-x86/xen-x86_32.h b/xen/include/public/arch-x86/xen-x86_32.h index 139438e83534..6755f12044e4 100644 --- a/xen/include/public/arch-x86/xen-x86_32.h +++ b/xen/include/public/arch-x86/xen-x86_32.h @@ -74,6 +74,7 @@ /* 32-/64-bit invariability for control interfaces (domctl/sysctl). */ #if defined(__XEN__) || defined(__XEN_TOOLS__) #undef ___DEFINE_XEN_GUEST_HANDLE +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ typedef struct { type *p; } \ __guest_handle_ ## name; \ @@ -82,7 +83,7 @@ #undef set_xen_guest_handle_raw #define set_xen_guest_handle_raw(hnd, val) \ do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0; \ - (hnd).p = val; \ + (hnd).p = (val); \ } while ( 0 ) #define int64_aligned_t int64_t __attribute__((aligned(8))) #define uint64_aligned_t uint64_t __attribute__((aligned(8))) @@ -96,6 +97,7 @@ /* nothing */ #elif defined(__XEN__) || defined(__XEN_TOOLS__) /* Anonymous unions include all permissible names (e.g., al/ah/ax/eax). */ +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define __DECL_REG_LO8(which) union { \ uint32_t e ## which ## x; \ uint16_t which ## x; \ @@ -104,6 +106,7 @@ uint8_t which ## h; \ }; \ } +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define __DECL_REG_LO16(name) union { \ uint32_t e ## name, _e ## name; \ uint16_t name; \ From patchwork Tue Dec 20 08:50:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077653 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 B396BC4332F for ; Tue, 20 Dec 2022 08:55:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466676.725691 (Exim 4.92) (envelope-from ) id 1p7YPB-0003Hh-Ti; Tue, 20 Dec 2022 08:55:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466676.725691; Tue, 20 Dec 2022 08:55:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YPB-0003HV-Pu; Tue, 20 Dec 2022 08:55:21 +0000 Received: by outflank-mailman (input) for mailman id 466676; Tue, 20 Dec 2022 08:55:20 +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 1p7YLU-0001kP-K3 for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:32 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 7f8a504d-8043-11ed-8fd4-01056ac49cbb; Tue, 20 Dec 2022 09:51:31 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 843961688; Tue, 20 Dec 2022 00:52:11 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AFB6D3F71A; Tue, 20 Dec 2022 00:51:29 -0800 (PST) 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: 7f8a504d-8043-11ed-8fd4-01056ac49cbb From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [RFC PATCH 15/18] public/x86: cppcheck: misra rule 20.7 deviation on xen-x86_64.h Date: Tue, 20 Dec 2022 08:50:57 +0000 Message-Id: <20221220085100.22848-16-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found violations of rule 20.7 for the macros __DECL_REG_LOHI, __DECL_REG_LO8 and __DECL_REG_LO16, but the macro parameters are used as variable identifiers, so it is safe to suppress the findings. Eclair and coverity does not report these findings. Signed-off-by: Luca Fancellu --- xen/include/public/arch-x86/xen-x86_64.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/include/public/arch-x86/xen-x86_64.h b/xen/include/public/arch-x86/xen-x86_64.h index 5d9035ed2230..7e375cd6f45f 100644 --- a/xen/include/public/arch-x86/xen-x86_64.h +++ b/xen/include/public/arch-x86/xen-x86_64.h @@ -115,6 +115,7 @@ struct iret_context { #if defined(__XEN__) || defined(__XEN_TOOLS__) /* Anonymous unions include all permissible names (e.g., al/ah/ax/eax/rax). */ +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define __DECL_REG_LOHI(which) union { \ uint64_t r ## which ## x; \ uint32_t e ## which ## x; \ @@ -124,12 +125,14 @@ struct iret_context { uint8_t which ## h; \ }; \ } +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define __DECL_REG_LO8(name) union { \ uint64_t r ## name; \ uint32_t e ## name; \ uint16_t name; \ uint8_t name ## l; \ } +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define __DECL_REG_LO16(name) union { \ uint64_t r ## name; \ uint32_t e ## name; \ From patchwork Tue Dec 20 08:50:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077654 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 B2CDBC4332F for ; Tue, 20 Dec 2022 08:55:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466711.725702 (Exim 4.92) (envelope-from ) id 1p7YPU-00042g-6f; Tue, 20 Dec 2022 08:55:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466711.725702; Tue, 20 Dec 2022 08:55:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YPU-00042X-2J; Tue, 20 Dec 2022 08:55:40 +0000 Received: by outflank-mailman (input) for mailman id 466711; Tue, 20 Dec 2022 08:55:39 +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 1p7YLY-0001kV-AJ for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:36 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 7ff5cb8b-8043-11ed-91b6-6bf2151ebd3b; Tue, 20 Dec 2022 09:51:31 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9CB1D168F; Tue, 20 Dec 2022 00:52:12 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C82883F71A; Tue, 20 Dec 2022 00:51:30 -0800 (PST) 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: 7ff5cb8b-8043-11ed-91b6-6bf2151ebd3b From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [RFC PATCH 16/18] public/x86: cppcheck: misra rule 20.7 deviation on arch-x86/xen.h Date: Tue, 20 Dec 2022 08:50:58 +0000 Message-Id: <20221220085100.22848-17-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found violations of rule 20.7 for the macros ___DEFINE_XEN_GUEST_HANDLE and set_xen_guest_handle_raw. For the first one, the macro parameters are never used as an expression, so it is safe to suppress the finding. For the second one, while the argument "val" is never used in an expression, it doesn't harm the code or the readability, so add them. Eclair and coverity does not report these findings. Signed-off-by: Luca Fancellu --- xen/include/public/arch-x86/xen.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/include/public/arch-x86/xen.h b/xen/include/public/arch-x86/xen.h index c0f4551247f4..04f5bc899ae3 100644 --- a/xen/include/public/arch-x86/xen.h +++ b/xen/include/public/arch-x86/xen.h @@ -14,6 +14,7 @@ /* Structural guest handles introduced in 0x00030201. */ #if __XEN_INTERFACE_VERSION__ >= 0x00030201 +/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */ #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ typedef struct { type *p; } __guest_handle_ ## name #else @@ -36,7 +37,7 @@ #define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name #define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name) #define XEN_GUEST_HANDLE_PARAM(name) XEN_GUEST_HANDLE(name) -#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = val; } while (0) +#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = (val); } while (0) #define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val) #if defined(__i386__) From patchwork Tue Dec 20 08:50:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077651 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 3EBF5C4167B for ; Tue, 20 Dec 2022 08:55:25 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466669.725680 (Exim 4.92) (envelope-from ) id 1p7YOz-0002lV-KP; Tue, 20 Dec 2022 08:55:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466669.725680; Tue, 20 Dec 2022 08:55:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YOz-0002lO-Hd; Tue, 20 Dec 2022 08:55:09 +0000 Received: by outflank-mailman (input) for mailman id 466669; Tue, 20 Dec 2022 08:55:08 +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 1p7YLa-0001kV-8j for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:38 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 80b00519-8043-11ed-91b6-6bf2151ebd3b; Tue, 20 Dec 2022 09:51:33 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EBDE31688; Tue, 20 Dec 2022 00:52:13 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E10413F71A; Tue, 20 Dec 2022 00:51:31 -0800 (PST) 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: 80b00519-8043-11ed-91b6-6bf2151ebd3b From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [RFC PATCH 17/18] public: misra rule 20.7 deviation on errno.h Date: Tue, 20 Dec 2022 08:50:59 +0000 Message-Id: <20221220085100.22848-18-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found a violation of rule 20.7 for the macro XEN_ERRNO, while the macro parameter is never used as an expression, it doesn't harm the code or the readability to add parenthesis, so add them. This finding is reported also by eclair and coverity. Signed-off-by: Luca Fancellu Acked-by: Jan Beulich --- xen/include/public/errno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/public/errno.h b/xen/include/public/errno.h index 6bdc8c507990..5a78a7607c0d 100644 --- a/xen/include/public/errno.h +++ b/xen/include/public/errno.h @@ -31,7 +31,7 @@ #ifndef __ASSEMBLY__ -#define XEN_ERRNO(name, value) XEN_##name = value, +#define XEN_ERRNO(name, value) XEN_##name = (value), enum xen_errno { #elif __XEN_INTERFACE_VERSION__ < 0x00040700 From patchwork Tue Dec 20 08:51:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13077652 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 377A2C4332F for ; Tue, 20 Dec 2022 08:55:25 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466665.725668 (Exim 4.92) (envelope-from ) id 1p7YOy-0002W8-Dt; Tue, 20 Dec 2022 08:55:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466665.725668; Tue, 20 Dec 2022 08:55:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7YOy-0002W4-Ad; Tue, 20 Dec 2022 08:55:08 +0000 Received: by outflank-mailman (input) for mailman id 466665; Tue, 20 Dec 2022 08:55:07 +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 1p7YLb-0001kV-A2 for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 08:51:39 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 8178a9a1-8043-11ed-91b6-6bf2151ebd3b; Tue, 20 Dec 2022 09:51:34 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 45730168F; Tue, 20 Dec 2022 00:52:15 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3C02F3F71A; Tue, 20 Dec 2022 00:51:33 -0800 (PST) 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: 8178a9a1-8043-11ed-91b6-6bf2151ebd3b From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [RFC PATCH 18/18] public: misra rule 20.7 deviation on memory.h Date: Tue, 20 Dec 2022 08:51:00 +0000 Message-Id: <20221220085100.22848-19-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221220085100.22848-1-luca.fancellu@arm.com> References: <20221220085100.22848-1-luca.fancellu@arm.com> Cppcheck has found a violation of rule 20.7 for the macro XENMEM_SHARING_OP_FIELD_MAKE_GREF, the argument "val" is used in an expression, hence add parenthesis to the argument "val" to fix the violation. Signed-off-by: Luca Fancellu Acked-by: Jan Beulich --- xen/include/public/memory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h index 29cf5c823902..c5f0d31e235d 100644 --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -485,7 +485,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_mem_access_op_t); #define XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG (xen_mk_ullong(1) << 62) #define XENMEM_SHARING_OP_FIELD_MAKE_GREF(field, val) \ - (field) = (XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG | val) + (field) = (XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG | (val)) #define XENMEM_SHARING_OP_FIELD_IS_GREF(field) \ ((field) & XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG) #define XENMEM_SHARING_OP_FIELD_GET_GREF(field) \