vnc: Drop some superfluous conditionals
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 | 16 +++++----------- 2 files changed, 7 insertions(+), 15 deletions(-)
Signature · 1 line
1.9.3
PATCH 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
@@ -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
@@ -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
Re: [Qemu-devel] [PATCH 1/2] vnc: Drop superfluous conditionals around g_free()
Quoted 12 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>--- ui/vnc-tls.c | 6 ++---- ui/vnc.c | 12 ++++-------- 2 files changed, 6 insertions(+), 12 deletions(-)ui/vnc-tls.c +0
-0@@ -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
-4struct stat sb; -if (*cred) { -g_free (*cred); - *cred =NULL ; - } +g_free (*cred); + *cred =NULL ; *cred =g_malloc (strlen (certdir) +strlen (filename) +2 );
Makes a dead store to *cred more obvious.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 2/2 vnc: Drop superfluous conditionals around g_strdup()
In reply to Markus Armbruster--- ui/vnc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
ui/vnc.c +1 -3
@@ -3010,9 +3010,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
Re: [Qemu-devel] [PATCH 2/2] vnc: Drop superfluous conditionals around g_strdup()
Il 06/06/2014 18:36, Markus Armbruster ha scritto:
Quoted 10 lines
Signed-off-by Markus Armbruster <[email protected]>--- ui/vnc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)ui/vnc.c +0
-0
ui/vnc.c int vnc_display_password(DisplayState *ds, const char *password) · line 3013
Quoted 7 lines
ui/vnc.c +1
-3@@ -3010,9 +3010,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);
You have a dead store now. :)
Paolo
Quoted 3 lines
ui/vnc.c +0
-0return 0 ; }
Re: [Qemu-devel] [PATCH 2/2] vnc: Drop superfluous conditionals around g_strdup()
Quoted 12 lines · Paolo Bonzini
Il 06/06/2014 18:36, Markus Armbruster ha scritto:
Quoted 11 lines
Signed-off-by Markus Armbruster <[email protected]>--- ui/vnc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)ui/vnc.c +0
-0@@ -3010,9 +3010,7 @@ int vnc_display_password(DisplayState *ds, const char *password)
Quoted 8 lines
ui/vnc.c int vnc_display_password(DisplayState *ds, const char *password) · line 3013
Quoted 6 lines
ui/vnc.c +1
-3g_free (vs->password); vs->password =NULL ; -if (password) { - vs->password =g_strdup (password); - } + vs->password =g_strdup (password);You have a dead store now. :)
Noticed right after I sent %-}
Thanks!
Re: [Qemu-devel] [PATCH 2/2] vnc: Drop superfluous conditionals around g_strdup()
In reply to Markus ArmbrusterWrong patch; v2 sent.