Fix -Wsign-conversion on 32-bit

Closes: https://gitlab.freedesktop.org/emersion/libliftoff/-/issues/75
This commit is contained in:
Simon Ser 2023-02-22 10:45:05 +01:00
parent 314684fc64
commit 25dd6d662e
6 changed files with 11 additions and 11 deletions

View file

@ -182,7 +182,7 @@ main(int argc, char *argv[])
layers[0] = add_layer(drm_fd, output, 0, 0, crtc->mode.hdisplay,
crtc->mode.vdisplay, false, true, &fbs[0]);
for (i = 1; i < layers_len; i++) {
layers[i] = add_layer(drm_fd, output, 100 * i, 100 * i,
layers[i] = add_layer(drm_fd, output, 100 * (int)i, 100 * (int)i,
256, 256, i % 2, false, &fbs[i]);
}
@ -205,7 +205,7 @@ main(int argc, char *argv[])
for (i = 1; i < layers_len; i++) {
if (liftoff_layer_needs_composition(layers[i])) {
composite(drm_fd, &composition_fb, &fbs[i],
i * 100, i * 100);
(int)i * 100, (int)i * 100);
}
}

View file

@ -199,8 +199,8 @@ main(int argc, char *argv[])
crtc->mode.vdisplay, false);
for (i = 1; i < LAYERS_LEN; i++) {
init_layer(drm_fd, &layers[i], output, 100, 100, i % 2);
layers[i].x = 100 * i;
layers[i].y = 100 * i;
layers[i].x = 100 * (int)i;
layers[i].y = 100 * (int)i;
}
for (i = 0; i < LAYERS_LEN; i++) {

View file

@ -145,7 +145,7 @@ main(int argc, char *argv[])
crtc->mode.vdisplay, false);
for (j = 1; j < LAYERS_PER_OUTPUT; j++) {
layers[layers_len++] = add_layer(drm_fd, output,
100 * j, 100 * j,
100 * (int)j, 100 * (int)j,
256, 256, j % 2);
}
}

View file

@ -120,7 +120,7 @@ main(int argc, char *argv[])
layers[0] = add_layer(drm_fd, output, 0, 0, crtc->mode.hdisplay,
crtc->mode.vdisplay, false);
for (i = 1; i < LAYERS_LEN; i++) {
layers[i] = add_layer(drm_fd, output, 100 * i, 100 * i,
layers[i] = add_layer(drm_fd, output, 100 * (int)i, 100 * (int)i,
256, 256, i % 2);
}

View file

@ -335,11 +335,11 @@ plane_check_layer_fb(struct liftoff_plane *plane, struct liftoff_layer *layer)
return false;
}
if (format_index < modifiers[modifier_index].offset ||
format_index >= modifiers[modifier_index].offset + 64) {
if ((size_t)format_index < modifiers[modifier_index].offset ||
(size_t)format_index >= modifiers[modifier_index].offset + 64) {
return false;
}
format_shift = (int)(format_index - modifiers[modifier_index].offset);
format_shift = format_index - (int)modifiers[modifier_index].offset;
return (modifiers[modifier_index].formats & ((uint64_t)1 << format_shift)) != 0;
}

View file

@ -12,7 +12,7 @@
#define MAX_LAYERS 128
static struct liftoff_layer *
add_layer(struct liftoff_output *output, int x, int y, int width, int height)
add_layer(struct liftoff_output *output, int x, int y, uint32_t width, uint32_t height)
{
uint32_t fb_id;
struct liftoff_layer *layer;
@ -85,7 +85,7 @@ main(int argc, char *argv[])
for (i = 0; i < layers_len; i++) {
/* Planes don't intersect, so the library can arrange them in
* any order. Testing all combinations takes more time. */
layers[i] = add_layer(output, i * 100, i * 100, 100, 100);
layers[i] = add_layer(output, (int)i * 100, (int)i * 100, 100, 100);
for (j = 0; j < planes_len; j++) {
if (j == 1) {
/* Make the lowest plane above the primary plane