From nobody Mon Nov 23 22:28:43 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; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1794944191; cv=pass; d=zohomail.com; s=zohoarc; b=FUqWYpIvpfby5K9A9EbYh45JiMIxWMeze2I8sv2FjjbIqmpQ2am87Ib2wNWLtyusiz7uWmiQEod1qEAqGRUvUVqh5RG/9h6ZaW9PHqVov2hmU77ah6qO/9T6iL8UPtJAfyWAObzF12ZOSDNWi8zsmy3Yj5SmEhgnjggT4dIovu8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794944191; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qDDzvay385CUNjb72j2EhJns+cfktYW1MWGlf4e3lWs=; b=JOGSHmnIpReASkY6q0jSR9ascVdzzMeZSF4ZDNPNiMERm4rFk2ZVxRlXUFr2ozs95sfqWBrvAHQoph5mGL/EdS51WiRJdJPkaHPvkAKlf52am+kI579knqJ2AZP3n0tSpW9vr42jhqYaFv6yHjIEozmIR8ZfCVrN7rVMdYglZvs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1794944191014289.62710090141013; Tue, 17 Nov 2026 11:36:31 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1493107.1693237 (Exim 4.92) (envelope-from ) id 1xTOy9-00045A-7J; Tue, 17 Nov 2026 19:35:53 +0000 Received: by outflank-mailman (output) from mailman id 1493107.1693237; Tue, 17 Nov 2026 19:35:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xTOy9-000453-4R; Tue, 17 Nov 2026 19:35:53 +0000 Received: by outflank-mailman (input) for mailman id 1493107; Tue, 17 Nov 2026 19:35:51 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xTOy7-00044x-7c for xen-devel@lists.xenproject.org; Tue, 17 Nov 2026 19:35:51 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xTOy6-00BycX-K6 for xen-devel@lists.xenproject.org; Tue, 17 Nov 2026 20:35:50 +0100 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6afcac81-2eae-0a2a0a5409dd-0a2a4505c65a-32 for ; Tue, 17 Nov 2026 20:35:50 +0100 Received: from [52.101.84.85] (helo=DB3PR0202CU003.outbound.protection.outlook.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6afcac96-4cb1-0a2a45050019-346554553e73-3 for ; Tue, 17 Nov 2026 20:35:50 +0100 Received: from AM9PR03MB7526.eurprd03.prod.outlook.com (2603:10a6:20b:3de::17) by CPHPR03MB395035.eurprd03.prod.outlook.com (2603:10a6:380:107::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.615.14; Tue, 17 Nov 2026 19:35:47 +0000 Received: from AM9PR03MB7526.eurprd03.prod.outlook.com ([fe80::904d:5820:80e1:41ba]) by AM9PR03MB7526.eurprd03.prod.outlook.com ([fe80::904d:5820:80e1:41ba%3]) with mapi id 15.21.0592.009; Tue, 17 Nov 2026 19:35:47 +0000 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fwTdfvYLYb4Gjq2U/YWnRA2oZa2KvSFMUL2iNfSY4BTQEBz0n3TSPNstIQFrlp0ypQHfxwTbyNV318SCUUiOZHoMZFpfY36Op3vPcon19Mv59RCPT4X1r1L3nmMC1Feplr2s3KjrpOpEfgZdVSHMeMA+26I7JqvQdRp+I0QnFAFomlkkvI9bLQeCiDbpNmVtDNBeH0NUWloRV2eJz/2+V7MD4vGajve6czsSt8zp7FASLlR3hbtdYKXDTlS480NfDX5NmD08CNLRTynTgtIAji/UvdRFOtKHJOroiC8O2M1kiN3FJarzVFNNWIif7dhwCBVMsD8bakrg4siyp//JiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qDDzvay385CUNjb72j2EhJns+cfktYW1MWGlf4e3lWs=; b=JdAkgvuOHLkNgDr7F7eDW0egA0EVrvh+l8whzpg9B8lTQP4nEJ9CvlOnZ0EocSm83jjjuCA7hnGHLf1gwGRAkCMtqzlKnNaH1RqoKk0cv208IIjjgvEfXzZSjwt81r+3I1zMEXmhCLjfOaYEiZuJlATSzZnC41IACqZW9B9qJzwW6Hh3RDKB/ZDElS+7eBc8i4YkL0rbqzHtsmzdia4ByRyZ6BK64RJm2d5wF1YzlG9HXbYMpGgpFqXktDWTrMx8cXhuHrUz8JZpRf1UOXEtf6KJ7W0yochZcRhOpuYebqKVkzxaHE7SH1DymVoSA+n/ZBComm1Se5v4DwiS2H62nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qDDzvay385CUNjb72j2EhJns+cfktYW1MWGlf4e3lWs=; b=USUN7ZIqxhW66+0z7kGQ2tge1VuG6X+5Vi9KKS30tzpvk+JDsaL0FPvInZQhtSTiHHyWfUq2oWkVwbHVIvNRZF67rRRlpYplTE/6oGi9J2oSwf7TOKWQ00y9A/uVfQM4ublHQgabhundVaDYrXIid/8nNE/7F7it6Gr9OQb1G8JLRfNOvyy7AE1WUvvWjWxRQVgvqY1WFawj8QafQPJvjIztYbDlejjd1MPerKFIIvQjcL9LE2ZFiOHs+jyLunY7OgPQ2b732fm7hzZugLlUATc52vNOunbBmrnhd5O5LY6jsrqDvPoPBWWUpRmzYt1YkshHto3qbValmfMHk432qQ== From: Dmytro Prokopchuk1 To: "xen-devel@lists.xenproject.org" CC: Dmytro Prokopchuk1 , Nicola Vetrini , Doug Goldstein , Stefano Stabellini , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?B?Um9nZXIgUGF1IE1vbm7DqQ==?= Subject: [PATCH v3] misra: deviate MISRA C Rule 10.1 for boolean operands of arithmetic Thread-Topic: [PATCH v3] misra: deviate MISRA C Rule 10.1 for boolean operands of arithmetic Thread-Index: AQHddsrYLaVRJihQEUu25Hr3vcjlcw== Date: Tue, 17 Nov 2026 19:35:47 +0000 Message-ID: Accept-Language: en-US, uk-UA, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM9PR03MB7526:EE_|CPHPR03MB395035:EE_ x-ms-office365-filtering-correlation-id: 2ab8aa0e-5afb-4495-9e96-08df44e1faa1 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|23010399003|42112799006|366016|1800799024|7416014|376014|18002099003|6133799003|261009221227099003|261009223027099003|3023799007|260925022911599003|11063799006|260925021911599003|56012099006|260925021311599003|261028144727099003|261102123227099003|261022105027099003|261026140227099003|261026121527099003|261022075727099003|261021123027099003|261021121427099003|38070700021|261102124527099003|10067099003; x-microsoft-antispam-message-info: fl8FisIGlr2ZbbQ38BBPbUaBTkp4sCFdC2HNBNlBoD4ntTICLGUR6uzZntdMtC2h8xQrJuL4WwOX/+G3y6eXD9tP+ohI8ghbVxVGQY2S69DYIGhv2UVQsWqs5wY7aqcl7RjvMyBM+/DY33VSg2aF7FnL8oh3KBe3MbK+DI5xbhy+vhxw+PgCwfmafkmIoP1dSy1c993Got42OH3XeC7NERuj69MfF94ZYJBq4EZG/38UZ0I7cP9d1gLmNHRvPDn25e/f8FxwXvSh9fizTGQmmYjcPwE4lO5nDGORwandMvLUyOKOHQKrIG7jy0NdZLE7ByV25t0+w5/AX4OeXnHaUoLyWx850fOpxh/pNj/sTmqDta2VMVUzpRecWfXT/rUk6Vg9G0HG8kr8DSxNXGqvQCqkpA/f0uWSepWt9yLhxR1XtX1oexPis5TQx9UNAvP7s9BRaYXoXWmQq6eBj5OtDJGeNqMnrSHB4DhJRLapRjP/mQPsYiPUNuOakaTWYsu9bhudM1icyDZjI12ODTVJBJsZQlwsU0ZvAY3mSM3Hb5ykCB8pjGe4CSlgwgPUV50NnhU2ZmWMOPJvXaLQ/VNbf1oBrxOT7e4Y/O0v+qxv+pWZCezqbPyFVKU/sobjG33/b/w/u0HicHX8A9DTlLxDzoqzUXZQpXC7+c4YZXk2bj5mnZpU0Brzm3+ijDKGl8+3yQd8fDKFTyquFcBr791rUnAZLLhPBmZtA01F5vbZ9Mk= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR03MB7526.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(42112799006)(366016)(1800799024)(7416014)(376014)(18002099003)(6133799003)(261009221227099003)(261009223027099003)(3023799007)(260925022911599003)(11063799006)(260925021911599003)(56012099006)(260925021311599003)(261028144727099003)(261102123227099003)(261022105027099003)(261026140227099003)(261026121527099003)(261022075727099003)(261021123027099003)(261021121427099003)(38070700021)(261102124527099003)(10067099003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?B?NTlOWEQrdWtUSzZ5dVN4U0FCaFEzUWwxNDdONU5zSnYwd29WYVZPWSt4cld6?= =?utf-8?B?d3ozbkNlNys1aUtVM3hsWmFpa056RkU1bW1EdVYrYk9kTVRReWd5cGU5L0Qy?= =?utf-8?B?SkZVYXdsM1pUUkkrMDB0U0o2OGtMbFR1K28wMS9hdW50MWovUW1VTWxnTVRR?= =?utf-8?B?d0FjSUU1V3V5WVVQeEZSYzBGdzVuVDhXMi82YXIxclQxekpPQm9ZZTZiNU5G?= =?utf-8?B?aDB2a1dzT25OWnlIN3RTbTJOVDFWd3BHQWFiekl3MXdYUHVnT3VWVEY2M3Yw?= =?utf-8?B?VmR2TjE3K1d5dFdVK3pNbUYzN1AyU21yNE5uMz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GV1WWJDZHlraStmeTlwYWJOWkU4aTJuK3lVVzBBZko3VU40VUhn?= =?utf-8?B?dnZtZ2pBeTloeGVFV1ArQ2dKSnNLbHlHSG8vWUtMbVFnOTlrbjZrNDBFT2ww?= =?utf-8?B?RXhoYWFpQ0NYbzdyOFlkd2d1OVBZbWJ1SityTEk4bUFFdk9oRUhaWEZTc1RP?= =?utf-8?B?QnBLRjVwVFBIelBmd2VLZjZ5VXY5UDhSNE9ZMDdZaWtnM3JyU0tlMm03bldh?= =?utf-8?Q?oVCudvPflI1CXbpM=3D?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM9PR03MB7526.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ab8aa0e-5afb-4495-9e96-08df44e1faa1 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Nov 2026 19:35:47.2653 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 0X1C5h2UtYVs7ybfif0uhgfQMZuGwWjmPfMsPQb/nLaGqMkKSBlBdvsyGktr5xyt7BFoAzR6ZaK/+UWCbHL55BJGbrrrYbVJZZ1OLOx4iA8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CPHPR03MB395035 X-purgate-ID: tlsNG-c201ff/1794944150-F5EA92A1-A638E30D/0/0 X-purgate-type: clean X-purgate-size: 7468 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1794944192703158500 MISRA C Rule 10.1 states: "Operands shall not be of an inappropriate essential type". The result of relational, equality and logical negation operators has type int and value 0 or 1 (C99 6.5.8p6, 6.5.9p3, 6.5.3.3p5). An object or function result of type bool has value 0 or 1 too, and it is promoted to int (C99 6.3.1.2, 6.3.1.1p2). Using that value as an operand of unary +, -, binary +, -, *, <<, >> and of +=3D, -=3D, *=3D, <<=3D, >>=3D is well-defined. Division, remainder, the relational operators, increment and decrement stay covered by the rule. Update the ECLAIR configuration to tag the accepted uses as safe. Update deviations.rst and rules.rst accordingly. Signed-off-by: Dmytro Prokopchuk Reviewed-by: Jan Beulich --- Test CI pipeline: https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/3080459013 Changes in v3: - include unary + and - - drop relational operators - split the ECLAIR config into one clause per operator group for readability --- .../eclair_analysis/ECLAIR/deviations.ecl | 9 +++++++++ docs/misra/deviations.rst | 20 +++++++++++++++++++ docs/misra/rules.rst | 4 ++++ 3 files changed, 33 insertions(+) diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/= eclair_analysis/ECLAIR/deviations.ecl index d49af53055..e22a05a21b 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -341,6 +341,15 @@ still non-negative." -config=3DMC3A2.R10.1,etypes+=3D{safe, "stmt(operator(logical)||node(condi= tional_operator||binary_conditional_operator))", "dst_type(ebool||boolean)"} -doc_end =20 +-doc_begin=3D"A 0-or-1 Boolean operand of unary +, -, binary +, -, *, <<, = >> and of +=3D, -=3D, *=3D, <<=3D, >>=3D is safe. See docs/misra/deviations= .rst for the full explanation." +-config=3DMC3A2.R10.1,etypes+=3D{safe, "stmt(operator(plus||minus))", "src= _type(ebool||boolean)"} +-config=3DMC3A2.R10.1,etypes+=3D{safe, "stmt(operator(add||add_assign))", = "src_type(ebool||boolean)"} +-config=3DMC3A2.R10.1,etypes+=3D{safe, "stmt(operator(sub||sub_assign))", = "src_type(ebool||boolean)"} +-config=3DMC3A2.R10.1,etypes+=3D{safe, "stmt(operator(mul||mul_assign))", = "src_type(ebool||boolean)"} +-config=3DMC3A2.R10.1,etypes+=3D{safe, "stmt(operator(shl||shl_assign))", = "src_type(ebool||boolean)"} +-config=3DMC3A2.R10.1,etypes+=3D{safe, "stmt(operator(shr||shr_assign))", = "src_type(ebool||boolean)"} +-doc_end + -doc_begin=3D"The macro ISOLATE_LSB encapsulates a well-known pattern to o= btain a mask where only the lowest bit set in the argument is set, if any, for u= nsigned integers arguments on two's complement architectures diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst index 7b983db264..6458a79a67 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -355,6 +355,26 @@ Deviations related to MISRA C:2012 Rules: well-known to all Xen developers to be a comparison with 0. - Tagged as `safe` for ECLAIR. =20 + * - R10.1 + - The result of relational, equality and logical negation operators h= as + type int and value 0 or 1 (C99 6.5.8p6, 6.5.9p3, 6.5.3.3p5). An obj= ect + or function result of type bool has value 0 or 1 too, and it is + promoted to int (C99 6.3.1.2, 6.3.1.1p2). Such a value is a + well-defined operand of the following operators. Unary + leaves it + unchanged. Unary - yields 0 or -1, all bits clear or, in two's + complement, all bits set. Binary + and - (and +=3D and -=3D) count + something if the condition holds. \* (and \*=3D) yields the other o= perand + if the condition holds and 0 otherwise. << and >> (and <<=3D and >>= =3D) + extend that selection to a shift: a Boolean left operand contribute= s 0 + or 1, and a Boolean right operand is a shift count of 0 or 1. / and= % + (and /=3D and %=3D) are excluded. A Boolean divisor is 0 when the c= ondition + is false, and division or remainder by zero is undefined behavior + (C99 6.5.5p5). The relational operators are excluded as well: with + 0-or-1 operands, whatever they express can be written with the equa= lity + and logical operators, which already accept an essentially Boolean + operand. Increment and decrement stay under the rule. + - Tagged as `safe` for ECLAIR. + * - R10.1 - Xen only supports architectures where signed integers are represent= end using two's complement and all the Xen developers are aware of this= . For diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst index 7e191a0d4a..c075fe2391 100644 --- a/docs/misra/rules.rst +++ b/docs/misra/rules.rst @@ -387,6 +387,10 @@ maintainers if you want to suggest a change. compilers' extensions) - Implicit conversions to boolean for conditionals (?: if while for) and logical operators (! || &&) + - Operands of essentially Boolean type (results of relational, + equality and logical negation operators, objects and function + results of type bool) used only with unary +, -, binary +, -, + \*, <<, >>, +=3D, -=3D, \*=3D, <<=3D and >>=3D - The essential type model allows the constants defined by anonym= ous enums (e.g., enum { A, B, C }) to be used as operands to arithm= etic operators, as they have a signed essential type. --=20 2.43.0