aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2013-01-22 11:07:57 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2013-01-30 11:14:46 +0100
commitc64f50d1e250879611e6f328e2c4fb18c8a4ab0c (patch)
tree93e1a5b9279becfec8eba4477924cfa67a1f89b0
parent6528499fa4c3ceaec01ad29d8090ef55918ebfb3 (diff)
g_strdup(NULL) returns NULL; simplify
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-rw-r--r--hw/9pfs/virtio-9p-device.c6
-rw-r--r--hw/block-common.c4
-rw-r--r--net/net.c4
-rw-r--r--slirp/slirp.c8
-rw-r--r--util/qemu-option.c8
5 files changed, 7 insertions, 23 deletions
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 6f427dfc5d..6eab7f7fa1 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) {
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/net/net.c b/net/net.c
index cdd9b04989..2f0ab3a121 100644
--- a/net/net.c
+++ b/net/net.c
@@ -566,9 +566,7 @@ static int net_init_nic(const NetClientOptions *opts, const char *name,
assert(peer);
nd->netdev = peer;
}
- if (name) {
- nd->name = g_strdup(name);
- }
+ nd->name = g_strdup(name);
if (nic->has_model) {
nd->model = g_strdup(nic->model);
}
diff --git a/slirp/slirp.c b/slirp/slirp.c
index e93b578832..0e6e232789 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -225,12 +225,8 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork,
pstrcpy(slirp->client_hostname, sizeof(slirp->client_hostname),
vhostname);
}
- if (tftp_path) {
- slirp->tftp_prefix = g_strdup(tftp_path);
- }
- if (bootfile) {
- slirp->bootp_filename = g_strdup(bootfile);
- }
+ slirp->tftp_prefix = g_strdup(tftp_path);
+ slirp->bootp_filename = g_strdup(bootfile);
slirp->vdhcp_startaddr = vdhcp_start;
slirp->vnameserver_addr = vnameserver;
diff --git a/util/qemu-option.c b/util/qemu-option.c
index f532b765a0..c12e7245ef 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -643,9 +643,7 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value,
QTAILQ_INSERT_TAIL(&opts->head, opt, next);
}
opt->desc = desc;
- if (value) {
- opt->str = g_strdup(value);
- }
+ opt->str = g_strdup(value);
qemu_opt_parse(opt, &local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
@@ -792,9 +790,7 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
}
}
opts = g_malloc0(sizeof(*opts));
- if (id) {
- opts->id = g_strdup(id);
- }
+ opts->id = g_strdup(id);
opts->list = list;
loc_save(&opts->loc);
QTAILQ_INIT(&opts->head);