forked from enlightenment/efl
build: fix void* use in pointer maths
Summary: void* is an invalid type for calculating pointer offsets, so ensure that this is always cast to something else (e.g., char*) in the few cases where it's been misused Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11816
This commit is contained in:
parent
6417b35ad4
commit
ef3a09499f
|
@ -205,20 +205,20 @@ struct _Eina_Accessor_CArray_Length
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
eina_carray_length_accessor_get_at(Eina_Accessor_CArray_Length *accessor, unsigned int idx, void **data)
|
eina_carray_length_accessor_get_at(Eina_Accessor_CArray_Length *accessor, unsigned int idx, void **data)
|
||||||
{
|
{
|
||||||
if (accessor->array + idx*accessor->step >= accessor->end)
|
if ((char*)accessor->array + idx*accessor->step >= (char*)accessor->end)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
memcpy(data, (void*) accessor->array + idx*accessor->step, accessor->step);
|
memcpy(data, (char*) accessor->array + idx*accessor->step, accessor->step);
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
eina_carray_length_accessor_ptr_get_at(Eina_Accessor_CArray_Length *accessor, unsigned int idx, void **data)
|
eina_carray_length_accessor_ptr_get_at(Eina_Accessor_CArray_Length *accessor, unsigned int idx, void **data)
|
||||||
{
|
{
|
||||||
if (accessor->array + idx*accessor->step >= accessor->end)
|
if ((char*)accessor->array + idx*accessor->step >= (char*)accessor->end)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
*data = (((void*)accessor->array) + idx*accessor->step);
|
*data = (((char*)accessor->array) + idx*accessor->step);
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ eina_carray_length_accessor_new(void** array, unsigned int step, unsigned int le
|
||||||
EINA_MAGIC_SET(&accessor->accessor, EINA_MAGIC_ACCESSOR);
|
EINA_MAGIC_SET(&accessor->accessor, EINA_MAGIC_ACCESSOR);
|
||||||
|
|
||||||
accessor->array = array;
|
accessor->array = array;
|
||||||
accessor->end = accessor->array + length * step;
|
accessor->end = (void**)((char*)accessor->array + length * step);
|
||||||
accessor->step = step;
|
accessor->step = step;
|
||||||
|
|
||||||
accessor->accessor.version = EINA_ACCESSOR_VERSION;
|
accessor->accessor.version = EINA_ACCESSOR_VERSION;
|
||||||
|
@ -269,7 +269,7 @@ eina_carray_length_ptr_accessor_new(void** array, unsigned int step, unsigned in
|
||||||
EINA_MAGIC_SET(&accessor->accessor, EINA_MAGIC_ACCESSOR);
|
EINA_MAGIC_SET(&accessor->accessor, EINA_MAGIC_ACCESSOR);
|
||||||
|
|
||||||
accessor->array = array;
|
accessor->array = array;
|
||||||
accessor->end = accessor->array + length * step;
|
accessor->end = (void**)((char*)accessor->array + length * step);
|
||||||
accessor->step = step;
|
accessor->step = step;
|
||||||
|
|
||||||
accessor->accessor.version = EINA_ACCESSOR_VERSION;
|
accessor->accessor.version = EINA_ACCESSOR_VERSION;
|
||||||
|
|
|
@ -2588,7 +2588,7 @@ _write_to_fd(void *data, Ecore_Fd_Handler *fd_handler)
|
||||||
fd = ecore_main_fd_handler_fd_get(fd_handler);
|
fd = ecore_main_fd_handler_fd_get(fd_handler);
|
||||||
if (fd < 0) goto end;
|
if (fd < 0) goto end;
|
||||||
|
|
||||||
len = write(fd, slice->slice.mem + slice->written_bytes,
|
len = write(fd, (char*)slice->slice.mem + slice->written_bytes,
|
||||||
slice->slice.len - slice->written_bytes);
|
slice->slice.len - slice->written_bytes);
|
||||||
|
|
||||||
slice->written_bytes += len;
|
slice->written_bytes += len;
|
||||||
|
|
Loading…
Reference in New Issue