aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2013-01-30 10:51:18 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2013-01-30 10:51:18 -0600
commitb0df98f3a2968eb5aba3075d1cf9b1a3931907e0 (patch)
treea728d1405d22b86de4ad994a27eb8192e619cf57 /hw
parent7cc2a8b14a363777e7d5b7d102176fba0cf27667 (diff)
parent99f4280854514b22972bd257fe5facc439222d2e (diff)
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
# By Markus Armbruster (12) and others # Via Stefan Hajnoczi * stefanha/trivial-patches: qmp-commands.hx: s/tray-open/tray_open/ to match qapi schema tests: Fix {rtc, m48t59}-test build on illumos qemu-pixman.h: Avoid mutual inclusion loop with console.h qemu-ga: Fix unchecked strdup() by converting to g_strdup() qapi: Fix unchecked strdup() by converting to g_strdup() libcacard: Fix unchecked strdup() by converting to g_strdup() qemu-log: Plug trivial memory leak in cpu_set_log_filename() qemu-log: Fix unchecked strdup() by converting to g_strdup() virtfs-proxy-helper: Fix unchecked strdup() by conv. to g_strdup() spice: Fix unchecked strdup() by converting to g_strdup() readline: Fix unchecked strdup() by converting to g_strdup() hw/9pfs: Fix unchecked strdup() by converting to g_strdup() g_strdup(NULL) returns NULL; simplify g_malloc(0) and g_malloc0(0) return NULL; simplify xilinx_axidma: Fix debug mode compile messages cadence_gem: Debug mode compile fixes cadence_ttc: Debug mode compile fixes vnc: Clean up vncws_send_handshake_response()
Diffstat (limited to 'hw')
-rw-r--r--hw/9pfs/virtio-9p-device.c8
-rw-r--r--hw/9pfs/virtio-9p-local.c8
-rw-r--r--hw/9pfs/virtio-9p.c6
-rw-r--r--hw/block-common.c4
-rw-r--r--hw/cadence_gem.c17
-rw-r--r--hw/cadence_ttc.c4
-rw-r--r--hw/vhost.c7
-rw-r--r--hw/xilinx_axidma.c2
8 files changed, 23 insertions, 33 deletions
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 6f427dfc5d..74155fb61e 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -85,11 +85,7 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
}
s->ctx.export_flags = fse->export_flags;
- if (fse->path) {
- s->ctx.fs_root = g_strdup(fse->path);
- } else {
- s->ctx.fs_root = NULL;
- }
+ s->ctx.fs_root = g_strdup(fse->path);
s->ctx.exops.get_st_gen = NULL;
len = strlen(conf->tag);
if (len > MAX_TAG_LEN - 1) {
@@ -98,7 +94,7 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
exit(1);
}
- s->tag = strdup(conf->tag);
+ s->tag = g_strdup(conf->tag);
s->ctx.uid = -1;
s->ops = fse->ops;
diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c
index 113602144c..f1b1c83a22 100644
--- a/hw/9pfs/virtio-9p-local.c
+++ b/hw/9pfs/virtio-9p-local.c
@@ -46,7 +46,7 @@ static const char *local_mapped_attr_path(FsContext *ctx,
const char *path, char *buffer)
{
char *dir_name;
- char *tmp_path = strdup(path);
+ char *tmp_path = g_strdup(path);
char *base_name = basename(tmp_path);
/* NULL terminate the directory */
@@ -55,7 +55,7 @@ static const char *local_mapped_attr_path(FsContext *ctx,
snprintf(buffer, PATH_MAX, "%s/%s/%s/%s",
ctx->fs_root, dir_name, VIRTFS_META_DIR, base_name);
- free(tmp_path);
+ g_free(tmp_path);
return buffer;
}
@@ -130,7 +130,7 @@ static int local_create_mapped_attr_dir(FsContext *ctx, const char *path)
{
int err;
char attr_dir[PATH_MAX];
- char *tmp_path = strdup(path);
+ char *tmp_path = g_strdup(path);
snprintf(attr_dir, PATH_MAX, "%s/%s/%s",
ctx->fs_root, dirname(tmp_path), VIRTFS_META_DIR);
@@ -139,7 +139,7 @@ static int local_create_mapped_attr_dir(FsContext *ctx, const char *path)
if (err < 0 && errno == EEXIST) {
err = 0;
}
- free(tmp_path);
+ g_free(tmp_path);
return err;
}
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 0aaf0d2de0..b795839620 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -3101,11 +3101,7 @@ static void v9fs_xattrcreate(void *opaque)
xattr_fidp->fs.xattr.flags = flags;
v9fs_string_init(&xattr_fidp->fs.xattr.name);
v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name);
- if (size) {
- xattr_fidp->fs.xattr.value = g_malloc(size);
- } else {
- xattr_fidp->fs.xattr.value = NULL;
- }
+ xattr_fidp->fs.xattr.value = g_malloc(size);
err = offset;
put_fid(pdu, file_fidp);
out_nofid:
diff --git a/hw/block-common.c b/hw/block-common.c
index 0f1b64ec95..d21ec3ada1 100644
--- a/hw/block-common.c
+++ b/hw/block-common.c
@@ -18,9 +18,7 @@ void blkconf_serial(BlockConf *conf, char **serial)
if (!*serial) {
/* try to fall back to value set with legacy -drive serial=... */
dinfo = drive_get_by_blockdev(conf->bs);
- if (dinfo->serial) {
- *serial = g_strdup(dinfo->serial);
- }
+ *serial = g_strdup(dinfo->serial);
}
}
diff --git a/hw/cadence_gem.c b/hw/cadence_gem.c
index 0d834422df..b77423d449 100644
--- a/hw/cadence_gem.c
+++ b/hw/cadence_gem.c
@@ -687,14 +687,15 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
packet_desc_addr = s->rx_desc_addr;
while (1) {
- DB_PRINT("read descriptor 0x%x\n", packet_desc_addr);
+ DB_PRINT("read descriptor 0x%x\n", (unsigned)packet_desc_addr);
/* read current descriptor */
cpu_physical_memory_read(packet_desc_addr,
(uint8_t *)&desc[0], sizeof(desc));
/* Descriptor owned by software ? */
if (rx_desc_get_ownership(desc) == 1) {
- DB_PRINT("descriptor 0x%x owned by sw.\n", packet_desc_addr);
+ DB_PRINT("descriptor 0x%x owned by sw.\n",
+ (unsigned)packet_desc_addr);
s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_NOBUF;
/* Handle interrupt consequences */
gem_update_int_status(s);
@@ -709,7 +710,7 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
*/
if (rx_desc_get_buffer(desc) == 0) {
DB_PRINT("Invalid RX buffer (NULL) for descriptor 0x%x\n",
- packet_desc_addr);
+ (unsigned)packet_desc_addr);
break;
}
@@ -749,7 +750,7 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
s->rx_desc_addr += 8;
}
- DB_PRINT("set SOF, OWN on descriptor 0x%08x\n", packet_desc_addr);
+ DB_PRINT("set SOF, OWN on descriptor 0x%08x\n", (unsigned)packet_desc_addr);
/* Count it */
gem_receive_updatestats(s, buf, size);
@@ -861,7 +862,8 @@ static void gem_transmit(GemState *s)
*/
if ((tx_desc_get_buffer(desc) == 0) ||
(tx_desc_get_length(desc) == 0)) {
- DB_PRINT("Invalid TX descriptor @ 0x%x\n", packet_desc_addr);
+ DB_PRINT("Invalid TX descriptor @ 0x%x\n",
+ (unsigned)packet_desc_addr);
break;
}
@@ -1031,10 +1033,11 @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size)
offset >>= 2;
retval = s->regs[offset];
- DB_PRINT("offset: 0x%04x read: 0x%08x\n", offset*4, retval);
+ DB_PRINT("offset: 0x%04x read: 0x%08x\n", (unsigned)offset*4, retval);
switch (offset) {
case GEM_ISR:
+ DB_PRINT("lowering irq on ISR read\n");
qemu_set_irq(s->irq, 0);
break;
case GEM_PHYMNTNC:
@@ -1073,7 +1076,7 @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val,
GemState *s = (GemState *)opaque;
uint32_t readonly;
- DB_PRINT("offset: 0x%04x write: 0x%08x ", offset, (unsigned)val);
+ DB_PRINT("offset: 0x%04x write: 0x%08x ", (unsigned)offset, (unsigned)val);
offset >>= 2;
/* Squash bits which are read only in write value */
diff --git a/hw/cadence_ttc.c b/hw/cadence_ttc.c
index 2a8fadd810..67028a3f75 100644
--- a/hw/cadence_ttc.c
+++ b/hw/cadence_ttc.c
@@ -302,7 +302,7 @@ static uint64_t cadence_ttc_read(void *opaque, hwaddr offset,
{
uint32_t ret = cadence_ttc_read_imp(opaque, offset);
- DB_PRINT("addr: %08x data: %08x\n", offset, ret);
+ DB_PRINT("addr: %08x data: %08x\n", (unsigned)offset, (unsigned)ret);
return ret;
}
@@ -311,7 +311,7 @@ static void cadence_ttc_write(void *opaque, hwaddr offset,
{
CadenceTimerState *s = cadence_timer_from_addr(opaque, offset);
- DB_PRINT("addr: %08x data %08x\n", offset, (unsigned)value);
+ DB_PRINT("addr: %08x data %08x\n", (unsigned)offset, (unsigned)value);
cadence_timer_sync(s);
diff --git a/hw/vhost.c b/hw/vhost.c
index cee8aad4a1..0dd2a9aa40 100644
--- a/hw/vhost.c
+++ b/hw/vhost.c
@@ -269,11 +269,8 @@ static inline void vhost_dev_log_resize(struct vhost_dev* dev, uint64_t size)
vhost_log_chunk_t *log;
uint64_t log_base;
int r, i;
- if (size) {
- log = g_malloc0(size * sizeof *log);
- } else {
- log = NULL;
- }
+
+ log = g_malloc0(size * sizeof *log);
log_base = (uint64_t)(unsigned long)log;
r = ioctl(dev->control, VHOST_SET_LOG_BASE, &log_base);
assert(r >= 0);
diff --git a/hw/xilinx_axidma.c b/hw/xilinx_axidma.c
index d0ee566a28..cc51584dfc 100644
--- a/hw/xilinx_axidma.c
+++ b/hw/xilinx_axidma.c
@@ -444,7 +444,7 @@ static void axidma_write(void *opaque, hwaddr addr,
break;
default:
D(qemu_log("%s: ch=%d addr=" TARGET_FMT_plx " v=%x\n",
- __func__, sid, addr * 4, value));
+ __func__, sid, addr * 4, (unsigned)value));
s->regs[addr] = value;
break;
}