Skip to contentSkip to conversation

vnc: Drop some superfluous conditionals

PATCH In review Markus Armbruster 3 participants 9 messages Jun 6, 2014 – Jun 12, 2014

lore
Share & tools
lore
#0 lore raw

v2 cover vnc: Drop some superfluous conditionals

Markus Armbruster (2):
vnc: Drop superfluous conditionals around g_free()
vnc: Drop superfluous conditionals around g_strdup()

 ui/vnc-tls.c |  6 ++----
 ui/vnc.c     | 15 ++++-----------
 2 files changed, 6 insertions(+), 15 deletions(-)
Signature · 1 line
1.9.3
#1 lore raw

PATCH v2 1/2 vnc: Drop superfluous conditionals around g_free()

---
 ui/vnc-tls.c |  6 ++----
 ui/vnc.c     | 12 ++++--------
 2 files changed, 6 insertions(+), 12 deletions(-)
ui/vnc-tls.c +2 -4
index 50275de..6392326 100644
@@ -443,10 +443,8 @@ static int vnc_set_x509_credential(VncDisplay *vd,
 {
     struct stat sb;
 
-    if (*cred) {
-        g_free(*cred);
-        *cred = NULL;
-    }
+    g_free(*cred);
+    *cred = NULL;
 
     *cred = g_malloc(strlen(certdir) + strlen(filename) + 2);
 
ui/vnc.c +4 -8
index 1684206..d771a2c 100644
@@ -2972,10 +2972,8 @@ static void vnc_display_close(DisplayState *ds)
 
     if (!vs)
         return;
-    if (vs->display) {
-        g_free(vs->display);
-        vs->display = NULL;
-    }
+    g_free(vs->display);
+    vs->display = NULL;
     if (vs->lsock != -1) {
         qemu_set_fd_handler2(vs->lsock, NULL, NULL, NULL, NULL);
         close(vs->lsock);
@@ -3010,10 +3008,8 @@ int vnc_display_password(DisplayState *ds, const char *password)
         return -EINVAL;
     }
 
-    if (vs->password) {
-        g_free(vs->password);
-        vs->password = NULL;
-    }
+    g_free(vs->password);
+    vs->password = NULL;
     if (password) {
         vs->password = g_strdup(password);
     }
Signature · 1 line
1.9.3
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] vnc: Drop superfluous conditionals around g_free()

Quoted 12 lines · Markus Armbruster
---
 ui/vnc-tls.c |  6 ++----
 ui/vnc.c     | 12 ++++--------
 2 files changed, 6 insertions(+), 12 deletions(-)
ui/vnc-tls.c +0 -0
index 50275de..6392326 100644
@@ -443,10 +443,8 @@ static int vnc_set_x509_credential(VncDisplay *vd,
 {

ui/vnc-tls.c static int vnc_set_x509_credential(VncDisplay *vd, · line 449

Quoted 10 lines
ui/vnc-tls.c +2 -4
     struct stat sb;
 
-    if (*cred) {
-        g_free(*cred);
-        *cred = NULL;
-    }
+    g_free(*cred);
+    *cred = NULL;
 
     *cred = g_malloc(strlen(certdir) + strlen(filename) + 2);

Still a dead store

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#3 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] vnc: Drop superfluous conditionals around g_free()

Quoted 22 lines · Eric Blake
Quoted 21 lines · Markus Armbruster
---
 ui/vnc-tls.c |  6 ++----
 ui/vnc.c     | 12 ++++--------
 2 files changed, 6 insertions(+), 12 deletions(-)
ui/vnc-tls.c +2 -4
index 50275de..6392326 100644
@@ -443,10 +443,8 @@ static int vnc_set_x509_credential(VncDisplay *vd,
 {
     struct stat sb;
 
-    if (*cred) {
-        g_free(*cred);
-        *cred = NULL;
-    }
+    g_free(*cred);
+    *cred = NULL;
 
Quoted 3 lines

ui/vnc-tls.c static int vnc_set_x509_credential(VncDisplay *vd, · line 449

Quoted 1 line
ui/vnc-tls.c +0 -0
     *cred = g_malloc(strlen(certdir) + strlen(filename) + 2);

Still a dead store

No deader than before my patch :)

Still, it's as good an opportunity to drop it as any. Gerd, would you like a v3?

#4 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] vnc: Drop superfluous conditionals around g_free()

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

+ *cred = NULL;

     *cred = g_malloc(strlen(certdir) + strlen(filename) + 2);

Still a dead store

No deader than before my patch :)

Still, it's as good an opportunity to drop it as any. Gerd, would you like a v3?

It's an improvement in any case, so I'm not going to reject it. Nevertheless a v3 would be nice though.

cheers,
Gerd

#5 lore raw

PATCH v2 2/2 vnc: Drop superfluous conditionals around g_strdup()

In reply to Markus Armbruster
---
 ui/vnc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
ui/vnc.c +1 -4
index d771a2c..6c9d4f3 100644
@@ -3009,10 +3009,7 @@ int vnc_display_password(DisplayState *ds, const char *password)
     }
 
     g_free(vs->password);
-    vs->password = NULL;
-    if (password) {
-        vs->password = g_strdup(password);
-    }
+    vs->password = g_strdup(password);
 
     return 0;
 }
Signature · 1 line
1.9.3
Reviewed-by on v2 2/2
#6 lore raw

Re: [Qemu-devel] [PATCH v2 2/2] vnc: Drop superfluous conditionals around g_strdup()

Quoted 4 lines · Markus Armbruster
---
 ui/vnc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#7 lore raw
In reply to Markus Armbruster
Quoted 8 lines · Markus Armbruster

Markus Armbruster (2):
vnc: Drop superfluous conditionals around g_free()
vnc: Drop superfluous conditionals around g_strdup()

 ui/vnc-tls.c |  6 ++----
 ui/vnc.c     | 15 ++++-----------
 2 files changed, 6 insertions(+), 15 deletions(-)

Picked them up.

thanks,
Gerd

#8 lore raw
Quoted 10 lines · Gerd Hoffmann
Quoted 8 lines · Markus Armbruster

Markus Armbruster (2):
vnc: Drop superfluous conditionals around g_free()
vnc: Drop superfluous conditionals around g_strdup()

 ui/vnc-tls.c |  6 ++----
 ui/vnc.c     | 15 ++++-----------
 2 files changed, 6 insertions(+), 15 deletions(-)

Picked them up.

Thanks!

I'll drop the dead store Eric noted in a followup patch, unless you squash it in (fine with me).