* [Qemu-devel] [PATCH] Replace remaining gmtime, localtime by gmtime_r, localtime_r
@ 2013-01-07 22:08 Stefan Weil
2013-01-11 8:41 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
2013-01-11 8:46 ` Stefan Hajnoczi
0 siblings, 2 replies; 3+ messages in thread
From: Stefan Weil @ 2013-01-07 22:08 UTC (permalink / raw)
To: qemu-trivial
Cc: Kevin Wolf, Peter Maydell, Anthony Liguori, Stefan Weil,
qemu-devel, Stefan Hajnoczi
This allows removing of MinGW specific code and improves
reentrancy for POSIX hosts.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
block.c | 10 ----------
block/vvfat.c | 4 ----
hw/omap1.c | 2 +-
vl.c | 8 +++-----
4 files changed, 4 insertions(+), 20 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..21e4a74 100644
--- a/vl.c
+++ b/vl.c
@@ -454,15 +454,13 @@ void qemu_get_timedate(struct tm *tm, int offset)
ti += offset;
if (rtc_date_offset == -1) {
if (rtc_utc)
- ret = gmtime(&ti);
+ ret = gmtime_r(&ti, tm);
else
- ret = localtime(&ti);
+ ret = localtime_r(&ti, tm);
} else {
ti -= rtc_date_offset;
- ret = gmtime(&ti);
+ ret = gmtime_r(&ti, tm);
}
-
- memcpy(tm, ret, sizeof(struct tm));
}
int qemu_timedate_diff(struct tm *tm)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] Replace remaining gmtime, localtime by gmtime_r, localtime_r
2013-01-07 22:08 [Qemu-devel] [PATCH] Replace remaining gmtime, localtime by gmtime_r, localtime_r Stefan Weil
@ 2013-01-11 8:41 ` Stefan Hajnoczi
2013-01-11 8:46 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2013-01-11 8:41 UTC (permalink / raw)
To: Stefan Weil
Cc: Kevin Wolf, Peter Maydell, Anthony Liguori, qemu-trivial,
qemu-devel, Stefan Hajnoczi
On Mon, Jan 07, 2013 at 11:08:13PM +0100, Stefan Weil wrote:
> This allows removing of MinGW specific code and improves
> reentrancy for POSIX hosts.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
> block.c | 10 ----------
> block/vvfat.c | 4 ----
> hw/omap1.c | 2 +-
> vl.c | 8 +++-----
> 4 files changed, 4 insertions(+), 20 deletions(-)
Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] Replace remaining gmtime, localtime by gmtime_r, localtime_r
2013-01-07 22:08 [Qemu-devel] [PATCH] Replace remaining gmtime, localtime by gmtime_r, localtime_r Stefan Weil
2013-01-11 8:41 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
@ 2013-01-11 8:46 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2013-01-11 8:46 UTC (permalink / raw)
To: Stefan Weil
Cc: Kevin Wolf, Peter Maydell, Anthony Liguori, qemu-trivial,
qemu-devel, Stefan Hajnoczi
On Mon, Jan 07, 2013 at 11:08:13PM +0100, Stefan Weil wrote:
> diff --git a/vl.c b/vl.c
> index f056c95..21e4a74 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -454,15 +454,13 @@ void qemu_get_timedate(struct tm *tm, int offset)
> ti += offset;
> if (rtc_date_offset == -1) {
> if (rtc_utc)
> - ret = gmtime(&ti);
> + ret = gmtime_r(&ti, tm);
> else
> - ret = localtime(&ti);
> + ret = localtime_r(&ti, tm);
> } else {
> ti -= rtc_date_offset;
> - ret = gmtime(&ti);
> + ret = gmtime_r(&ti, tm);
> }
> -
> - memcpy(tm, ret, sizeof(struct tm));
> }
BTW I fixed the compiler warning here, no need to respin:
vl.c: In function ‘qemu_get_timedate’:
vl.c:451:16: error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable]
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-01-11 8:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-07 22:08 [Qemu-devel] [PATCH] Replace remaining gmtime, localtime by gmtime_r, localtime_r Stefan Weil
2013-01-11 8:41 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
2013-01-11 8:46 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).