[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 2/3] xen: x86: irq: initialize irq desc in create_irq()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • Date: Thu, 27 Mar 2025 09:37:25 +0100
  • Arc-authentication-results: i=1; bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Arc-message-signature: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; c=relaxed/relaxed; t=1743064645; h=DKIM-Signature:MIME-Version:Date:From:To:Cc:Subject:In-Reply-To: References:Message-ID:X-Sender:Organization:Content-Type: Content-Transfer-Encoding; bh=inc5xP4R66Z0jvrVKmQ1fBuY3sL4BE1qh+eqZzVwvug=; b=n25JP2ZAd5XrrkpNhTOVt/EJVq9a1iH0/Axohnv1c+gh/9VOsSTmdKz3Gm0hMMfLF0pb tucEDnR7w6K341hzGa0daEKAWAnDNDQu4FsNWKrC8nTbtPo0qOGXT8Jl6q27ero4qtRzq lbsBjHuvciLRCuBO0JXR+rw8e55jzD3YdChtcSvNGE/FbTR3nwGt1qCvSKYsYu5k1XfCr c3Bf29KbSYtOJHsVKruIYMGqZ4EAGzYQ7vI1d63+7rTrNcRnaUKoqunfUwc9GWTWJdwOQ AAukgk3rhI7Lmi9zxhmkRoFfJPQJYoxAc45w5UyBTzTo8qWy/CwU2JZOxKauNfGy1vX35 IfBPXW0iqcPkfFtIG904mRDopOyAF3fN++cBNX/X71A0pc+bNa/zFz9375X2VS9N2u7lq ZgWNqGlRYlWkJCumva8AM2rEr2h/ParyJBQKRDYWP+n+q1NupKwn+UVQ2zfzQsSkR16ge 8KEL8BMT01v2lzRLyEHoMXgi/pF+VS3njvt3N+K36KYQcRYLR0Xe+zJxTcHmStjxNldAT dPbmyJ6Q0HUsPf5jzdB+/kjZuSSIc/BD/8EvhYByoFXpgomkNDUWha0RzT3PY+WcwfGZ5 Xl/v2YTMPozWqd26NCcw7IHfWFbF/utPAiQqJxusTyVcolhs1cmzcpwYtWxlDc4=
  • Arc-seal: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; cv=none; t=1743064645; b=xX0e6cU5iHCVe549dhhsBjDsnow4Oq5L8hxSug8dbBEjr5nLZ+k5dgF5pZ13FZsQBEwR pXyl7TkN4QJMgGMiIOytZiu1UcLawJuEAl1w3umxzr3WyENYapQ0JVS/kzpLjiOh4KI81 fOkR9lIhyPomLjAXaDLngXJCL1WiGyRDOblTpR4MDyzzRGIN7cMhPQxv49kNqkDok4bvZ 2rRGl/1kml/4N1qnsEU/g8FKJ3Gh/d1RneC8jICKbxBdpKFWu4F4M/0DyCPn0xmm248AK cft9ehUQlmi2/oxU/Aap1Oosjjq3dQYrEe1pMVwHNYW3d1eAgdQ+Gp8eFZ86/ndCFfPyK L89bdyV36cjzX3dOk3wgB7qlfwlc5hx3hYJP8S/3WV0tS02XNc1r8HIBUHgYayjHt6XQY YCelrbBDdWuomzusD9k4ncQXrCbXPRPVhKLKQ57W84gnG6qISnqBL+KBHOf5rg28Xik2h Eq1Bl5X7UT8m3pX9cl8zVdWSPDRxt++odChU2OhlDkq+TViT/mw7yf3krkrPFS4EUryY2 xoUbJA1FH3etFgmVszaszyid5qgUGPg4H0OYW8wKHIeiFAUOziHfGjARvdFicRUTnhC06 SG+SYQkOhAzWLDsf6n9Ny3MxSK8jtj+Z3egSowpK8S9/yXq10S9XVMu8+J64P4o=
  • Authentication-results: bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Cc: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, consulting@xxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 27 Mar 2025 08:37:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxx>

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



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.