Skip to content

Commit b38f2a8

Browse files
committed
libvisual/lv_bmp.c: Address warnings -Wpointer-to-int-cast (and -Wint-to-pointer-cast)
Symptom was: > lv_bmp.c: In function 'load_uncompressed': > lv_bmp.c:75:61: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] > 75 | uint8_t *end = (uint8_t *) ((int)data & ~1); > | ^ > lv_bmp.c:75:48: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] > 75 | uint8_t *end = (uint8_t *) ((int)data & ~1); > | ^ > lv_bmp.c:96:61: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] > 96 | uint8_t *end = (uint8_t *) ((int)data & ~7); > | ^ > lv_bmp.c:96:48: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] > 96 | uint8_t *end = (uint8_t *) ((int)data & ~7); > | ^
1 parent ab111fe commit b38f2a8

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

libvisual/libvisual/lv_bmp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <string.h>
3030
#include <math.h>
3131
#include <gettext.h>
32+
#include <stdint.h>
3233

3334
#include <sys/stat.h>
3435
#include <fcntl.h>
@@ -72,7 +73,7 @@ static int load_uncompressed (FILE *fp, VisVideo *video, int depth)
7273
while (data > (uint8_t *) visual_video_get_pixels (video)) {
7374
/* Unpack 4 bpp pixels aka 2 pixels per byte */
7475
uint8_t *col = data - video->pitch;
75-
uint8_t *end = (uint8_t *) ((int)data & ~1);
76+
uint8_t *end = (uint8_t *) ((uintptr_t)data & ~1);
7677
data = col;
7778

7879
while (col < end) {
@@ -93,7 +94,7 @@ static int load_uncompressed (FILE *fp, VisVideo *video, int depth)
9394
while (data > (uint8_t *) visual_video_get_pixels (video)) {
9495
/* Unpack 1 bpp pixels aka 8 pixels per byte */
9596
uint8_t *col = data - video->pitch;
96-
uint8_t *end = (uint8_t *) ((int)data & ~7);
97+
uint8_t *end = (uint8_t *) ((uintptr_t)data & ~7);
9798
data = col;
9899

99100
while (col < end) {

0 commit comments

Comments
 (0)