forked from old/legacy-imlib2
Loaders: Avoid cast-align warnings with -Wcast-align=strict
This commit is contained in:
parent
6337c54d30
commit
d27354926a
|
@ -224,4 +224,6 @@ int decompress_load(ImlibImage * im, int load_data,
|
|||
|
||||
#define QUIT_WITH_RC(_err) { rc = _err; goto quit; }
|
||||
|
||||
#define PCAST(T, p) ((T)(const void *)(p))
|
||||
|
||||
#endif /* IMLIB2_LOADER_H */
|
||||
|
|
|
@ -28,7 +28,8 @@ static const char *const _formats[] = { "ani" };
|
|||
typedef struct {
|
||||
unsigned char nest;
|
||||
int nframes, nfsteps;
|
||||
uint32_t *rates, *seq;
|
||||
const uint32_t *rates;
|
||||
const uint32_t *seq;
|
||||
} riff_ctx_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -119,7 +120,8 @@ _riff_parse(ImlibImage * im, riff_ctx_t * ctx, const char *fdata,
|
|||
break;
|
||||
}
|
||||
|
||||
chunk = (const ani_chunk_t *)fptr;
|
||||
chunk = PCAST(const ani_chunk_t *, fptr);
|
||||
|
||||
type = SWAP_LE_32(chunk->hdr.type);
|
||||
size = SWAP_LE_32(chunk->hdr.size);
|
||||
|
||||
|
@ -202,7 +204,8 @@ _riff_parse(ImlibImage * im, riff_ctx_t * ctx, const char *fdata,
|
|||
pf->frame_delay = (1000 * SWAP_LE_32(AH.rate)) / 60;
|
||||
break;
|
||||
case RIFF_TYPE_rate:
|
||||
ctx->rates = (uint32_t *) (fptr + 8);
|
||||
ctx->rates = PCAST(const uint32_t *, fptr + 8);
|
||||
|
||||
if ((int)size != 4 * ctx->nfsteps)
|
||||
{
|
||||
D("rate chunk size mismatch: %d != %d\n", size,
|
||||
|
@ -216,7 +219,8 @@ _riff_parse(ImlibImage * im, riff_ctx_t * ctx, const char *fdata,
|
|||
Dx("\n");
|
||||
break;
|
||||
case RIFF_TYPE_seq:
|
||||
ctx->seq = (uint32_t *) (fptr + 8);
|
||||
ctx->seq = PCAST(const uint32_t *, fptr + 8);
|
||||
|
||||
if ((int)size != 4 * ctx->nfsteps)
|
||||
{
|
||||
D("seq chunk size mismatch: %d != %d\n", size,
|
||||
|
|
|
@ -681,7 +681,7 @@ _load(ImlibImage * im, int load_data)
|
|||
{
|
||||
for (x = 0; x < w && buffer_ptr < buffer_end_safe; x++)
|
||||
{
|
||||
pixel = *(unsigned short *)buffer_ptr;
|
||||
pixel = *PCAST(const unsigned short *, buffer_ptr);
|
||||
|
||||
if (im->has_alpha)
|
||||
a = SCALE(a, pixel);
|
||||
|
@ -730,7 +730,7 @@ _load(ImlibImage * im, int load_data)
|
|||
{
|
||||
for (x = 0; x < w && buffer_ptr < buffer_end_safe; x++)
|
||||
{
|
||||
pixel = *(unsigned int *)buffer_ptr;
|
||||
pixel = *PCAST(const unsigned int *, buffer_ptr);
|
||||
|
||||
if (im->has_alpha)
|
||||
a = SCALE(a, pixel);
|
||||
|
|
|
@ -244,7 +244,8 @@ row_callback(png_struct * png_ptr, png_byte * new_row,
|
|||
PNG_PASS_COLS(im->w, pass), PNG_PASS_ROWS(im->h, pass));
|
||||
y = y0 + dy * row_num;
|
||||
|
||||
sptr = (const uint32_t *)new_row; /* Assuming aligned */
|
||||
sptr = PCAST(const uint32_t *, new_row); /* Assuming aligned */
|
||||
|
||||
dptr = im->data + y * im->w;
|
||||
for (x = x0; x < im->w; x += dx)
|
||||
{
|
||||
|
@ -341,7 +342,8 @@ _load(ImlibImage * im, int load_data)
|
|||
|
||||
for (ic = 0;; ic++, fptr += 8 + len + 4)
|
||||
{
|
||||
chunk = (const png_chunk_t *)fptr;
|
||||
chunk = PCAST(const png_chunk_t *, fptr);
|
||||
|
||||
len = htonl(chunk->hdr.len);
|
||||
D("Scan %3d: %06lx: %6d: %.4s: ", ic,
|
||||
fptr - (unsigned char *)im->fi->fdata, len, chunk->hdr.name);
|
||||
|
@ -429,7 +431,8 @@ _load(ImlibImage * im, int load_data)
|
|||
|
||||
for (ic = 0;; ic++, fptr += 8 + len + 4)
|
||||
{
|
||||
chunk = (const png_chunk_t *)fptr;
|
||||
chunk = PCAST(const png_chunk_t *, fptr);
|
||||
|
||||
len = htonl(chunk->hdr.len);
|
||||
D("Chunk %3d: %06lx: %6d: %.4s: ", ic,
|
||||
fptr - (unsigned char *)im->fi->fdata, len, chunk->hdr.name);
|
||||
|
|
|
@ -94,7 +94,8 @@ _load(ImlibImage * im, int load_data)
|
|||
|
||||
if (im->fi->fsize > (int)(sizeof(tga_footer)))
|
||||
{
|
||||
footer = (tga_footer *) (fptr + im->fi->fsize - sizeof(tga_footer));
|
||||
footer =
|
||||
PCAST(const tga_footer *, fptr + im->fi->fsize - sizeof(tga_footer));
|
||||
|
||||
/* check the footer to see if we have a v2.0 TGA file */
|
||||
footer_present = memcmp(footer->signature, TGA_SIGNATURE,
|
||||
|
|
Loading…
Reference in New Issue