[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PULL 08/20] Drop superfluous conditionals around g_strdu
From: |
Michael Tokarev |
Subject: |
[Qemu-trivial] [PULL 08/20] Drop superfluous conditionals around g_strdup() |
Date: |
Thu, 11 Dec 2014 21:15:56 +0300 |
From: Markus Armbruster <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
backends/rng-random.c | 6 +-----
hw/tpm/tpm_passthrough.c | 4 +---
util/uri.c | 43 +++++++++++++++++--------------------------
3 files changed, 19 insertions(+), 34 deletions(-)
diff --git a/backends/rng-random.c b/backends/rng-random.c
index 601d9dc..4f85a8e 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -88,11 +88,7 @@ static char *rng_random_get_filename(Object *obj, Error
**errp)
{
RndRandom *s = RNG_RANDOM(obj);
- if (s->filename) {
- return g_strdup(s->filename);
- }
-
- return NULL;
+ return g_strdup(s->filename);
}
static void rng_random_set_filename(Object *obj, const char *filename,
diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index 56e9e0f..2bf3c6f 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -400,9 +400,7 @@ static int tpm_passthrough_handle_device_opts(QemuOpts
*opts, TPMBackend *tb)
const char *value;
value = qemu_opt_get(opts, "cancel-path");
- if (value) {
- tb->cancel_path = g_strdup(value);
- }
+ tb->cancel_path = g_strdup(value);
value = qemu_opt_get(opts, "path");
if (!value) {
diff --git a/util/uri.c b/util/uri.c
index e348c17..bbf2832 100644
--- a/util/uri.c
+++ b/util/uri.c
@@ -1736,24 +1736,21 @@ uri_resolve(const char *uri, const char *base) {
goto done;
if ((ref->scheme == NULL) && (ref->path == NULL) &&
((ref->authority == NULL) && (ref->server == NULL))) {
- if (bas->scheme != NULL)
- res->scheme = g_strdup(bas->scheme);
+ res->scheme = g_strdup(bas->scheme);
if (bas->authority != NULL)
res->authority = g_strdup(bas->authority);
else if (bas->server != NULL) {
- res->server = g_strdup(bas->server);
- if (bas->user != NULL)
- res->user = g_strdup(bas->user);
- res->port = bas->port;
+ res->server = g_strdup(bas->server);
+ res->user = g_strdup(bas->user);
+ res->port = bas->port;
}
- if (bas->path != NULL)
- res->path = g_strdup(bas->path);
- if (ref->query != NULL)
+ res->path = g_strdup(bas->path);
+ if (ref->query != NULL) {
res->query = g_strdup (ref->query);
- else if (bas->query != NULL)
- res->query = g_strdup(bas->query);
- if (ref->fragment != NULL)
- res->fragment = g_strdup(ref->fragment);
+ } else {
+ res->query = g_strdup(bas->query);
+ }
+ res->fragment = g_strdup(ref->fragment);
goto step_7;
}
@@ -1767,13 +1764,10 @@ uri_resolve(const char *uri, const char *base) {
val = uri_to_string(ref);
goto done;
}
- if (bas->scheme != NULL)
- res->scheme = g_strdup(bas->scheme);
+ res->scheme = g_strdup(bas->scheme);
- if (ref->query != NULL)
- res->query = g_strdup(ref->query);
- if (ref->fragment != NULL)
- res->fragment = g_strdup(ref->fragment);
+ res->query = g_strdup(ref->query);
+ res->fragment = g_strdup(ref->fragment);
/*
* 4) If the authority component is defined, then the reference is a
@@ -1787,20 +1781,17 @@ uri_resolve(const char *uri, const char *base) {
res->authority = g_strdup(ref->authority);
else {
res->server = g_strdup(ref->server);
- if (ref->user != NULL)
- res->user = g_strdup(ref->user);
+ res->user = g_strdup(ref->user);
res->port = ref->port;
}
- if (ref->path != NULL)
- res->path = g_strdup(ref->path);
+ res->path = g_strdup(ref->path);
goto step_7;
}
if (bas->authority != NULL)
res->authority = g_strdup(bas->authority);
else if (bas->server != NULL) {
- res->server = g_strdup(bas->server);
- if (bas->user != NULL)
- res->user = g_strdup(bas->user);
+ res->server = g_strdup(bas->server);
+ res->user = g_strdup(bas->user);
res->port = bas->port;
}
--
2.1.3
- [Qemu-trivial] [PULL 14/20] fw_cfg: remove superfluous blank line, (continued)
- [Qemu-trivial] [PULL 14/20] fw_cfg: remove superfluous blank line, Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 01/20] qmp: fix typo in input-send-event examples, Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 19/20] hpet: increase spelling precision, Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 13/20] get_maintainer.pl: Remove the --git-chief-penguins option, Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 11/20] util: Use g_new() & friends where that makes obvious sense, Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 18/20] pflash_cfi02.c: associate "cfi.pflash02" to "Storage devices" category, Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 16/20] virtio: remove useless declaration of virtio_net_init(), Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 10/20] util: Fuse g_malloc(); memset() into g_new0(), Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 12/20] configure: Replace which(1) with "has", Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 17/20] vt82c686: fix coverity warning about out-of-bounds write, Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 08/20] Drop superfluous conditionals around g_strdup(),
Michael Tokarev <=
- [Qemu-trivial] [PULL 09/20] util: Drop superfluous conditionals around g_free(), Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 20/20] Sort include/qemu/typedefs.h, Michael Tokarev, 2014/12/11
- Re: [Qemu-trivial] [Qemu-devel] [PULL 00/20] Trivial patches for 2014-12-11, Peter Maydell, 2014/12/11