[PATCH] treewide: improve strict-aliasing

Robin Jarry rjarry at redhat.com
Mon Aug 31 16:12:47 CEST 2026


Morten Brørup, Aug 31, 2026 at 08:36:
> Grout is built with -Wstrict-aliasing=2, which requires
> type casting to the generic "void *", like this:
>
> 	struct conn *conn;
> 	// create a new connection object
> 	if (rte_mempool_get(conn_pool, (void *)&conn) < 0)
> 		return NULL;
>
> Change to -Wstrict-aliasing=3, so we can use more accurate
> type casting, like this:
>
> 	struct conn *conn;
> 	// create a new connection object
> 	if (rte_mempool_get(conn_pool, (void **)&conn) < 0)
> 		return NULL;
>
> Grout currently compiles just fine with -Wstrict-aliasing=3.
>
> For reference, rte_mempool_get is declared as:
>
> static __rte_always_inline int
> rte_mempool_get(struct rte_mempool *mp, void **obj_p);
>
> Signed-off-by: Morten Brørup <mb at smartsharesystems.com>
> ---
>  meson.build | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meson.build b/meson.build
> index 144d1765..f0ac6ab6 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -33,7 +33,7 @@ endforeach
>  
>  # additional project C flags (keep alpha sorted)
>  add_project_arguments('-Wmissing-prototypes', language: 'c')
> -add_project_arguments('-Wstrict-aliasing=2', language: 'c')
> +add_project_arguments('-Wstrict-aliasing=3', language: 'c')
>  add_project_arguments('-fstrict-aliasing', language: 'c')
>  
>  # optional project C flags (keep alpha sorted)

This would make sense to replace all (void *) blanket casts with more
appropriate ones in the same patch.

Also, you could get rid of the now unnecessary intermediate void *data
variables since we can cast to (void **).

-- 
Robin

# Shading within a garment may occur.



More information about the grout mailing list