QEMU-Devel Archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block/ssh: remove dead code
@ 2015-09-14 11:12 Paolo Bonzini
  2015-09-14 11:18 ` Richard W.M. Jones
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Paolo Bonzini @ 2015-09-14 11:12 UTC (permalink / raw
  To: qemu-devel; +Cc: qemu-trivial, jcody, rjones

The "err" label cannot be reached with qp != NULL.  Remove the free-ing
of qp and avoid future regressions by removing the initializer.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/ssh.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/block/ssh.c b/block/ssh.c
index 8d06739..d35b51f 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -193,7 +193,7 @@ sftp_error_report(BDRVSSHState *s, const char *fs, ...)
 static int parse_uri(const char *filename, QDict *options, Error **errp)
 {
     URI *uri = NULL;
-    QueryParams *qp = NULL;
+    QueryParams *qp;
     int i;
 
     uri = uri_parse(filename);
@@ -249,9 +249,6 @@ static int parse_uri(const char *filename, QDict *options, Error **errp)
     return 0;
 
  err:
-    if (qp) {
-      query_params_free(qp);
-    }
     if (uri) {
       uri_free(uri);
     }
-- 
2.5.0

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

* Re: [Qemu-devel] [PATCH] block/ssh: remove dead code
  2015-09-14 11:12 [Qemu-devel] [PATCH] block/ssh: remove dead code Paolo Bonzini
@ 2015-09-14 11:18 ` Richard W.M. Jones
  2015-09-15  2:31 ` Fam Zheng
  2015-09-16 10:29 ` Michael Tokarev
  2 siblings, 0 replies; 4+ messages in thread
From: Richard W.M. Jones @ 2015-09-14 11:18 UTC (permalink / raw
  To: Paolo Bonzini; +Cc: qemu-trivial, jcody, qemu-devel

On Mon, Sep 14, 2015 at 01:12:34PM +0200, Paolo Bonzini wrote:
> The "err" label cannot be reached with qp != NULL.  Remove the free-ing
> of qp and avoid future regressions by removing the initializer.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  block/ssh.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/block/ssh.c b/block/ssh.c
> index 8d06739..d35b51f 100644
> --- a/block/ssh.c
> +++ b/block/ssh.c
> @@ -193,7 +193,7 @@ sftp_error_report(BDRVSSHState *s, const char *fs, ...)
>  static int parse_uri(const char *filename, QDict *options, Error **errp)
>  {
>      URI *uri = NULL;
> -    QueryParams *qp = NULL;
> +    QueryParams *qp;
>      int i;
>  
>      uri = uri_parse(filename);
> @@ -249,9 +249,6 @@ static int parse_uri(const char *filename, QDict *options, Error **errp)
>      return 0;
>  
>   err:
> -    if (qp) {
> -      query_params_free(qp);
> -    }
>      if (uri) {
>        uri_free(uri);
>      }

The patch looks correct to me, so:

ACK

However (in libguestfs) we would generally leave such code around to
make it more future proof against rearrangements of the code which
could cause a memory leak.  But then again, libguestfs (following
systemd practice) uses __attribute__((cleanup)) extensively ...

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/

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

* Re: [Qemu-devel] [PATCH] block/ssh: remove dead code
  2015-09-14 11:12 [Qemu-devel] [PATCH] block/ssh: remove dead code Paolo Bonzini
  2015-09-14 11:18 ` Richard W.M. Jones
@ 2015-09-15  2:31 ` Fam Zheng
  2015-09-16 10:29 ` Michael Tokarev
  2 siblings, 0 replies; 4+ messages in thread
From: Fam Zheng @ 2015-09-15  2:31 UTC (permalink / raw
  To: Paolo Bonzini; +Cc: qemu-trivial, jcody, qemu-devel, rjones

On Mon, 09/14 13:12, Paolo Bonzini wrote:
> The "err" label cannot be reached with qp != NULL.  Remove the free-ing
> of qp and avoid future regressions by removing the initializer.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  block/ssh.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/block/ssh.c b/block/ssh.c
> index 8d06739..d35b51f 100644
> --- a/block/ssh.c
> +++ b/block/ssh.c
> @@ -193,7 +193,7 @@ sftp_error_report(BDRVSSHState *s, const char *fs, ...)
>  static int parse_uri(const char *filename, QDict *options, Error **errp)
>  {
>      URI *uri = NULL;
> -    QueryParams *qp = NULL;
> +    QueryParams *qp;
>      int i;
>  
>      uri = uri_parse(filename);
> @@ -249,9 +249,6 @@ static int parse_uri(const char *filename, QDict *options, Error **errp)
>      return 0;
>  
>   err:
> -    if (qp) {
> -      query_params_free(qp);
> -    }
>      if (uri) {
>        uri_free(uri);
>      }
> -- 
> 2.5.0
> 
> 

Reviewed-by: Fam Zheng <famz@redhat.com>

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

* Re: [Qemu-devel] [PATCH] block/ssh: remove dead code
  2015-09-14 11:12 [Qemu-devel] [PATCH] block/ssh: remove dead code Paolo Bonzini
  2015-09-14 11:18 ` Richard W.M. Jones
  2015-09-15  2:31 ` Fam Zheng
@ 2015-09-16 10:29 ` Michael Tokarev
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Tokarev @ 2015-09-16 10:29 UTC (permalink / raw
  To: Paolo Bonzini, qemu-devel; +Cc: qemu-trivial, jcody, rjones

14.09.2015 14:12, Paolo Bonzini wrote:
> The "err" label cannot be reached with qp != NULL.  Remove the free-ing
> of qp and avoid future regressions by removing the initializer.

Applied to -trivial, thank you!

/mjt

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

end of thread, other threads:[~2015-09-16 10:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-14 11:12 [Qemu-devel] [PATCH] block/ssh: remove dead code Paolo Bonzini
2015-09-14 11:18 ` Richard W.M. Jones
2015-09-15  2:31 ` Fam Zheng
2015-09-16 10:29 ` Michael Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).