[Mesa-dev] [PATCH] mesa/util: fix arithmetic use of 'void *' in u_vector_foreach
Kenneth Graunke
kenneth at whitecape.org
Tue May 30 18:28:12 UTC 2017
On Tuesday, May 30, 2017 8:41:32 AM PDT Samuel Pitoiset wrote:
> u_vector_foreach is currently only used by the Intel Vulkan
> driver but when this macro is used in mesa core, GCC reports
> a compile-time error. Probably because some compiler options
> are different.
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
> src/util/u_vector.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/util/u_vector.h b/src/util/u_vector.h
> index c7fcb37a05..c0e199cfa5 100644
> --- a/src/util/u_vector.h
> +++ b/src/util/u_vector.h
> @@ -84,7 +84,7 @@ u_vector_finish(struct u_vector *queue)
> #define u_vector_foreach(elem, queue) \
> STATIC_ASSERT(__builtin_types_compatible_p(__typeof__(queue), struct u_vector *)); \
> for (uint32_t __u_vector_offset = (queue)->tail; \
> - elem = (queue)->data + (__u_vector_offset & ((queue)->size - 1)), __u_vector_offset < (queue)->head; \
> + elem = (void *)((char *)(queue)->data + (__u_vector_offset & ((queue)->size - 1))), __u_vector_offset < (queue)->head; \
> __u_vector_offset += (queue)->element_size)
>
>
>
Yeah, void * math is a GCCism - we shouldn't do that in core Mesa.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170530/86137e2a/attachment.sig>
More information about the mesa-dev
mailing list