qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [PATCH] Correct computation of bytes per pixel from b


From: Jan Kiszka
Subject: Re: [Qemu-trivial] [PATCH] Correct computation of bytes per pixel from bits per pixel
Date: Wed, 22 Aug 2012 10:02:23 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

Can you use this free space to provide a scenario where the missing
round-up caused a problem?

On 2012-08-21 23:32, BALATON Zoltan wrote:
> 
> Signed-off-by: BALATON Zoltan <address@hidden>
> ---
>  console.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/console.c b/console.c
> index 4525cc7..f698b77 100644
> --- a/console.c
> +++ b/console.c
> @@ -1612,7 +1612,7 @@ PixelFormat
> qemu_different_endianness_pixelformat(int bpp)
>      memset(&pf, 0x00, sizeof(PixelFormat));
> 
>      pf.bits_per_pixel = bpp;
> -    pf.bytes_per_pixel = bpp / 8;
> +    pf.bytes_per_pixel = (bpp + 7) >> 3;

Compilers are smart enough to substitute such divisions by shift
operations but for humans the explicit form is easier to read. So please
keep it.

>      pf.depth = bpp == 32 ? 24 : bpp;
> 
>      switch (bpp) {
> @@ -1661,7 +1661,7 @@ PixelFormat qemu_default_pixelformat(int bpp)
>      memset(&pf, 0x00, sizeof(PixelFormat));
> 
>      pf.bits_per_pixel = bpp;
> -    pf.bytes_per_pixel = bpp / 8;
> +    pf.bytes_per_pixel = (bpp + 7) >> 3;
>      pf.depth = bpp == 32 ? 24 : bpp;
> 
>      switch (bpp) {

Jan


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]