From d3cf9b6e22fca25273e87d0b11882a7f886c97fe Mon Sep 17 00:00:00 2001 From: John Bowler Date: Thu, 26 Sep 2024 09:35:34 -0700 Subject: [PATCH] [libpng16] arm: Use `png_aligncastconst` for an upcast in Neon intrinsics This changes the arm/palette_neon_intrinsics.c code from using a bare cast to using the portable macro `png_aligncastconst`. This removes the `-Wcast-align` warning. The cast is safe because the pointer was allocated by `malloc(1024)`, and `malloc` is required to return a pointer with sufficient alignment for anything the allocation can accomodate. Nevertheless, this is a quick and dirty fix; the use of `png_bytep` in the `png_struct` declaration of the pointer is machine-specific. Other architectures may need different types and, consequently, the only type which is portable to other companies' CPUs is `(void*)`. This is a cherry-pick of commit a604b12c112162bfb45a0476e956777f6ed82d85 from branch 'libpng18'. Reviewed-by: Cosmin Truta Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- arm/palette_neon_intrinsics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arm/palette_neon_intrinsics.c b/arm/palette_neon_intrinsics.c index 92c7d6f9f..484eb41b7 100644 --- a/arm/palette_neon_intrinsics.c +++ b/arm/palette_neon_intrinsics.c @@ -64,7 +64,7 @@ png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info, { png_uint_32 row_width = row_info->width; const png_uint_32 *riffled_palette = - (const png_uint_32 *)png_ptr->riffled_palette; + png_aligncastconst(png_const_uint_32p, png_ptr->riffled_palette); const png_uint_32 pixels_per_chunk = 4; png_uint_32 i;