[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/28] util/uri: do not check argument of uri_free()
From: |
Kevin Wolf |
Subject: |
[PULL 09/28] util/uri: do not check argument of uri_free() |
Date: |
Fri, 9 Jul 2021 14:50:16 +0200 |
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
uri_free() checks if its argument is NULL in uri_clean() and g_free().
There is no need to check the argument before the call.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Message-Id: <20210629063602.4239-1-xypron.glpk@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/nfs.c | 4 +---
block/ssh.c | 4 +---
util/uri.c | 22 ++++++----------------
3 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/block/nfs.c b/block/nfs.c
index 7dff64f489..9aeaefb364 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -147,9 +147,7 @@ out:
if (qp) {
query_params_free(qp);
}
- if (uri) {
- uri_free(uri);
- }
+ uri_free(uri);
return ret;
}
diff --git a/block/ssh.c b/block/ssh.c
index d008caf059..e0fbb4934b 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -237,9 +237,7 @@ static int parse_uri(const char *filename, QDict *options,
Error **errp)
return 0;
err:
- if (uri) {
- uri_free(uri);
- }
+ uri_free(uri);
return -EINVAL;
}
diff --git a/util/uri.c b/util/uri.c
index 8bdef84120..ff72c6005f 100644
--- a/util/uri.c
+++ b/util/uri.c
@@ -1340,7 +1340,7 @@ static void uri_clean(URI *uri)
/**
* uri_free:
- * @uri: pointer to an URI
+ * @uri: pointer to an URI, NULL is ignored
*
* Free up the URI struct
*/
@@ -1939,15 +1939,9 @@ step_7:
val = uri_to_string(res);
done:
- if (ref != NULL) {
- uri_free(ref);
- }
- if (bas != NULL) {
- uri_free(bas);
- }
- if (res != NULL) {
- uri_free(res);
- }
+ uri_free(ref);
+ uri_free(bas);
+ uri_free(res);
return val;
}
@@ -2190,12 +2184,8 @@ done:
if (remove_path != 0) {
ref->path = NULL;
}
- if (ref != NULL) {
- uri_free(ref);
- }
- if (bas != NULL) {
- uri_free(bas);
- }
+ uri_free(ref);
+ uri_free(bas);
return val;
}
--
2.31.1
- [PULL 00/28] Block layer patches, Kevin Wolf, 2021/07/09
- [PULL 01/28] MAINTAINERS: update block/rbd.c maintainer, Kevin Wolf, 2021/07/09
- [PULL 02/28] block/rbd: Add support for rbd image encryption, Kevin Wolf, 2021/07/09
- [PULL 04/28] block/rbd: store object_size in BDRVRBDState, Kevin Wolf, 2021/07/09
- [PULL 03/28] block/rbd: bump librbd requirement to luminous release, Kevin Wolf, 2021/07/09
- [PULL 05/28] block/rbd: update s->image_size in qemu_rbd_getlength, Kevin Wolf, 2021/07/09
- [PULL 06/28] block/rbd: migrate from aio to coroutines, Kevin Wolf, 2021/07/09
- [PULL 07/28] block/rbd: add write zeroes support, Kevin Wolf, 2021/07/09
- [PULL 09/28] util/uri: do not check argument of uri_free(),
Kevin Wolf <=
- [PULL 08/28] block/rbd: drop qemu_rbd_refresh_limits, Kevin Wolf, 2021/07/09
- [PULL 10/28] export/fuse: Pass default_permissions for mount, Kevin Wolf, 2021/07/09
- [PULL 11/28] export/fuse: Add allow-other option, Kevin Wolf, 2021/07/09
- [PULL 12/28] export/fuse: Give SET_ATTR_SIZE its own branch, Kevin Wolf, 2021/07/09
- [PULL 13/28] export/fuse: Let permissions be adjustable, Kevin Wolf, 2021/07/09
- [PULL 14/28] iotests/308: Test +w on read-only FUSE exports, Kevin Wolf, 2021/07/09
- [PULL 15/28] iotests/fuse-allow-other: Test allow-other, Kevin Wolf, 2021/07/09
- [PULL 17/28] MAINTAINERS: add block/rbd.c reviewer, Kevin Wolf, 2021/07/09
- [PULL 16/28] block/rbd: fix type of task->complete, Kevin Wolf, 2021/07/09
- [PULL 18/28] vhost-user: Fix backends without multiqueue support, Kevin Wolf, 2021/07/09