qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] vnc: Drop some superfluous conditionals
@ 2014-06-06 16:36 Markus Armbruster
  2014-06-06 16:36 ` [Qemu-devel] [PATCH 1/2] vnc: Drop superfluous conditionals around g_free() Markus Armbruster
  2014-06-06 16:36 ` [Qemu-devel] [PATCH 2/2] vnc: Drop superfluous conditionals around g_strdup() Markus Armbruster
  0 siblings, 2 replies; 7+ messages in thread
From: Markus Armbruster @ 2014-06-06 16:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: kraxel

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(-)

-- 
1.9.3

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

* [Qemu-devel] [PATCH 1/2] vnc: Drop superfluous conditionals around g_free()
  2014-06-06 16:36 [Qemu-devel] [PATCH 0/2] vnc: Drop some superfluous conditionals Markus Armbruster
@ 2014-06-06 16:36 ` Markus Armbruster
  2014-06-06 16:45   ` Eric Blake
  2014-06-06 16:36 ` [Qemu-devel] [PATCH 2/2] vnc: Drop superfluous conditionals around g_strdup() Markus Armbruster
  1 sibling, 1 reply; 7+ messages in thread
From: Markus Armbruster @ 2014-06-06 16:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: kraxel

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 ui/vnc-tls.c |  6 ++----
 ui/vnc.c     | 12 ++++--------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/ui/vnc-tls.c b/ui/vnc-tls.c
index 50275de..6392326 100644
--- a/ui/vnc-tls.c
+++ b/ui/vnc-tls.c
@@ -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);
 
diff --git a/ui/vnc.c b/ui/vnc.c
index 1684206..d771a2c 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -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);
     }
-- 
1.9.3

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

* [Qemu-devel] [PATCH 2/2] vnc: Drop superfluous conditionals around g_strdup()
  2014-06-06 16:36 [Qemu-devel] [PATCH 0/2] vnc: Drop some superfluous conditionals Markus Armbruster
  2014-06-06 16:36 ` [Qemu-devel] [PATCH 1/2] vnc: Drop superfluous conditionals around g_free() Markus Armbruster
@ 2014-06-06 16:36 ` Markus Armbruster
  2014-06-06 16:38   ` Paolo Bonzini
  2014-06-06 16:48   ` Markus Armbruster
  1 sibling, 2 replies; 7+ messages in thread
From: Markus Armbruster @ 2014-06-06 16:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: kraxel

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 ui/vnc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index d771a2c..0853ded 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -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;
 }
-- 
1.9.3

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

* Re: [Qemu-devel] [PATCH 2/2] vnc: Drop superfluous conditionals around g_strdup()
  2014-06-06 16:36 ` [Qemu-devel] [PATCH 2/2] vnc: Drop superfluous conditionals around g_strdup() Markus Armbruster
@ 2014-06-06 16:38   ` Paolo Bonzini
  2014-06-06 16:50     ` Markus Armbruster
  2014-06-06 16:48   ` Markus Armbruster
  1 sibling, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2014-06-06 16:38 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kraxel

Il 06/06/2014 18:36, Markus Armbruster ha scritto:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  ui/vnc.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/ui/vnc.c b/ui/vnc.c
> index d771a2c..0853ded 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -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

>      return 0;
>  }
>

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

* Re: [Qemu-devel] [PATCH 1/2] vnc: Drop superfluous conditionals around g_free()
  2014-06-06 16:36 ` [Qemu-devel] [PATCH 1/2] vnc: Drop superfluous conditionals around g_free() Markus Armbruster
@ 2014-06-06 16:45   ` Eric Blake
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2014-06-06 16:45 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kraxel

[-- Attachment #1: Type: text/plain, Size: 822 bytes --]

On 06/06/2014 10:36 AM, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  ui/vnc-tls.c |  6 ++----
>  ui/vnc.c     | 12 ++++--------
>  2 files changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/ui/vnc-tls.c b/ui/vnc-tls.c
> index 50275de..6392326 100644
> --- a/ui/vnc-tls.c
> +++ b/ui/vnc-tls.c
> @@ -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);

Makes a dead store to *cred more obvious.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 2/2] vnc: Drop superfluous conditionals around g_strdup()
  2014-06-06 16:36 ` [Qemu-devel] [PATCH 2/2] vnc: Drop superfluous conditionals around g_strdup() Markus Armbruster
  2014-06-06 16:38   ` Paolo Bonzini
@ 2014-06-06 16:48   ` Markus Armbruster
  1 sibling, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2014-06-06 16:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: kraxel

Wrong patch; v2 sent.

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

* Re: [Qemu-devel] [PATCH 2/2] vnc: Drop superfluous conditionals around g_strdup()
  2014-06-06 16:38   ` Paolo Bonzini
@ 2014-06-06 16:50     ` Markus Armbruster
  0 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2014-06-06 16:50 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, kraxel

Paolo Bonzini <pbonzini@redhat.com> writes:

> Il 06/06/2014 18:36, Markus Armbruster ha scritto:
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  ui/vnc.c | 4 +---
>>  1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/ui/vnc.c b/ui/vnc.c
>> index d771a2c..0853ded 100644
>> --- a/ui/vnc.c
>> +++ b/ui/vnc.c
>> @@ -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. :)

Noticed right after I sent %-}

Thanks!

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

end of thread, other threads:[~2014-06-06 16:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-06 16:36 [Qemu-devel] [PATCH 0/2] vnc: Drop some superfluous conditionals Markus Armbruster
2014-06-06 16:36 ` [Qemu-devel] [PATCH 1/2] vnc: Drop superfluous conditionals around g_free() Markus Armbruster
2014-06-06 16:45   ` Eric Blake
2014-06-06 16:36 ` [Qemu-devel] [PATCH 2/2] vnc: Drop superfluous conditionals around g_strdup() Markus Armbruster
2014-06-06 16:38   ` Paolo Bonzini
2014-06-06 16:50     ` Markus Armbruster
2014-06-06 16:48   ` Markus Armbruster

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 NNTP newsgroup(s).