From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NrwZx-0008EA-IE for qemu-devel@nongnu.org; Wed, 17 Mar 2010 12:58:45 -0400 Received: from [199.232.76.173] (port=35635 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrwZx-0008Dl-2w for qemu-devel@nongnu.org; Wed, 17 Mar 2010 12:58:45 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NrwZv-0004lR-Lz for qemu-devel@nongnu.org; Wed, 17 Mar 2010 12:58:44 -0400 Received: from mail-pv0-f173.google.com ([74.125.83.173]:60371) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NrwZv-0004lH-B7 for qemu-devel@nongnu.org; Wed, 17 Mar 2010 12:58:43 -0400 Received: by pvf33 with SMTP id 33so615531pvf.4 for ; Wed, 17 Mar 2010 09:58:41 -0700 (PDT) Message-ID: <4BA10A38.1020709@codemonkey.ws> Date: Wed, 17 Mar 2010 11:58:32 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 01/18] avoid dubiously clever code in win32_start_timer References: <1268217535-26554-1-git-send-email-pbonzini@redhat.com> <1268217535-26554-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1268217535-26554-2-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On 03/10/2010 04:38 AM, Paolo Bonzini wrote: > The code is initializing an unsigned int to UINT_MAX using "-1", so that > the following always-true comparison seems to be always-false at a > first look. Since alarm timer initializations are never nested, it is > simpler to unconditionally store the result of timeGetDevCaps into > data->period. > > Signed-off-by: Paolo Bonzini > Applied all. Thanks. Nice cleanup. Regards, Anthony Liguori > --- > vl.c | 6 ++---- > 1 files changed, 2 insertions(+), 4 deletions(-) > > diff --git a/vl.c b/vl.c > index d8328c7..6b1e1a7 100644 > --- a/vl.c > +++ b/vl.c > @@ -626,7 +626,7 @@ static struct qemu_alarm_timer *alarm_timer; > struct qemu_alarm_win32 { > MMRESULT timerId; > unsigned int period; > -} alarm_win32_data = {0, -1}; > +} alarm_win32_data = {0, 0}; > > static int win32_start_timer(struct qemu_alarm_timer *t); > static void win32_stop_timer(struct qemu_alarm_timer *t); > @@ -1360,9 +1360,7 @@ static int win32_start_timer(struct qemu_alarm_timer *t) > memset(&tc, 0, sizeof(tc)); > timeGetDevCaps(&tc, sizeof(tc)); > > - if (data->period< tc.wPeriodMin) > - data->period = tc.wPeriodMin; > - > + data->period = tc.wPeriodMin; > timeBeginPeriod(data->period); > > flags = TIME_CALLBACK_FUNCTION; >