|
|
05bba0 |
From 7c92e003601bf83d662f5e21a4bc095de875e906 Mon Sep 17 00:00:00 2001
|
|
|
05bba0 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
05bba0 |
Date: Tue, 8 Sep 2015 18:06:20 +0200
|
|
|
05bba0 |
Subject: [PATCH 2/7] util: Drop superfluous conditionals around g_free()
|
|
|
05bba0 |
|
|
|
05bba0 |
Message-id: <1441735585-23432-3-git-send-email-armbru@redhat.com>
|
|
|
05bba0 |
Patchwork-id: 67707
|
|
|
05bba0 |
O-Subject: [RHEL-7.2 qemu-kvm PATCH 2/7] util: Drop superfluous conditionals around g_free()
|
|
|
05bba0 |
Bugzilla: 1218919
|
|
|
05bba0 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
05bba0 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
05bba0 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
05bba0 |
|
|
|
05bba0 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
05bba0 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
05bba0 |
Reviewed-by: Fam Zheng <famz@redhat.com>
|
|
|
05bba0 |
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
|
|
|
05bba0 |
(cherry picked from commit 44c2286b5df1f50fc9fedabd7b1a5a8022e583fc)
|
|
|
05bba0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
05bba0 |
---
|
|
|
05bba0 |
util/uri.c | 48 ++++++++++++++++++++++--------------------------
|
|
|
05bba0 |
1 file changed, 22 insertions(+), 26 deletions(-)
|
|
|
05bba0 |
|
|
|
05bba0 |
diff --git a/util/uri.c b/util/uri.c
|
|
|
05bba0 |
index bbf2832..01dc09e 100644
|
|
|
05bba0 |
--- a/util/uri.c
|
|
|
05bba0 |
+++ b/util/uri.c
|
|
|
05bba0 |
@@ -225,7 +225,7 @@ rfc3986_parse_scheme(URI *uri, const char **str) {
|
|
|
05bba0 |
while (ISA_ALPHA(cur) || ISA_DIGIT(cur) ||
|
|
|
05bba0 |
(*cur == '+') || (*cur == '-') || (*cur == '.')) cur++;
|
|
|
05bba0 |
if (uri != NULL) {
|
|
|
05bba0 |
- if (uri->scheme != NULL) g_free(uri->scheme);
|
|
|
05bba0 |
+ g_free(uri->scheme);
|
|
|
05bba0 |
uri->scheme = g_strndup(*str, cur - *str);
|
|
|
05bba0 |
}
|
|
|
05bba0 |
*str = cur;
|
|
|
05bba0 |
@@ -262,8 +262,7 @@ rfc3986_parse_fragment(URI *uri, const char **str)
|
|
|
05bba0 |
((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))
|
|
|
05bba0 |
NEXT(cur);
|
|
|
05bba0 |
if (uri != NULL) {
|
|
|
05bba0 |
- if (uri->fragment != NULL)
|
|
|
05bba0 |
- g_free(uri->fragment);
|
|
|
05bba0 |
+ g_free(uri->fragment);
|
|
|
05bba0 |
if (uri->cleanup & 2)
|
|
|
05bba0 |
uri->fragment = g_strndup(*str, cur - *str);
|
|
|
05bba0 |
else
|
|
|
05bba0 |
@@ -298,8 +297,7 @@ rfc3986_parse_query(URI *uri, const char **str)
|
|
|
05bba0 |
((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))
|
|
|
05bba0 |
NEXT(cur);
|
|
|
05bba0 |
if (uri != NULL) {
|
|
|
05bba0 |
- if (uri->query != NULL)
|
|
|
05bba0 |
- g_free (uri->query);
|
|
|
05bba0 |
+ g_free(uri->query);
|
|
|
05bba0 |
uri->query = g_strndup (*str, cur - *str);
|
|
|
05bba0 |
}
|
|
|
05bba0 |
*str = cur;
|
|
|
05bba0 |
@@ -360,7 +358,7 @@ rfc3986_parse_user_info(URI *uri, const char **str)
|
|
|
05bba0 |
NEXT(cur);
|
|
|
05bba0 |
if (*cur == '@') {
|
|
|
05bba0 |
if (uri != NULL) {
|
|
|
05bba0 |
- if (uri->user != NULL) g_free(uri->user);
|
|
|
05bba0 |
+ g_free(uri->user);
|
|
|
05bba0 |
if (uri->cleanup & 2)
|
|
|
05bba0 |
uri->user = g_strndup(*str, cur - *str);
|
|
|
05bba0 |
else
|
|
|
05bba0 |
@@ -473,9 +471,9 @@ not_ipv4:
|
|
|
05bba0 |
NEXT(cur);
|
|
|
05bba0 |
found:
|
|
|
05bba0 |
if (uri != NULL) {
|
|
|
05bba0 |
- if (uri->authority != NULL) g_free(uri->authority);
|
|
|
05bba0 |
+ g_free(uri->authority);
|
|
|
05bba0 |
uri->authority = NULL;
|
|
|
05bba0 |
- if (uri->server != NULL) g_free(uri->server);
|
|
|
05bba0 |
+ g_free(uri->server);
|
|
|
05bba0 |
if (cur != host) {
|
|
|
05bba0 |
if (uri->cleanup & 2)
|
|
|
05bba0 |
uri->server = g_strndup(host, cur - host);
|
|
|
05bba0 |
@@ -585,7 +583,7 @@ rfc3986_parse_path_ab_empty(URI *uri, const char **str)
|
|
|
05bba0 |
if (ret != 0) return(ret);
|
|
|
05bba0 |
}
|
|
|
05bba0 |
if (uri != NULL) {
|
|
|
05bba0 |
- if (uri->path != NULL) g_free(uri->path);
|
|
|
05bba0 |
+ g_free(uri->path);
|
|
|
05bba0 |
if (*str != cur) {
|
|
|
05bba0 |
if (uri->cleanup & 2)
|
|
|
05bba0 |
uri->path = g_strndup(*str, cur - *str);
|
|
|
05bba0 |
@@ -631,7 +629,7 @@ rfc3986_parse_path_absolute(URI *uri, const char **str)
|
|
|
05bba0 |
}
|
|
|
05bba0 |
}
|
|
|
05bba0 |
if (uri != NULL) {
|
|
|
05bba0 |
- if (uri->path != NULL) g_free(uri->path);
|
|
|
05bba0 |
+ g_free(uri->path);
|
|
|
05bba0 |
if (cur != *str) {
|
|
|
05bba0 |
if (uri->cleanup & 2)
|
|
|
05bba0 |
uri->path = g_strndup(*str, cur - *str);
|
|
|
05bba0 |
@@ -673,7 +671,7 @@ rfc3986_parse_path_rootless(URI *uri, const char **str)
|
|
|
05bba0 |
if (ret != 0) return(ret);
|
|
|
05bba0 |
}
|
|
|
05bba0 |
if (uri != NULL) {
|
|
|
05bba0 |
- if (uri->path != NULL) g_free(uri->path);
|
|
|
05bba0 |
+ g_free(uri->path);
|
|
|
05bba0 |
if (cur != *str) {
|
|
|
05bba0 |
if (uri->cleanup & 2)
|
|
|
05bba0 |
uri->path = g_strndup(*str, cur - *str);
|
|
|
05bba0 |
@@ -715,7 +713,7 @@ rfc3986_parse_path_no_scheme(URI *uri, const char **str)
|
|
|
05bba0 |
if (ret != 0) return(ret);
|
|
|
05bba0 |
}
|
|
|
05bba0 |
if (uri != NULL) {
|
|
|
05bba0 |
- if (uri->path != NULL) g_free(uri->path);
|
|
|
05bba0 |
+ g_free(uri->path);
|
|
|
05bba0 |
if (cur != *str) {
|
|
|
05bba0 |
if (uri->cleanup & 2)
|
|
|
05bba0 |
uri->path = g_strndup(*str, cur - *str);
|
|
|
05bba0 |
@@ -769,7 +767,7 @@ rfc3986_parse_hier_part(URI *uri, const char **str)
|
|
|
05bba0 |
} else {
|
|
|
05bba0 |
/* path-empty is effectively empty */
|
|
|
05bba0 |
if (uri != NULL) {
|
|
|
05bba0 |
- if (uri->path != NULL) g_free(uri->path);
|
|
|
05bba0 |
+ g_free(uri->path);
|
|
|
05bba0 |
uri->path = NULL;
|
|
|
05bba0 |
}
|
|
|
05bba0 |
}
|
|
|
05bba0 |
@@ -812,7 +810,7 @@ rfc3986_parse_relative_ref(URI *uri, const char *str) {
|
|
|
05bba0 |
} else {
|
|
|
05bba0 |
/* path-empty is effectively empty */
|
|
|
05bba0 |
if (uri != NULL) {
|
|
|
05bba0 |
- if (uri->path != NULL) g_free(uri->path);
|
|
|
05bba0 |
+ g_free(uri->path);
|
|
|
05bba0 |
uri->path = NULL;
|
|
|
05bba0 |
}
|
|
|
05bba0 |
}
|
|
|
05bba0 |
@@ -1285,21 +1283,21 @@ static void
|
|
|
05bba0 |
uri_clean(URI *uri) {
|
|
|
05bba0 |
if (uri == NULL) return;
|
|
|
05bba0 |
|
|
|
05bba0 |
- if (uri->scheme != NULL) g_free(uri->scheme);
|
|
|
05bba0 |
+ g_free(uri->scheme);
|
|
|
05bba0 |
uri->scheme = NULL;
|
|
|
05bba0 |
- if (uri->server != NULL) g_free(uri->server);
|
|
|
05bba0 |
+ g_free(uri->server);
|
|
|
05bba0 |
uri->server = NULL;
|
|
|
05bba0 |
- if (uri->user != NULL) g_free(uri->user);
|
|
|
05bba0 |
+ g_free(uri->user);
|
|
|
05bba0 |
uri->user = NULL;
|
|
|
05bba0 |
- if (uri->path != NULL) g_free(uri->path);
|
|
|
05bba0 |
+ g_free(uri->path);
|
|
|
05bba0 |
uri->path = NULL;
|
|
|
05bba0 |
- if (uri->fragment != NULL) g_free(uri->fragment);
|
|
|
05bba0 |
+ g_free(uri->fragment);
|
|
|
05bba0 |
uri->fragment = NULL;
|
|
|
05bba0 |
- if (uri->opaque != NULL) g_free(uri->opaque);
|
|
|
05bba0 |
+ g_free(uri->opaque);
|
|
|
05bba0 |
uri->opaque = NULL;
|
|
|
05bba0 |
- if (uri->authority != NULL) g_free(uri->authority);
|
|
|
05bba0 |
+ g_free(uri->authority);
|
|
|
05bba0 |
uri->authority = NULL;
|
|
|
05bba0 |
- if (uri->query != NULL) g_free(uri->query);
|
|
|
05bba0 |
+ g_free(uri->query);
|
|
|
05bba0 |
uri->query = NULL;
|
|
|
05bba0 |
}
|
|
|
05bba0 |
|
|
|
05bba0 |
@@ -1711,10 +1709,8 @@ uri_resolve(const char *uri, const char *base) {
|
|
|
05bba0 |
/*
|
|
|
05bba0 |
* the base fragment must be ignored
|
|
|
05bba0 |
*/
|
|
|
05bba0 |
- if (bas->fragment != NULL) {
|
|
|
05bba0 |
- g_free(bas->fragment);
|
|
|
05bba0 |
- bas->fragment = NULL;
|
|
|
05bba0 |
- }
|
|
|
05bba0 |
+ g_free(bas->fragment);
|
|
|
05bba0 |
+ bas->fragment = NULL;
|
|
|
05bba0 |
val = uri_to_string(bas);
|
|
|
05bba0 |
goto done;
|
|
|
05bba0 |
}
|
|
|
05bba0 |
--
|
|
|
05bba0 |
1.8.3.1
|
|
|
05bba0 |
|