From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSeWk-0004as-3u for qemu-devel@nongnu.org; Wed, 05 Jul 2017 03:15:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSeWj-0007ep-3f for qemu-devel@nongnu.org; Wed, 05 Jul 2017 03:15:10 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:35239) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dSeWi-0007ds-Rl for qemu-devel@nongnu.org; Wed, 05 Jul 2017 03:15:08 -0400 Received: by mail-wm0-x241.google.com with SMTP id u23so30502950wma.2 for ; Wed, 05 Jul 2017 00:15:08 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 5 Jul 2017 09:14:18 +0200 Message-Id: <1499238885-26161-16-git-send-email-pbonzini@redhat.com> In-Reply-To: <1499238885-26161-1-git-send-email-pbonzini@redhat.com> References: <1499238885-26161-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 15/42] util/oslib-win32: Remove if conditional List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alistair Francis From: Alistair Francis The original ready < nhandles - 1 can be re-written as ready + 1 < nhandles. The check was actually incorrect because WAIT_OBJECT_0 was not subtracted from ready; it worked because WAIT_OBJECT_0 is zero. After subtracting WAIT_OBJECT_0, the result is the same condition that we are checking on the first itteration of the for loop. This means we can remove the if statement and let the for loop check the code. Signed-off-by: Alistair Francis Message-Id: Signed-off-by: Paolo Bonzini --- util/oslib-win32.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 80e4668..3de9e77 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -438,10 +438,8 @@ 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) { - for (i = ready - WAIT_OBJECT_0 + 1; i < nhandles; i++) { - handles[i-1] = handles[i]; - } + for (i = ready - WAIT_OBJECT_0 + 1; i < nhandles; i++) { + handles[i-1] = handles[i]; } nhandles--; recursed_result = poll_rest(FALSE, handles, nhandles, fds, nfds, 0); -- 1.8.3.1