diff mbox series

[1/3] exynos4210: workaround UBSAN compilation error

Message ID 20180116151152.4040-2-marcandre.lureau@redhat.com
State New
Headers show
Series Sanitizers configuration | expand

Commit Message

Marc-André Lureau Jan. 16, 2018, 3:11 p.m. UTC
gcc 5.4.0-6ubuntu1~16.04.5 build with UBSAN enabled error:

  CC      hw/display/exynos4210_fimd.o
/home/petmay01/linaro/qemu-for-merges/hw/display/exynos4210_fimd.c: In
function ‘fimd_get_buffer_id’:
/home/petmay01/linaro/qemu-for-merges/hw/display/exynos4210_fimd.c:1105:5:
error: case label does not reduce to an integer constant
     case FIMD_WINCON_BUF2_STAT:

Because FIMD_WINCON_BUF2_STAT case contains an integer
overflow, use U suffix to get the unsigned type.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/display/exynos4210_fimd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Peter Maydell Jan. 16, 2018, 3:44 p.m. UTC | #1
On 16 January 2018 at 15:11, Marc-André Lureau
<marcandre.lureau@redhat.com> wrote:
> gcc 5.4.0-6ubuntu1~16.04.5 build with UBSAN enabled error:
>
>   CC      hw/display/exynos4210_fimd.o
> /home/petmay01/linaro/qemu-for-merges/hw/display/exynos4210_fimd.c: In
> function ‘fimd_get_buffer_id’:
> /home/petmay01/linaro/qemu-for-merges/hw/display/exynos4210_fimd.c:1105:5:
> error: case label does not reduce to an integer constant
>      case FIMD_WINCON_BUF2_STAT:
>
> Because FIMD_WINCON_BUF2_STAT case contains an integer
> overflow, use U suffix to get the unsigned type.

We should note that this is a gcc bug here (we compile with
-fwrapv so integer overflows like this are well-defined)
which we are working around.

> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/display/exynos4210_fimd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c
> index fd0b2bec65..86e37e93e9 100644
> --- a/hw/display/exynos4210_fimd.c
> +++ b/hw/display/exynos4210_fimd.c
> @@ -98,7 +98,7 @@
>  #define FIMD_WINCON_BUFSTATUS       ((1 << 21) | (1 << 31))
>  #define FIMD_WINCON_BUF0_STAT       ((0 << 21) | (0 << 31))
>  #define FIMD_WINCON_BUF1_STAT       ((1 << 21) | (0 << 31))
> -#define FIMD_WINCON_BUF2_STAT       ((0 << 21) | (1 << 31))
> +#define FIMD_WINCON_BUF2_STAT       ((0 << 21) | (1U << 31))
>  #define FIMD_WINCON_BUFSELECT       ((1 << 20) | (1 << 30))
>  #define FIMD_WINCON_BUF0_SEL        ((0 << 20) | (0 << 30))
>  #define FIMD_WINCON_BUF1_SEL        ((1 << 20) | (0 << 30))
> --
> 2.16.0.rc1.1.gef27df75a1
>

thanks
-- PMM
diff mbox series

Patch

diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c
index fd0b2bec65..86e37e93e9 100644
--- a/hw/display/exynos4210_fimd.c
+++ b/hw/display/exynos4210_fimd.c
@@ -98,7 +98,7 @@ 
 #define FIMD_WINCON_BUFSTATUS       ((1 << 21) | (1 << 31))
 #define FIMD_WINCON_BUF0_STAT       ((0 << 21) | (0 << 31))
 #define FIMD_WINCON_BUF1_STAT       ((1 << 21) | (0 << 31))
-#define FIMD_WINCON_BUF2_STAT       ((0 << 21) | (1 << 31))
+#define FIMD_WINCON_BUF2_STAT       ((0 << 21) | (1U << 31))
 #define FIMD_WINCON_BUFSELECT       ((1 << 20) | (1 << 30))
 #define FIMD_WINCON_BUF0_SEL        ((0 << 20) | (0 << 30))
 #define FIMD_WINCON_BUF1_SEL        ((1 << 20) | (0 << 30))