Patchwork [3/4] s390-ccw.img: Fix compile warning in s390 ccw virtio code

login
register
mail settings
Submitter Christian Borntraeger
Date April 23, 2013, 11:23 a.m.
Message ID <1366716185-36913-4-git-send-email-borntraeger@de.ibm.com>
Download mbox | patch
Permalink /patch/238892/
State New
Headers show

Comments

Christian Borntraeger - April 23, 2013, 11:23 a.m.
Lets fix this gcc warning:

virtio.c: In function ‘vring_send_buf’:
virtio.c:125:35: error: operation on ‘vr->next_idx’ may be undefined
[-Werror=sequence-point]

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 pc-bios/s390-ccw/virtio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Alexander Graf - April 23, 2013, 11:31 a.m.
On 04/23/2013 01:23 PM, Christian Borntraeger wrote:
> Lets fix this gcc warning:
>
> virtio.c: In function ‘vring_send_buf’:
> virtio.c:125:35: error: operation on ‘vr->next_idx’ may be undefined
> [-Werror=sequence-point]
>
> Signed-off-by: Christian Borntraeger<borntraeger@de.ibm.com>
> ---
>   pc-bios/s390-ccw/virtio.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
> index 79e2941..1968fc6 100644
> --- a/pc-bios/s390-ccw/virtio.c
> +++ b/pc-bios/s390-ccw/virtio.c
> @@ -122,7 +122,9 @@ static void vring_send_buf(struct vring *vr, void *p, int len, int flags)
>       vr->desc[vr->next_idx].addr = (ulong)p;
>       vr->desc[vr->next_idx].len = len;
>       vr->desc[vr->next_idx].flags = flags&  ~VRING_HIDDEN_IS_CHAIN;
> -    vr->desc[vr->next_idx].next = ++vr->next_idx;
> +    vr->desc[vr->next_idx].next = vr->next_idx;
> +    vr->desc[vr->next_idx].next++;
> +    vr->next_idx++;

Hrm. This looks a lot more complicated than it needs to. Why is gcc 
emitting a warning here? Maybe it only wants braces. Please try whether

.next = ++(vr->next_id);

works for you.


Alex
Christian Borntraeger - April 23, 2013, 11:45 a.m.
On 23/04/13 13:31, Alexander Graf wrote:
> On 04/23/2013 01:23 PM, Christian Borntraeger wrote:
>> Lets fix this gcc warning:
>>
>> virtio.c: In function ‘vring_send_buf’:
>> virtio.c:125:35: error: operation on ‘vr->next_idx’ may be undefined
>> [-Werror=sequence-point]
>>
>> Signed-off-by: Christian Borntraeger<borntraeger@de.ibm.com>
>> ---
>>   pc-bios/s390-ccw/virtio.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
>> index 79e2941..1968fc6 100644
>> --- a/pc-bios/s390-ccw/virtio.c
>> +++ b/pc-bios/s390-ccw/virtio.c
>> @@ -122,7 +122,9 @@ static void vring_send_buf(struct vring *vr, void *p, int len, int flags)
>>       vr->desc[vr->next_idx].addr = (ulong)p;
>>       vr->desc[vr->next_idx].len = len;
>>       vr->desc[vr->next_idx].flags = flags&  ~VRING_HIDDEN_IS_CHAIN;
>> -    vr->desc[vr->next_idx].next = ++vr->next_idx;
>> +    vr->desc[vr->next_idx].next = vr->next_idx;
>> +    vr->desc[vr->next_idx].next++;
>> +    vr->next_idx++;
> 
> Hrm. This looks a lot more complicated than it needs to. Why is gcc emitting a warning here? Maybe it only wants braces. Please try whether
> 
> .next = ++(vr->next_id);
> 
> works for you.
> 
> 
> Alex
> 
> 

I already did that, but I get the same error message. I dont understand why gcc emits that warning,
but it does :-(
Alexander Graf - April 26, 2013, 6:38 a.m.
On 23.04.2013, at 13:45, Christian Borntraeger wrote:

> On 23/04/13 13:31, Alexander Graf wrote:
>> On 04/23/2013 01:23 PM, Christian Borntraeger wrote:
>>> Lets fix this gcc warning:
>>> 
>>> virtio.c: In function ‘vring_send_buf’:
>>> virtio.c:125:35: error: operation on ‘vr->next_idx’ may be undefined
>>> [-Werror=sequence-point]
>>> 
>>> Signed-off-by: Christian Borntraeger<borntraeger@de.ibm.com>
>>> ---
>>>  pc-bios/s390-ccw/virtio.c | 4 +++-
>>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
>>> index 79e2941..1968fc6 100644
>>> --- a/pc-bios/s390-ccw/virtio.c
>>> +++ b/pc-bios/s390-ccw/virtio.c
>>> @@ -122,7 +122,9 @@ static void vring_send_buf(struct vring *vr, void *p, int len, int flags)
>>>      vr->desc[vr->next_idx].addr = (ulong)p;
>>>      vr->desc[vr->next_idx].len = len;
>>>      vr->desc[vr->next_idx].flags = flags&  ~VRING_HIDDEN_IS_CHAIN;
>>> -    vr->desc[vr->next_idx].next = ++vr->next_idx;
>>> +    vr->desc[vr->next_idx].next = vr->next_idx;
>>> +    vr->desc[vr->next_idx].next++;
>>> +    vr->next_idx++;
>> 
>> Hrm. This looks a lot more complicated than it needs to. Why is gcc emitting a warning here? Maybe it only wants braces. Please try whether
>> 
>> .next = ++(vr->next_id);
>> 
>> works for you.
>> 
>> 
>> Alex
>> 
>> 
> 
> I already did that, but I get the same error message. I dont understand why gcc emits that warning,
> but it does :-(

*shrug* I'll just add it to the queue.


Alex

Patch

diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 79e2941..1968fc6 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -122,7 +122,9 @@  static void vring_send_buf(struct vring *vr, void *p, int len, int flags)
     vr->desc[vr->next_idx].addr = (ulong)p;
     vr->desc[vr->next_idx].len = len;
     vr->desc[vr->next_idx].flags = flags & ~VRING_HIDDEN_IS_CHAIN;
-    vr->desc[vr->next_idx].next = ++vr->next_idx;
+    vr->desc[vr->next_idx].next = vr->next_idx;
+    vr->desc[vr->next_idx].next++;
+    vr->next_idx++;
 
     /* Chains only have a single ID */
     if (!(flags & VRING_DESC_F_NEXT)) {