All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel]  [PATCH] pci: fix compilation warnings
@ 2016-03-28  7:23 Marcel Apfelbaum
  2016-03-28  8:43 ` Stefan Weil
  2016-04-10  8:28 ` Marcel Apfelbaum
  0 siblings, 2 replies; 4+ messages in thread
From: Marcel Apfelbaum @ 2016-03-28  7:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcel, peter.maydell, armbru, mst

Fix 'error: shift exponent -1 is negative' warning
by adding a corresponding assert.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
---
 hw/pci/pci.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index e67664d..a1d41aa 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -163,11 +163,15 @@ int pci_bar(PCIDevice *d, int reg)
 
 static inline int pci_irq_state(PCIDevice *d, int irq_num)
 {
+    assert(irq_num >= 0);
+
 	return (d->irq_state >> irq_num) & 0x1;
 }
 
 static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level)
 {
+    assert(irq_num >= 0);
+
 	d->irq_state &= ~(0x1 << irq_num);
 	d->irq_state |= level << irq_num;
 }
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] pci: fix compilation warnings
  2016-03-28  7:23 [Qemu-devel] [PATCH] pci: fix compilation warnings Marcel Apfelbaum
@ 2016-03-28  8:43 ` Stefan Weil
  2016-03-28  9:53   ` Marcel Apfelbaum
  2016-04-10  8:28 ` Marcel Apfelbaum
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Weil @ 2016-03-28  8:43 UTC (permalink / raw)
  To: Marcel Apfelbaum, qemu-devel; +Cc: peter.maydell, armbru, mst

[-- Attachment #1: Type: text/plain, Size: 1061 bytes --]

Am 28.03.2016 um 09:23 schrieb Marcel Apfelbaum:
> Fix 'error: shift exponent -1 is negative' warning
> by adding a corresponding assert.
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
> ---
>  hw/pci/pci.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index e67664d..a1d41aa 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -163,11 +163,15 @@ int pci_bar(PCIDevice *d, int reg)
>  
>  static inline int pci_irq_state(PCIDevice *d, int irq_num)
>  {
> +    assert(irq_num >= 0);
> +
>  	return (d->irq_state >> irq_num) & 0x1;
>  }
>  
>  static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level)
>  {
> +    assert(irq_num >= 0);
> +
>  	d->irq_state &= ~(0x1 << irq_num);
>  	d->irq_state |= level << irq_num;
>  }

Do we use negative values for irq_num anywhere?
If not, using an unsigned irq_num might be a better solution.

Stefan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] pci: fix compilation warnings
  2016-03-28  8:43 ` Stefan Weil
@ 2016-03-28  9:53   ` Marcel Apfelbaum
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Apfelbaum @ 2016-03-28  9:53 UTC (permalink / raw)
  To: Stefan Weil, qemu-devel; +Cc: peter.maydell, armbru, mst

On 03/28/2016 11:43 AM, Stefan Weil wrote:
> Am 28.03.2016 um 09:23 schrieb Marcel Apfelbaum:
>> Fix 'error: shift exponent -1 is negative' warning
>> by adding a corresponding assert.
>>
>> Reported-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
>> ---
>>   hw/pci/pci.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
>> index e67664d..a1d41aa 100644
>> --- a/hw/pci/pci.c
>> +++ b/hw/pci/pci.c
>> @@ -163,11 +163,15 @@ int pci_bar(PCIDevice *d, int reg)
>>
>>   static inline int pci_irq_state(PCIDevice *d, int irq_num)
>>   {
>> +    assert(irq_num >= 0);
>> +
>>   	return (d->irq_state >> irq_num) & 0x1;
>>   }
>>
>>   static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level)
>>   {
>> +    assert(irq_num >= 0);
>> +
>>   	d->irq_state &= ~(0x1 << irq_num);
>>   	d->irq_state |= level << irq_num;
>>   }
>
> Do we use negative values for irq_num anywhere?

Hi Stefan,

I didn't see any irq_nu assignments to a negative value but there are
some cases where it can be negative due to arithmetical operations like:

    hw/pci-host/bonito.c:651:    int internal_irq = irq_num - BONITO_IRQ_BASE;

On other cases we look for negative value:

    hw/ppc/ppc4xx_devs.c:171:    if (irq_num < 0 || irq_num > 3)
or
    hw/ppc/ppc4xx_pci.c:263:    if (irq_num < 0)


> If not, using an unsigned irq_num might be a better solution.

All of the above are manageable, of course, but we are close to
hard freeze (tomorrow) and the scope of this patch is much smaller (fix a compilation warning)

I think is definitely worth looking into it, but maybe as part of QEMU 2.7.

Thanks,
Marcel
>
> Stefan
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] pci: fix compilation warnings
  2016-03-28  7:23 [Qemu-devel] [PATCH] pci: fix compilation warnings Marcel Apfelbaum
  2016-03-28  8:43 ` Stefan Weil
@ 2016-04-10  8:28 ` Marcel Apfelbaum
  1 sibling, 0 replies; 4+ messages in thread
From: Marcel Apfelbaum @ 2016-04-10  8:28 UTC (permalink / raw)
  To: Marcel Apfelbaum, qemu-devel; +Cc: peter.maydell, armbru, mst

On 03/28/2016 10:23 AM, Marcel Apfelbaum wrote:
> Fix 'error: shift exponent -1 is negative' warning
> by adding a corresponding assert.
>

Ping.

Thanks,
Marcel

> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
> ---
>   hw/pci/pci.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index e67664d..a1d41aa 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -163,11 +163,15 @@ int pci_bar(PCIDevice *d, int reg)
>
>   static inline int pci_irq_state(PCIDevice *d, int irq_num)
>   {
> +    assert(irq_num >= 0);
> +
>   	return (d->irq_state >> irq_num) & 0x1;
>   }
>
>   static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level)
>   {
> +    assert(irq_num >= 0);
> +
>   	d->irq_state &= ~(0x1 << irq_num);
>   	d->irq_state |= level << irq_num;
>   }
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-04-10  8:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-28  7:23 [Qemu-devel] [PATCH] pci: fix compilation warnings Marcel Apfelbaum
2016-03-28  8:43 ` Stefan Weil
2016-03-28  9:53   ` Marcel Apfelbaum
2016-04-10  8:28 ` Marcel Apfelbaum

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.