[Spice-devel] [PATCH spice-common] Fix cast to spice_marshalller_intem_free_func function

Eduardo Lima (Etrunko) etrunko at redhat.com
Fri May 18 03:02:57 UTC 2018


On 17/05/18 18:15, Jonathon Jongsma wrote:
> Fine with me.
> 

Thanks, I fixed a typo in header before pushing.

s/spice_marshalller_intem_free_func/spice_marshaller_item_free_func


> Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
> 
> 
> On Thu, 2018-05-17 at 12:56 -0300, Eduardo Lima (Etrunko) wrote:
>> Building with gcc 8.0.1 from Fedora 28 gives the following error:
>>
>> FAILED: common/common@@spice-common at sta/marshaller.c.o
>> ../common/marshaller.c: In function 'spice_marshaller_reserve_space':
>> ../common/marshaller.c:311:27: error: cast between incompatible
>> function types from 'void (*)(void *)' to 'void (*)(uint8_t *, void
>> *)' {aka 'void (*)(unsigned char *, void *)'} [-Werror=cast-function-
>> type]
>>          item->free_data = (spice_marshaller_item_free_func)free;
>>                            ^
>> cc1: all warnings being treated as errors
>>
>> Which can be easily fixed by creating a new function with the correct
>> signature and calling free() from it.
>>
>> Signed-off-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
>> ---
>>  common/marshaller.c | 7 ++++++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/common/marshaller.c b/common/marshaller.c
>> index adfb8cd..80cedb7 100644
>> --- a/common/marshaller.c
>> +++ b/common/marshaller.c
>> @@ -270,6 +270,11 @@ static size_t
>> remaining_buffer_size(SpiceMarshallerData *d)
>>      return MARSHALLER_BUFFER_SIZE - d->current_buffer_position;
>>  }
>>  
>> +static void _reserve_space_free_data(uint8_t *data,
>> SPICE_GNUC_UNUSED void *opaque)
>> +{
>> +    free(data);
>> +}
>> +
>>  uint8_t *spice_marshaller_reserve_space(SpiceMarshaller *m, size_t
>> size)
>>  {
>>      MarshallerItem *item;
>> @@ -308,7 +313,7 @@ uint8_t
>> *spice_marshaller_reserve_space(SpiceMarshaller *m, size_t size)
>>          /* Large item, allocate by itself */
>>          item->data = (uint8_t *)spice_malloc(size);
>>          item->len = size;
>> -        item->free_data = (spice_marshaller_item_free_func)free;
>> +        item->free_data = _reserve_space_free_data;
>>          item->opaque = NULL;
>>      } else {
>>          /* Use next buffer */


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etrunko at redhat.com


More information about the Spice-devel mailing list