qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [RFC v1 3/4] util/oslib-win32: Fix up if conditional


From: Paolo Bonzini
Subject: Re: [Qemu-block] [RFC v1 3/4] util/oslib-win32: Fix up if conditional
Date: Thu, 29 Jun 2017 14:25:32 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0


On 28/06/2017 01:57, Alistair Francis wrote:
> Signed-off-by: Alistair Francis <address@hidden>
> Acked-by: Edgar E. Iglesias <address@hidden>
> ---
> 
>  util/oslib-win32.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/util/oslib-win32.c b/util/oslib-win32.c
> index 7ec0f8e083..a015e1ac96 100644
> --- a/util/oslib-win32.c
> +++ b/util/oslib-win32.c
> @@ -438,7 +438,7 @@ static int poll_rest(gboolean poll_msgs, HANDLE *handles, 
> gint nhandles,
>          if (timeout == 0 && nhandles > 1) {
>              /* Remove the handle that fired */
>              int i;
> -            if (ready < nhandles - 1) {
> +            if ((ready - WAIT_OBJECT_0) < nhandles - 1) {
>                  for (i = ready - WAIT_OBJECT_0 + 1; i < nhandles; i++) {
>                      handles[i-1] = handles[i];
>                  }
> 

WAIT_OBJECT_0 is zero, but I agree it's better to add it.

However, the condition can be rewritten as ready - WAIT_OBJECT_0 + 1 <
nhandles, which is the same as the first iteration's "i < nhandles".  So
I'd just remove the "if" and "unindent" the for loop.

Paolo



reply via email to

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