All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] util/uri: do not check argument of uri_free()
@ 2021-06-28 21:55 Heinrich Schuchardt
  2021-06-29  4:34 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2021-06-28 21:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Heinrich Schuchardt, Peter Lieven,
	Richard W . M . Jones, Max Reitz

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>
---
 block/nfs.c |  4 +---
 block/ssh.c |  4 +---
 capstone    |  2 +-
 util/uri.c  | 22 ++++++----------------
 4 files changed, 9 insertions(+), 23 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 b51a031620..9f88480ae8 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/capstone b/capstone
index f8b1b83301..31254f17e3 160000
--- a/capstone
+++ b/capstone
@@ -1 +1 @@
-Subproject commit f8b1b833015a4ae47110ed068e0deb7106ced66d
+Subproject commit 31254f17e3c6025f3465d1c974a8c96e338ddbe0
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.30.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] util/uri: do not check argument of uri_free()
  2021-06-28 21:55 [PATCH 1/1] util/uri: do not check argument of uri_free() Heinrich Schuchardt
@ 2021-06-29  4:34 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-29  4:34 UTC (permalink / raw)
  To: Heinrich Schuchardt, qemu-devel
  Cc: Kevin Wolf, Peter Lieven, Richard W . M . Jones, qemu-block, Max Reitz

On 6/28/21 11:55 PM, Heinrich Schuchardt wrote:
> 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>
> ---
>  block/nfs.c |  4 +---
>  block/ssh.c |  4 +---
>  capstone    |  2 +-
>  util/uri.c  | 22 ++++++----------------
>  4 files changed, 9 insertions(+), 23 deletions(-)

Looks good ...

> diff --git a/capstone b/capstone
> index f8b1b83301..31254f17e3 160000
> --- a/capstone
> +++ b/capstone
> @@ -1 +1 @@
> -Subproject commit f8b1b833015a4ae47110ed068e0deb7106ced66d
> +Subproject commit 31254f17e3c6025f3465d1c974a8c96e338ddbe0

... except this change.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-29  4:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 21:55 [PATCH 1/1] util/uri: do not check argument of uri_free() Heinrich Schuchardt
2021-06-29  4:34 ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.