diff mbox

[v2,14/29] virtio-gpu: use DIV_ROUND_UP

Message ID 20170713163219.9024-15-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau July 13, 2017, 4:32 p.m. UTC
I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/display/virtio-gpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Philippe Mathieu-Daudé July 14, 2017, 4:23 a.m. UTC | #1
On 07/13/2017 01:32 PM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   hw/display/virtio-gpu.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index 0506d2c1b0..669f36f8bb 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -408,7 +408,7 @@ static void virtio_gpu_transfer_to_host_2d(VirtIOGPU *g,
>       }
>   
>       format = pixman_image_get_format(res->image);
> -    bpp = (PIXMAN_FORMAT_BPP(format) + 7) / 8;
> +    bpp = DIV_ROUND_UP(PIXMAN_FORMAT_BPP(format), 8);
>       stride = pixman_image_get_stride(res->image);
>   
>       if (t2d.offset || t2d.r.x || t2d.r.y ||
> @@ -570,7 +570,7 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g,
>       scanout = &g->scanout[ss.scanout_id];
>   
>       format = pixman_image_get_format(res->image);
> -    bpp = (PIXMAN_FORMAT_BPP(format) + 7) / 8;
> +    bpp = DIV_ROUND_UP(PIXMAN_FORMAT_BPP(format), 8);
>       offset = (ss.r.x * bpp) + ss.r.y * pixman_image_get_stride(res->image);
>       if (!scanout->ds || surface_data(scanout->ds)
>           != ((uint8_t *)pixman_image_get_data(res->image) + offset) ||
>
Richard Henderson July 14, 2017, 8:37 a.m. UTC | #2
On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   hw/display/virtio-gpu.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~
diff mbox

Patch

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 0506d2c1b0..669f36f8bb 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -408,7 +408,7 @@  static void virtio_gpu_transfer_to_host_2d(VirtIOGPU *g,
     }
 
     format = pixman_image_get_format(res->image);
-    bpp = (PIXMAN_FORMAT_BPP(format) + 7) / 8;
+    bpp = DIV_ROUND_UP(PIXMAN_FORMAT_BPP(format), 8);
     stride = pixman_image_get_stride(res->image);
 
     if (t2d.offset || t2d.r.x || t2d.r.y ||
@@ -570,7 +570,7 @@  static void virtio_gpu_set_scanout(VirtIOGPU *g,
     scanout = &g->scanout[ss.scanout_id];
 
     format = pixman_image_get_format(res->image);
-    bpp = (PIXMAN_FORMAT_BPP(format) + 7) / 8;
+    bpp = DIV_ROUND_UP(PIXMAN_FORMAT_BPP(format), 8);
     offset = (ss.r.x * bpp) + ss.r.y * pixman_image_get_stride(res->image);
     if (!scanout->ds || surface_data(scanout->ds)
         != ((uint8_t *)pixman_image_get_data(res->image) + offset) ||