Skip to contentSkip to conversation

block/ssh: remove dead code

PATCH Applied Paolo Bonzini 4 participants 4 messages Sep 14, 2015 – Sep 16, 2015 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block/ssh: remove dead code

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

---
 block/ssh.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
block/ssh.c +1 -4
index 8d06739..d35b51f 100644
@@ -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);
     }
Signature · 1 line
2.5.0
#1 lore raw
Quoted 22 lines · Paolo Bonzini

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

---
 block/ssh.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
block/ssh.c +1 -1
index 8d06739..d35b51f 100644
@@ -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);

block/ssh.c static int parse_uri(const char *filename, QDict *options, Error **errp) · line 254

Quoted 9 lines
block/ssh.c +0 -3
@@ -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.

Signature · 5 lines
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/
Reviewed-by on v1 1/1
#2 lore raw
In reply to Paolo Bonzini
Quoted 35 lines · Paolo Bonzini

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

---
 block/ssh.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
block/ssh.c +1 -4
index 8d06739..d35b51f 100644
@@ -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);
     }
Signature · 1 line
2.5.0
#3 lore raw
In reply to Paolo Bonzini
Quoted 2 lines · Paolo Bonzini

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