From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:48822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNpQ2-0002jf-MH for qemu-devel@nongnu.org; Tue, 08 Nov 2011 12:25:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RNpQ1-0000QZ-Dr for qemu-devel@nongnu.org; Tue, 08 Nov 2011 12:25:06 -0500 Received: from mail-gx0-f173.google.com ([209.85.161.173]:53050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNpQ1-0000P7-5L for qemu-devel@nongnu.org; Tue, 08 Nov 2011 12:25:05 -0500 Received: by ggnp2 with SMTP id p2so869397ggn.4 for ; Tue, 08 Nov 2011 09:25:04 -0800 (PST) Message-ID: <4EB965C3.7090000@codemonkey.ws> Date: Tue, 08 Nov 2011 11:24:19 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <20111106160022.GF3225@redhat.com> In-Reply-To: <20111106160022.GF3225@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qemu_timedate_diff() shouldn't modify its argument. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gleb Natapov Cc: qemu-devel@nongnu.org On 11/06/2011 10:00 AM, Gleb Natapov wrote: > The caller of qemu_timedate_diff() does not expect that tm it passes to > the function will be modified, but mktime() is destructive and modifies > its argument. Pass a copy of tm to it and set tm_isdst so that mktime() > will not rely on it since its value may be outdated. > > Signed-off-by: Gleb Natapov Applied. Thanks. Regards, Anthony Liguori > diff --git a/vl.c b/vl.c > index 624da0f..641629b 100644 > --- a/vl.c > +++ b/vl.c > @@ -460,8 +460,11 @@ int qemu_timedate_diff(struct tm *tm) > if (rtc_date_offset == -1) > if (rtc_utc) > seconds = mktimegm(tm); > - else > - seconds = mktime(tm); > + else { > + struct tm tmp = *tm; > + tmp.tm_isdst = -1; /* use timezone to figure it out */ > + seconds = mktime(&tmp); > + } > else > seconds = mktimegm(tm) + rtc_date_offset; > > -- > Gleb. > >