All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicola Vetrini <nicola.vetrini@bugseng.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
	consulting@bugseng.com,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v1 2/3] xen: x86: irq: initialize irq desc in create_irq()
Date: Thu, 27 Mar 2025 09:37:25 +0100	[thread overview]
Message-ID: <bab91924eb87a56260d62faee028d5af@bugseng.com> (raw)
In-Reply-To: <84903e47-038c-46f5-862a-a0c9623c8125@suse.com>

On 2025-03-27 09:03, Jan Beulich wrote:
> On 27.03.2025 01:40, 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
>> 
>> While we have signed/unsigned comparison both in "for" loop and in
>> "if" statement, this still can't lead to use of uninitialized "desc",
>> as either loop will be executed at least once, or the function will
>> return early. So this is a clearly false positive warning. Anyways,
>> initialize "desc" with NULL to make GCC happy.
>> 
>> Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
> 
> Hmm, this puts us in an interesting conflict, I think. Misra, aiui, 
> will ...
> 
>> --- a/xen/arch/x86/irq.c
>> +++ b/xen/arch/x86/irq.c
>> @@ -265,7 +265,7 @@ void __init clear_irq_vector(int irq)
>>  int create_irq(nodeid_t node, bool grant_access)
>>  {
>>      int irq, ret;
>> -    struct irq_desc *desc;
>> +    struct irq_desc *desc = NULL;
> 
> ... consider such an assignment useless (and hence potentially 
> confusing)
> code. I'm curious what BugsEng folks are going to say here.
> 

It is quite odd to see this only in coverage builds, but the side 
effects of coverage options might trigger some of gcc's internal 
analyzer thresholds. Anyway, since there are no concerns about dead code 
(see 
https://gitlab.com/xen-project/xen/-/blob/staging/docs/misra/deviations.rst: 
R2.2, "There shall be no dead code", is globally deviated) and that this 
might actually be beneficial to remove some caution reports for R9.1 
("The value of an object with automatic storage duration shall not be 
read before it has been set") I think the overall effect is positive.

> Irrespective of that I think such a seemingly unnecessary initializer 
> wants
> to come with a justifying comment, e.g.
> 
>     struct irq_desc *desc = NULL /* gcc14 with -fcondition-coverage */;
> 
> here.
> 
> Finally, did you report this to upstream gcc? It's probably too late to
> fix in gcc15 (if still present), but it would be nice to have it fixed 
> in
> later versions (maybe including a late 14.x).
> 
> Jan

-- 
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253


  reply	other threads:[~2025-03-27  8:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-27  0:40 [PATCH v1 0/3] Enable MC/DC support for GCOV Volodymyr Babchuk
2025-03-27  0:40 ` [PATCH v1 1/3] xen: gcov: add support for gcc 14.1 Volodymyr Babchuk
2025-03-27  7:55   ` Jan Beulich
2025-03-27 22:03     ` Volodymyr Babchuk
2025-03-28  6:42       ` Andrew Cooper
2025-03-28 11:35         ` Volodymyr Babchuk
2025-03-27  0:40 ` [PATCH v1 2/3] xen: x86: irq: initialize irq desc in create_irq() Volodymyr Babchuk
2025-03-27  8:03   ` Jan Beulich
2025-03-27  8:37     ` Nicola Vetrini [this message]
2025-03-27  9:00       ` Nicola Vetrini
2025-03-27 13:10         ` Stewart Hildebrand
2025-03-27  0:40 ` [PATCH v1 3/3] xen: debug: gcov: add condition coverage support Volodymyr Babchuk
2025-03-27  8:08   ` Jan Beulich

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=bab91924eb87a56260d62faee028d5af@bugseng.com \
    --to=nicola.vetrini@bugseng.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=consulting@bugseng.com \
    --cc=jbeulich@suse.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.