From patchwork Tue Apr 1 01:17:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 14034281 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 19852C3600C for ; Tue, 1 Apr 2025 01:18:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.933348.1335336 (Exim 4.92) (envelope-from ) id 1tzQGM-0007FT-HG; Tue, 01 Apr 2025 01:17:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 933348.1335336; Tue, 01 Apr 2025 01:17:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzQGM-0007FI-Ck; Tue, 01 Apr 2025 01:17:58 +0000 Received: by outflank-mailman (input) for mailman id 933348; Tue, 01 Apr 2025 01:17:57 +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 1tzQGL-0006nG-Cb for xen-devel@lists.xenproject.org; Tue, 01 Apr 2025 01:17:57 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on20630.outbound.protection.outlook.com [2a01:111:f403:2607::630]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 241708ab-0e97-11f0-9ea7-5ba50f476ded; Tue, 01 Apr 2025 03:17:55 +0200 (CEST) Received: from GV1PR03MB10456.eurprd03.prod.outlook.com (2603:10a6:150:16a::21) by PA4PR03MB6703.eurprd03.prod.outlook.com (2603:10a6:102:ec::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.46; Tue, 1 Apr 2025 01:17:52 +0000 Received: from GV1PR03MB10456.eurprd03.prod.outlook.com ([fe80::a41e:5aa8:e298:757e]) by GV1PR03MB10456.eurprd03.prod.outlook.com ([fe80::a41e:5aa8:e298:757e%4]) with mapi id 15.20.8534.043; Tue, 1 Apr 2025 01:17:52 +0000 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: 241708ab-0e97-11f0-9ea7-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nAwatLDyaajIHjiL/s5mfEpHBsbwKLOAGOTkfgtUeIMilYYDcjsWvQOs6G0zozNkMC7qGx/DG6UkH03NzM3BYapxhhiTPipH4KUXC9xU5vnqsUlhX7W1SakJEX6028VqLaZSuqoVlC8rotawfVCSEFeFyJYzi52HsyWcFyl4kJo2nZ6eVQ3l/3q4lU6czc4MKroajrfmOUGvdSBKz9xIYJtX4MOPSGsTI6Lq7vlkTr3qKJwdPjDmPBCbIBYoFxURWNycYsM7nTuAH8GO6mkWLTLQRKFdC38nQZQnEQIIklKL+6b2OJJfl8HTwBipacyiQgDBK6yOwdnf4HUKLtst/w== 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=pYY5TMzKZzk8Pg6xp60F/cK2FtqsNx/Afg43r5Pf3JM=; b=mOrbLM/vuq9wFjCobJL4h6WgP0EUf0bCNJfkVFrgQZmE/ykKUs7zmwAtf4iqjZUscF2GeZ1iPcj0TP2MXkXY1TMChrszNIuMUr3uF+Qpc8vVHAXJKsRgqVPQIQPfIimGulLsV1c7FEM7z4+zMh4guMbygkJ/PwffjnEnfbB+oNUvvMz4rrcKJ/gjxDlihybtySNigmA2kl+RrxzallUaVk9PyEGkpS93e7nHMDE6M10aS7w3GFMkGFayI7P1N3prdYrMfoLQJl3A0iiR7MU8pcfgCzRTkOkKannmsVL0cePRoVG8n88uOrBAGocyzh2w1pWnbocVbfGq9Kp7xaHNpg== 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=pYY5TMzKZzk8Pg6xp60F/cK2FtqsNx/Afg43r5Pf3JM=; b=J1h9Xh5r2iq8Gw4JEDG1f4qW7TX3eYASmChHMjhGirR4LOhMPEYBNowFLAsU+FHvWV8pUQiSiD5xTnwFAab56SY4Oyj/Oo/+38VIrihCab9C3QO42Kn+EkH3iipNM9CfyTArz9cTtaXBtNiFrKApfapXPdfUPLZHNwWt78DAw26LHbPS8Vhu1HquOv0uA0mOCo7Jw024gyXmemitf9c9Etysf8lZF1S3BN6shBpAdZKiA/0+KG29aOVOax8FjtcJJWPeOwq23jiPhT3vGyNjhZZSN6aHJq/jLeRRABYNUlFRPHmBnlvaxoTzbOqni4wfSAYfzpJVYpf3f7i/0N/qhA== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Volodymyr Babchuk , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 2/3] xen: x86: irq: use do-while loop in create_irq() Thread-Topic: [PATCH v3 2/3] xen: x86: irq: use do-while loop in create_irq() Thread-Index: AQHboqPjgHkUwEzR90uZDjrf8rDceQ== Date: Tue, 1 Apr 2025 01:17:51 +0000 Message-ID: <20250401011744.2267367-3-volodymyr_babchuk@epam.com> References: <20250401011744.2267367-1-volodymyr_babchuk@epam.com> In-Reply-To: <20250401011744.2267367-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.48.1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: GV1PR03MB10456:EE_|PA4PR03MB6703:EE_ x-ms-office365-filtering-correlation-id: 9100af57-b86e-46f7-630e-08dd70bb061f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|366016|376014|1800799024|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?Ic+grm+7vHjpOWYGpKZwF68XIXKuRkZ?= =?utf-8?q?zNh6uNUmKyQ7HlmM4eD/VNClbVTHgRZ1zn/f+Xpxipf6hS16xIGgO0vjPIjPC0uv2?= =?utf-8?q?IzWBch3Awap/NzK78Y1doiTKw2fwHrJetA9qC1X7SQw1ffmgnzW20uxmzg/7ec5IX?= =?utf-8?q?R4xVkGgp46YYAk1eZf3QFjZm22x1Fe5sCia5cv6PMvYvoSHLH2ORv4Vt0jASzz1GZ?= =?utf-8?q?G0ZAcUF4daKsYDE+AJaINPWHEDaL3vkVPyqFi8XRiDzfaYetqPVsbuNzWn+3ODenR?= =?utf-8?q?SysTiIav8Vj84gA3fZZbnmdUDZbQLqjOUnAlFaC66aSj9Njk9vEkIZeO7sTvtRrRj?= =?utf-8?q?bw8lJXukSPX5LdUh+XasaxMMgT3c8fbuwOBYJJbC4T6TKMbLK66hqhTP7HnTbzDQG?= =?utf-8?q?0CUe45nRUNKlFBgqpEAM6tIQD28ZseJkBeLq04/EpHKPAa0E1CdxhYJRI0/t2f+Lp?= =?utf-8?q?Hx4S/QFDLYU7rdXLGi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ns7eJ6HRCQX4FlVbfmlKu?= =?utf-8?q?7GdBZfK2Pq2?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR03MB10456.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(1800799024)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?x29dAg0Px+IdZ/7JaXc0jUSwr7n3?= =?utf-8?q?CNJ1QPV5YZWSA0Y/abmLM6/849vQQBUtQ2jSxTJo1T/k0vJJtWPBXhJGGbyS1TlNn?= =?utf-8?q?cSEuRRmqWTzWqC27C722rsVctm95ZccnwS8XqBl5wuWOSQwHf6F4OYnRRDD1zk9uf?= =?utf-8?q?Y375hje+ji9aCQ0n1ADEIIj3Uij3hi/FvOr8BU8fYDzKVdhKqiKP1oSJqft/4L42R?= =?utf-8?q?ShwbI1pMk7oCqsAw8ZTpDBl7zZt8SizTEHjicZofcvNpHl45HIuXIcsIpZvCEiTgq?= =?utf-8?q?4E3xiJnrCkO8KhlTnN+497S3ibXwyZ0yNY6zWvsWTdQhFXUji5ye1XMnQpRYTjKm7?= =?utf-8?q?urPOqEMiVm3izM39d95NsKSU5DFLEgHvurMFCCwfYXZmbLkgURMQNL8CjSNKYNiPT?= =?utf-8?q?HuGUBzkISvq49raR+5fAh7wA9HaENHrmmP1hGppnoVTVHCIYIqxFtrwj9VKk65JBH?= =?utf-8?q?h6er65IceHa7DMGX+xCsEACOt1oBF0lT59Y//i9exCU4zJYsnrWjmOl10C6ZBGI7t?= =?utf-8?q?7UZV96mLIRLgdolm61NOHSZtVNHaMX+xSu5Wbu3g0TLqxBPUMpTlsvjNyNkpGIEXg?= =?utf-8?q?zs/M5FRapi+l36dCYWkO4lVIno5giLmbdrUhhFWSLYMjFuW1oFhgHFUIVjMvYAvLX?= =?utf-8?q?8HGktdCfZkqZ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PM5OgYOPY/npvOHCKi9zq4PA=3D=3D?= Content-ID: <6EE89C3D6CF6004F9DD0A0D8CB2A0C39@eurprd03.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: GV1PR03MB10456.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9100af57-b86e-46f7-630e-08dd70bb061f X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Apr 2025 01:17:51.6593 (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: Zsh/WTgvIvAxew5xeHXv1ZP/H3Z2PgHGa+1dOypOV9a0W3/WEpsEwP1+Vwbl1W8NknLMUk9Ef0Co+5/VBPsZGB5FbnIhnRo/WyfFmUTlXk4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR03MB6703 While building xen with GCC 14.2.1 with "-fcondition-coverage" option, the compiler produces a false positive warning: arch/x86/irq.c: In function ‘create_irq’: arch/x86/irq.c:281:11: error: ‘desc’ may be used uninitialized [-Werror=maybe-uninitialized] 281 | ret = init_one_irq_desc(desc); | ^~~~~~~~~~~~~~~~~~~~~~~ arch/x86/irq.c:269:22: note: ‘desc’ was declared here 269 | struct irq_desc *desc; | ^~~~ cc1: all warnings being treated as errors make[2]: *** [Rules.mk:252: arch/x86/irq.o] Error 1 The same behavior can be observed when building Xen with "-Og" optimization level. Fix this by using "do { } while" loop instead of "for" loop. Signed-off-by: Volodymyr Babchuk --- Changes in v3: - Correct code style ("do {") - Add comment describing why we need do { } while loop. I prefer to leave do {} while because Nicola Vetrini said that this approach might help with MISRA Rule 9.1 without needing an explicit initializer. Changes in v2: - Use do { } while loop instead of initializing desc with NULL --- xen/arch/x86/irq.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index dd8d921f18..2f288704b5 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -264,15 +264,24 @@ void __init clear_irq_vector(int irq) int create_irq(nodeid_t node, bool grant_access) { - int irq, ret; + int ret; + int irq = nr_irqs_gsi; struct irq_desc *desc; - for (irq = nr_irqs_gsi; irq < nr_irqs; irq++) - { + if ( irq >= nr_irqs ) + return -ENOSPC; + + /* + * do { } while loop is used here to convince gcc14 that 'desc' is + * really assigned. Otherwise with -Og or -fcondition-coverage it + * may throw an false error stating that 'desc' may be used before + * initialization. + */ + do { desc = irq_to_desc(irq); if (cmpxchg(&desc->arch.used, IRQ_UNUSED, IRQ_RESERVED) == IRQ_UNUSED) break; - } + } while ( ++irq < nr_irqs ); if (irq >= nr_irqs) return -ENOSPC;