[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/3] xen: x86: irq: use do-while loop in create_irq()
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Date: Fri, 28 Mar 2025 12:19:18 +0000
- Accept-language: en-US
- 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
- 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=wUMGxm33AzvPgMSbFPnRpY/1DSFzSMIFU0d0bQ1ISWA=; b=P54w5QpWCivUhNRbHA45GIuPy/EyOndoZZL4LfCqvfn6iV9XFvUVsiIbgJFkLLCVM1mMO2lB4fdFXpvEBhK7cxFNDCWHdl3sX/D/akCWyXnvML6gKQclDyl/QGzwXbADjng+r6UIt3n3v/bsUS7j2n/KV9OcVxS382igDtQStabk23aFwdTZI8dDNOTP6qnkj0wr+nW0iRzEe+FV2Imojls5sFzckZBEO3D0ZQM7Kyfc8758nwiG9JtNAM5uW3yxde0mqO1N6/xhMn/JSaLVjB4KoAIgOtEynrhVzl0LJ36pBjfGm0uWBl3SABKU/4moeTRq2HC+cIKzJ9XXyPoYEg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Xz5suee5B+AZFHHD7ZkF+l4tDLBfXhGol/+G1psMkPWkulWWfUyitCu+vpCJIHmFaGH6/dDd0yLLK1TuhrR8JiibvoaI4rkLJMUDCLyB76KFqGmJQdY3vlmRZaY+en3Y8chKIrBAKs14vg3oGwD/+Mm7t5l6DkIDLy6iQW+X9z0wneeZ08ghNFBX2iJJ7voo/KA2JbP/tYpiSy0iMj/LBmBJpTpuexcRjdnoHbfzd/Nsbh+L/jGue9oarWn381OQ5oktjnvfcvdoHXHvV8Xu3uW8po9Becn/C823WWbeLqzNSeLQ7Ni/oC3kjheqtelrw2K+5rajupTLgY+4dqxqhA==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
- Cc: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Delivery-date: Fri, 28 Mar 2025 12:19:34 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHbn9uhrkS1XYNimkOfzt6xc/nvUA==
- Thread-topic: [PATCH v2 2/3] xen: x86: irq: use do-while loop in create_irq()
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 <volodymyr_babchuk@xxxxxxxx>
---
Changes in v2:
- Use do { } while loop instead of initializing desc with NULL
---
xen/arch/x86/irq.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index dd8d921f18..3224ada846 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -264,15 +264,19 @@ 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
{
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;
--
2.48.1
|