Merge remote-tracking branch 'stefanha/trivial-patches' into staging

* stefanha/trivial-patches:
  hw/pc.c: Fix converting of ioport_register* to MemoryRegion
  Replace remaining gmtime, localtime by gmtime_r, localtime_r
  savevm: Remove MinGW specific code which is no longer needed
  qga/channel-posix.c: Explicitly include string.h
  configure: Fix comment (copy+paste bug)
  readline: avoid memcpy() of overlapping regions

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Anthony Liguori 2013-01-11 08:43:18 -06:00
commit fedf2de310
9 changed files with 22 additions and 52 deletions

10
block.c
View File

@ -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",

View File

@ -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));

2
configure vendored
View File

@ -2705,7 +2705,7 @@ if compile_prog "" "" ; then
byteswap_h=yes
fi
# Search for bswap_32 function
# Search for bswap32 function
bswap_h=no
cat > $TMPC << EOF
#include <sys/endian.h>

View File

@ -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;

12
hw/pc.c
View File

@ -103,6 +103,11 @@ static void ioport80_write(void *opaque, hwaddr addr, uint64_t data,
{
}
static uint64_t ioport80_read(void *opaque, hwaddr addr, unsigned size)
{
return 0xffffffffffffffff;
}
/* MSDOS compatibility mode FPU exception support */
static qemu_irq ferr_irq;
@ -123,6 +128,11 @@ static void ioportF0_write(void *opaque, hwaddr addr, uint64_t data,
qemu_irq_lower(ferr_irq);
}
static uint64_t ioportF0_read(void *opaque, hwaddr addr, unsigned size)
{
return 0xffffffffffffffff;
}
/* TSC handling */
uint64_t cpu_get_tsc(CPUX86State *env)
{
@ -960,6 +970,7 @@ static void cpu_request_exit(void *opaque, int irq, int level)
static const MemoryRegionOps ioport80_io_ops = {
.write = ioport80_write,
.read = ioport80_read,
.endianness = DEVICE_NATIVE_ENDIAN,
.impl = {
.min_access_size = 1,
@ -969,6 +980,7 @@ static const MemoryRegionOps ioport80_io_ops = {
static const MemoryRegionOps ioportF0_io_ops = {
.write = ioportF0_write,
.read = ioportF0_read,
.endianness = DEVICE_NATIVE_ENDIAN,
.impl = {
.min_access_size = 1,

View File

@ -4,6 +4,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include "qemu/osdep.h"
#include "qemu/sockets.h"
#include "qga/channel.h"

View File

@ -248,8 +248,8 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)
if (idx == READLINE_MAX_CMDS) {
/* Need to get one free slot */
free(rs->history[0]);
memcpy(rs->history, &rs->history[1],
(READLINE_MAX_CMDS - 1) * sizeof(char *));
memmove(rs->history, &rs->history[1],
(READLINE_MAX_CMDS - 1) * sizeof(char *));
rs->history[READLINE_MAX_CMDS - 1] = NULL;
idx = READLINE_MAX_CMDS - 1;
}

View File

@ -23,15 +23,6 @@
*/
#include "config-host.h"
#ifndef _WIN32
#include <arpa/inet.h>
#endif
#ifdef _WIN32
#include <windows.h>
#endif
#include "qemu-common.h"
#include "hw/hw.h"
#include "hw/qdev.h"
@ -2093,13 +2084,8 @@ void do_savevm(Monitor *mon, const QDict *qdict)
QEMUFile *f;
int saved_vm_running;
uint64_t vm_state_size;
#ifdef _WIN32
struct _timeb tb;
struct tm *ptm;
#else
struct timeval tv;
qemu_timeval tv;
struct tm tm;
#endif
const char *name = qdict_get_try_str(qdict, "name");
/* Verify if there is a device that doesn't support snapshots and is writable */
@ -2129,15 +2115,9 @@ void do_savevm(Monitor *mon, const QDict *qdict)
memset(sn, 0, sizeof(*sn));
/* fill auxiliary fields */
#ifdef _WIN32
_ftime(&tb);
sn->date_sec = tb.time;
sn->date_nsec = tb.millitm * 1000000;
#else
gettimeofday(&tv, NULL);
qemu_gettimeofday(&tv);
sn->date_sec = tv.tv_sec;
sn->date_nsec = tv.tv_usec * 1000;
#endif
sn->vm_clock_nsec = qemu_get_clock_ns(vm_clock);
if (name) {
@ -2149,15 +2129,9 @@ void do_savevm(Monitor *mon, const QDict *qdict)
pstrcpy(sn->name, sizeof(sn->name), name);
}
} else {
#ifdef _WIN32
time_t t = tb.time;
ptm = localtime(&t);
strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", ptm);
#else
/* cast below needed for OpenBSD where tv_sec is still 'long' */
localtime_r((const time_t *)&tv.tv_sec, &tm);
strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm);
#endif
}
/* Delete old snapshots of the same name */

9
vl.c
View File

@ -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)