[SLOF] [PATCH v3 01/22] virtio: fix gcc warnings (-Wextra)

Nikunj A Dadhania nikunj at linux.vnet.ibm.com
Wed Jan 27 16:33:28 AEDT 2016


Thomas Huth <thuth at redhat.com> writes:

> On 22.01.2016 11:54, Nikunj A Dadhania wrote:
>> Change variable types and type case in certain places to fix gcc
>> warnings
>> 
>> Signed-off-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
>> ---
>>  lib/libvirtio/virtio-9p.c  | 4 ++--
>>  lib/libvirtio/virtio-blk.c | 2 +-
>>  2 files changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/lib/libvirtio/virtio-9p.c b/lib/libvirtio/virtio-9p.c
>> index 5a5fd01..46bacd6 100644
>> --- a/lib/libvirtio/virtio-9p.c
>> +++ b/lib/libvirtio/virtio-9p.c
>> @@ -143,7 +143,7 @@ static int virtio_9p_transact(void *opaque, uint8_t *tx, int tx_size, uint8_t *r
>>  		return -1;
>>  	}
>>  
>> -	*rx_size = MIN(*rx_size, le32_to_cpu(*(uint32_t*)(&rx[0])));
>> +	*rx_size = MIN((uint32_t)*rx_size, le32_to_cpu(*(uint32_t*)(&rx[0])));
>>  	dprint_buffer("RX", rx, *rx_size);
>
> Could you try whether it also works to change the type of the parameter
> rx_size from "int *" to "uint32_t *" ? I think that would be slightly
> cleaner in this case, since the code apparently wants to write a 32-bit
> value into the buffer provided by the rx_size pointer.
>
>> @@ -332,5 +332,5 @@ cleanup_connection:
>>  
>>  
>>  	dprintf("%s : complete, read %llu bytes\n", __func__, offset);
>> -	return rc == 0 ? offset : rc;
>> +	return rc == 0 ? (int)offset : rc;
>>  }
>
> I'd maybe also rather change the return value type from "int" to "long"
> to make sure that no upper bits from offset are lost.

I would try both the suggestions

Regards
Nikunj



More information about the SLOF mailing list