qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>
Cc: "Thomas Huth" <thuth@redhat.com>,
	qemu-s390x <qemu-s390x@nongnu.org>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [PATCH] intc/i8259: avoid (false positive) gcc warning
Date: Thu, 18 Mar 2021 17:11:25 +0100	[thread overview]
Message-ID: <bb7ec2df-db8e-2d3e-e392-1d2e16ce81e6@de.ibm.com> (raw)
In-Reply-To: <69bb59c7-1f97-ba07-5150-d94d03210920@redhat.com>



On 18.03.21 17:03, Paolo Bonzini wrote:
> On 18/03/21 16:47, Christian Borntraeger wrote:
>> some copiler versions are smart enough to detect a potentially
>> uninitialized variable, but are not smart enough to detect that this
>> cannot happen due to the code flow:
>>
>> ../hw/intc/i8259.c: In function ‘pic_read_irq’:
>> ../hw/intc/i8259.c:203:13: error: ‘irq2’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>     203 |         irq = irq2 + 8;
>>         |         ~~~~^~~~~~~~~~
>>
>> Let us initialize irq2 to -1 to avoid this warning as the most simple
>> solution.
> 
> What about:

This also works, but if you want to go down that path then it would be good if you
could do this patch as I do not have the testing infrastructure to do proper x86
changes.
> 
> diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
> index 344fd04db1..bf28c179de 100644
> --- a/hw/intc/i8259.c
> +++ b/hw/intc/i8259.c
> @@ -189,20 +189,18 @@ int pic_read_irq(DeviceState *d)
>                   irq2 = 7;
>               }
>               intno = slave_pic->irq_base + irq2;
> +            irq = irq2 + 8;
> +            pic_intack(s, 2);
>           } else {
>               intno = s->irq_base + irq;
> +            pic_intack(s, irq);
>           }
> -        pic_intack(s, irq);
>       } else {
>           /* spurious IRQ on host controller */
>           irq = 7;
>           intno = s->irq_base + irq;
>       }
> 
> -    if (irq == 2) {
> -        irq = irq2 + 8;
> -    }
> -
>   #ifdef DEBUG_IRQ_LATENCY
>       printf("IRQ%d latency=%0.3fus\n",
>              irq,
> 
> 
> ?
> 
> Paolo
> 


  reply	other threads:[~2021-03-18 16:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18 15:47 [PATCH] intc/i8259: avoid (false positive) gcc warning Christian Borntraeger
2021-03-18 16:03 ` Paolo Bonzini
2021-03-18 16:11   ` Christian Borntraeger [this message]
2021-03-18 16:17     ` Philippe Mathieu-Daudé
2021-03-18 18:11       ` BALATON Zoltan

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=bb7ec2df-db8e-2d3e-e392-1d2e16ce81e6@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=thuth@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).