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 1F0B0E92FFA for ; Fri, 6 Oct 2023 09:17:05 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.613402.953878 (Exim 4.92) (envelope-from ) id 1qogww-0005hk-7h; Fri, 06 Oct 2023 09:16:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 613402.953878; Fri, 06 Oct 2023 09:16:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qogww-0005hd-4P; Fri, 06 Oct 2023 09:16:46 +0000 Received: by outflank-mailman (input) for mailman id 613402; Fri, 06 Oct 2023 09:16:44 +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 1qogwu-0005Di-EU for xen-devel@lists.xenproject.org; Fri, 06 Oct 2023 09:16:44 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 10f2d78a-6429-11ee-98d3-6d05b1d4d9a1; Fri, 06 Oct 2023 11:16:43 +0200 (CEST) Received: from support.bugseng.com (support.bugseng.com [162.55.131.47]) by support.bugseng.com (Postfix) with ESMTPA id 13A064EE0738; Fri, 6 Oct 2023 11:16:43 +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: 10f2d78a-6429-11ee-98d3-6d05b1d4d9a1 MIME-Version: 1.0 Date: Fri, 06 Oct 2023 11:16:43 +0200 From: Nicola Vetrini To: Xen-devel Cc: Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , consulting@bugseng.com Subject: Rule 10.1 violations in perfc_incra and PERFCOUNTER_ARRAY User-Agent: Roundcube Webmail/1.4.3 Message-ID: <5cfaaaceb163af3244981b020ed55f3f@bugseng.com> X-Sender: nicola.vetrini@bugseng.com Organization: BUGSENG s.r.l. Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Given the following macros in and #define perfc_incra(x,y) \ ( (y) <= PERFC_LAST_ ## x - PERFC_ ## x ? \ ++this_cpu(perfcounters)[PERFC_ ## x + (y)] : 0 ) and the following violation xen/arch/arm/traps.c:1407.5-1407.32: reference to enum constant `PERFC_hypercalls' has essential type `enum perfcounter' and standard type `int' :11606.29-11606.44: preprocessed tokens :137.1-137.16: expanded from macro `PERFC_' xen/include/xen/perfc.h:69.35-69.45: expanded from macro `perfc_incra' xen/arch/arm/traps.c:1407.5-1407.32: `+' addition operator expects a number or a character :11606.46: preprocessed tokens xen/include/xen/perfc.h:69.47: expanded from macro `perfc_incra' the difference between enumerated values is forbidden by the Rule. In the coding standard's interpretation, named enums are unordered list of symbols, which can only be compared for equality. There are a few possible paths forward: 1. use means different from named enums to generate these constants (such as #define-s or constants integers); 2. explicitly deviate subtraction of enums, therefore defining an explicit ordering on enumerated values; 3. use an unnamed enum, effectively considering the enumerated values as plain integers. This does not violate the Rule. Similarly the sum in #define PERFCOUNTER_ARRAY( name, descr, size ) \ PERFC_##name, \ PERFC_LAST_##name = PERFC_ ## name + (size) - sizeof(char[2 * !!(size) - 1]), causes other analogous violations. Lastly, this is a concern that manifested only in ARM code, but does not seem to be related to ARM-specific files, so there is perhaps some difference in the configuration of the two analyzed builds. -- Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)