From: Jan Beulich <jbeulich@suse.com>
To: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v2 2/3] xen: x86: irq: use do-while loop in create_irq()
Date: Fri, 28 Mar 2025 14:04:18 +0100 [thread overview]
Message-ID: <df7853d6-14c9-4dc6-9910-2fd735cf797c@suse.com> (raw)
In-Reply-To: <20250328121902.2134020-3-volodymyr_babchuk@epam.com>
On 28.03.2025 13:19, Volodymyr Babchuk wrote:
> 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@epam.com>
>
> ---
>
> Changes in v2:
>
> - Use do { } while loop instead of initializing desc with NULL
> ---
I'm afraid to disappoint you by saying that I liked v1 better; all it was
lacking was a comment. Such a comment is still lacking here. Without that,
someone may come and convert this back to the more normal (in this
situation) "for" loop.
> --- 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
> {
Nit: The brace goes on the same line as the "do", just like ...
> desc = irq_to_desc(irq);
> if (cmpxchg(&desc->arch.used, IRQ_UNUSED, IRQ_RESERVED) == IRQ_UNUSED)
> break;
> - }
> + } while ( ++irq < nr_irqs );
... it's on the same line as the "while" here.
Jan
next prev parent reply other threads:[~2025-03-28 13:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-28 12:19 [PATCH v2 0/3] Enable MC/DC support for GCOV Volodymyr Babchuk
2025-03-28 12:19 ` [PATCH v2 1/3] xen: gcov: add support for gcc 14 Volodymyr Babchuk
2025-03-28 13:05 ` Jan Beulich
2025-03-28 12:19 ` [PATCH v2 2/3] xen: x86: irq: use do-while loop in create_irq() Volodymyr Babchuk
2025-03-28 13:04 ` Jan Beulich [this message]
2025-03-28 12:19 ` [PATCH v2 3/3] xen: debug: gcov: add condition coverage support Volodymyr Babchuk
2025-03-28 13:08 ` Jan Beulich
2025-03-28 14:27 ` Anthony PERARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=df7853d6-14c9-4dc6-9910-2fd735cf797c@suse.com \
--to=jbeulich@suse.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=andrew.cooper3@citrix.com \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.