On Tue, Jun 29, 2021 at 08:36:02AM +0200, 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 <[email protected]> > --- > v2: > remove unrelated subproject change
Very straightforward change, so: Reviewed-by: Richard W.M. Jones <[email protected]> > 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 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/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 -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
