Skip to content

Commit

Permalink
[libpng16] arm: Use png_aligncastconst for an upcast in Neon intrin…
Browse files Browse the repository at this point in the history
…sics

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 a604b12
from branch 'libpng18'.

Reviewed-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
  • Loading branch information
jbowler authored and ctruta committed Sep 27, 2024
1 parent d288a1d commit d3cf9b6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arm/palette_neon_intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit d3cf9b6

Please sign in to comment.