From patchwork Fri Jan 11 09:18:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 211252 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 006B32C01FB for ; Fri, 11 Jan 2013 20:19:16 +1100 (EST) Received: from localhost ([::1]:48795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttale-0001jq-3d for incoming@patchwork.ozlabs.org; Fri, 11 Jan 2013 04:19:14 -0500 Received: from eggs.gnu.org ([208.118.235.92]:40748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttaku-0008WJ-5f for qemu-devel@nongnu.org; Fri, 11 Jan 2013 04:18:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ttakq-0005f9-Om for qemu-devel@nongnu.org; Fri, 11 Jan 2013 04:18:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36597) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttakq-0005f3-Gq for qemu-devel@nongnu.org; Fri, 11 Jan 2013 04:18:24 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0B9IN30026620 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 11 Jan 2013 04:18:24 -0500 Received: from localhost (dhcp-64-10.muc.redhat.com [10.32.64.10]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0B9INXL013087; Fri, 11 Jan 2013 04:18:23 -0500 From: Stefan Hajnoczi To: Date: Fri, 11 Jan 2013 10:18:05 +0100 Message-Id: <1357895886-14283-6-git-send-email-stefanha@redhat.com> In-Reply-To: <1357895886-14283-1-git-send-email-stefanha@redhat.com> References: <1357895886-14283-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id r0B9IN30026620 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Stefan Weil , Anthony Liguori , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 5/6] Replace remaining gmtime, localtime by gmtime_r, localtime_r X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stefan Weil This allows removing of MinGW specific code and improves reentrancy for POSIX hosts. [Removed unused ret variable in qemu_get_timedate() to fix warning: vl.c: In function ‘qemu_get_timedate’: vl.c:451:16: error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable] -- Stefan Hajnoczi] Signed-off-by: Stefan Weil Signed-off-by: Stefan Hajnoczi --- block.c | 10 ---------- block/vvfat.c | 4 ---- hw/omap1.c | 2 +- vl.c | 9 +++------ 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/block.c b/block.c index 4e28c55..60873ea 100644 --- a/block.c +++ b/block.c @@ -3338,11 +3338,7 @@ char *get_human_readable_size(char *buf, int buf_size, int64_t size) char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn) { char buf1[128], date_buf[128], clock_buf[128]; -#ifdef _WIN32 - struct tm *ptm; -#else struct tm tm; -#endif time_t ti; int64_t secs; @@ -3352,15 +3348,9 @@ char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn) "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK"); } else { ti = sn->date_sec; -#ifdef _WIN32 - ptm = localtime(&ti); - strftime(date_buf, sizeof(date_buf), - "%Y-%m-%d %H:%M:%S", ptm); -#else localtime_r(&ti, &tm); strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm); -#endif secs = sn->vm_clock_nsec / 1000000000; snprintf(clock_buf, sizeof(clock_buf), "%02d:%02d:%02d.%03d", diff --git a/block/vvfat.c b/block/vvfat.c index 83706ce..06e6654 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -529,13 +529,9 @@ static inline uint8_t fat_chksum(const direntry_t* entry) /* if return_time==0, this returns the fat_date, else the fat_time */ static uint16_t fat_datetime(time_t time,int return_time) { struct tm* t; -#ifdef _WIN32 - t=localtime(&time); /* this is not thread safe */ -#else struct tm t1; t = &t1; localtime_r(&time,t); -#endif if(return_time) return cpu_to_le16((t->tm_sec/2)|(t->tm_min<<5)|(t->tm_hour<<11)); return cpu_to_le16((t->tm_mday)|((t->tm_mon+1)<<5)|((t->tm_year-80)<<9)); diff --git a/hw/omap1.c b/hw/omap1.c index 8536e96..e85f2e2 100644 --- a/hw/omap1.c +++ b/hw/omap1.c @@ -2830,7 +2830,7 @@ static void omap_rtc_tick(void *opaque) s->round = 0; } - memcpy(&s->current_tm, localtime(&s->ti), sizeof(s->current_tm)); + localtime_r(&s->ti, &s->current_tm); if ((s->interrupts & 0x08) && s->ti == s->alarm_ti) { s->status |= 0x40; diff --git a/vl.c b/vl.c index f056c95..aed4182 100644 --- a/vl.c +++ b/vl.c @@ -448,21 +448,18 @@ StatusInfo *qmp_query_status(Error **errp) void qemu_get_timedate(struct tm *tm, int offset) { time_t ti; - struct tm *ret; time(&ti); ti += offset; if (rtc_date_offset == -1) { if (rtc_utc) - ret = gmtime(&ti); + gmtime_r(&ti, tm); else - ret = localtime(&ti); + localtime_r(&ti, tm); } else { ti -= rtc_date_offset; - ret = gmtime(&ti); + gmtime_r(&ti, tm); } - - memcpy(tm, ret, sizeof(struct tm)); } int qemu_timedate_diff(struct tm *tm)