From be012932d01f587abc7cc6200cca4fdd06f9e87e Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Wed, 24 Aug 2022 15:23:12 +0200 Subject: [PATCH] virgl: Fix ubsan warnings: virgl_screen.c:313:55: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' virgl_screen.c:682:27: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' virgl_encode.c:481:7: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' Signed-off-by: Gert Wollny Part-of: --- src/gallium/drivers/virgl/virgl_screen.c | 2 +- src/virtio/virtio-gpu/virgl_hw.h | 2 +- src/virtio/virtio-gpu/virgl_protocol.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c index 6e8058018f3..597521a4f42 100644 --- a/src/gallium/drivers/virgl/virgl_screen.c +++ b/src/gallium/drivers/virgl/virgl_screen.c @@ -679,7 +679,7 @@ virgl_format_check_bitmask(enum pipe_format format, enum virgl_formats vformat = pipe_to_virgl_format(format); int big = vformat / 32; int small = vformat % 32; - if ((bitmask[big] & (1 << small))) + if ((bitmask[big] & (1u << small))) return true; /* On GLES hosts we don't advertise BGRx_SRGB, but we may be able diff --git a/src/virtio/virtio-gpu/virgl_hw.h b/src/virtio/virtio-gpu/virgl_hw.h index b713ef6b943..ceb3a80ca9f 100644 --- a/src/virtio/virtio-gpu/virgl_hw.h +++ b/src/virtio/virtio-gpu/virgl_hw.h @@ -434,7 +434,7 @@ enum virgl_formats { #define VIRGL_CAP_APP_TWEAK_SUPPORT (1 << 28) #define VIRGL_CAP_BGRA_SRGB_IS_EMULATED (1 << 29) #define VIRGL_CAP_CLEAR_TEXTURE (1 << 30) -#define VIRGL_CAP_ARB_BUFFER_STORAGE (1 << 31) +#define VIRGL_CAP_ARB_BUFFER_STORAGE (1u << 31) /* These are used by the capability_bits_v2 field in virgl_caps_v2. */ #define VIRGL_CAP_V2_BLEND_EQUATION (1 << 0) diff --git a/src/virtio/virtio-gpu/virgl_protocol.h b/src/virtio/virtio-gpu/virgl_protocol.h index 31ce72e435a..6d5ba63a442 100644 --- a/src/virtio/virtio-gpu/virgl_protocol.h +++ b/src/virtio/virtio-gpu/virgl_protocol.h @@ -238,7 +238,7 @@ enum virgl_shader_stage { #define VIRGL_OBJ_RS_S0_LINE_LAST_PIXEL(x) (((x) & 0x1) << 28) #define VIRGL_OBJ_RS_S0_HALF_PIXEL_CENTER(x) (((x) & 0x1) << 29) #define VIRGL_OBJ_RS_S0_BOTTOM_EDGE_RULE(x) (((x) & 0x1) << 30) -#define VIRGL_OBJ_RS_S0_FORCE_PERSAMPLE_INTERP(x) (((x) & 0x1) << 31) +#define VIRGL_OBJ_RS_S0_FORCE_PERSAMPLE_INTERP(x) (((x) & 0x1u) << 31) #define VIRGL_OBJ_RS_POINT_SIZE 3 #define VIRGL_OBJ_RS_SPRITE_COORD_ENABLE 4