From: Markus Armbruster <armbru@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-trivial@nongnu.org, alevy@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] libcacard: Drop superfluous conditionals around g_free()
Date: Fri, 06 Jun 2014 18:59:02 +0200 [thread overview]
Message-ID: <87fvjidlex.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <5391EEDA.7030207@redhat.com> (Paolo Bonzini's message of "Fri, 06 Jun 2014 18:39:54 +0200")
Paolo Bonzini <pbonzini@redhat.com> writes:
> Il 06/06/2014 18:32, Markus Armbruster ha scritto:
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>> libcacard/cac.c | 14 ++++----------
>> libcacard/card_7816.c | 12 +++---------
>> libcacard/vcard.c | 10 +++-------
>> libcacard/vcard_emul_nss.c | 4 +---
>> libcacard/vreader.c | 4 +---
>> 5 files changed, 12 insertions(+), 32 deletions(-)
>>
>> diff --git a/libcacard/cac.c b/libcacard/cac.c
>> index 0a0163d..ae8c378 100644
>> --- a/libcacard/cac.c
>> +++ b/libcacard/cac.c
>> @@ -100,10 +100,8 @@ cac_applet_pki_reset(VCard *card, int channel)
>> pki_applet = &(applet_private->u.pki_data);
>>
>> pki_applet->cert_buffer = NULL;
>> - if (pki_applet->sign_buffer) {
>> - g_free(pki_applet->sign_buffer);
>> - pki_applet->sign_buffer = NULL;
>> - }
>> + g_free(pki_applet->sign_buffer);
>> + pki_applet->sign_buffer = NULL;
>> pki_applet->cert_buffer_len = 0;
>> pki_applet->sign_buffer_len = 0;
>> return VCARD_DONE;
>> @@ -285,12 +283,8 @@ cac_delete_pki_applet_private(VCardAppletPrivate *applet_private)
>> return;
>> }
>> pki_applet_data = &(applet_private->u.pki_data);
>> - if (pki_applet_data->cert != NULL) {
>> - g_free(pki_applet_data->cert);
>> - }
>> - if (pki_applet_data->sign_buffer != NULL) {
>> - g_free(pki_applet_data->sign_buffer);
>> - }
>> + g_free(pki_applet_data->cert);
>> + g_free(pki_applet_data->sign_buffer);
>> if (pki_applet_data->key != NULL) {
>> vcard_emul_delete_key(pki_applet_data->key);
>> }
>> diff --git a/libcacard/card_7816.c b/libcacard/card_7816.c
>> index a54f880..814fa16 100644
>> --- a/libcacard/card_7816.c
>> +++ b/libcacard/card_7816.c
>> @@ -172,16 +172,12 @@ vcard_response_delete(VCardResponse *response)
>> switch (response->b_type) {
>> case VCARD_MALLOC:
>> /* everything was malloc'ed */
>> - if (response->b_data) {
>> - g_free(response->b_data);
>> - }
>> + g_free(response->b_data);
>> g_free(response);
>> break;
>> case VCARD_MALLOC_DATA:
>> /* only the data buffer was malloc'ed */
>> - if (response->b_data) {
>> - g_free(response->b_data);
>> - }
>> + g_free(response->b_data);
>> break;
>> case VCARD_MALLOC_STRUCT:
>> /* only the structure was malloc'ed */
>> @@ -358,9 +354,7 @@ vcard_apdu_delete(VCardAPDU *apdu)
>> if (apdu == NULL) {
>> return;
>> }
>> - if (apdu->a_data) {
>> - g_free(apdu->a_data);
>> - }
>> + g_free(apdu->a_data);
>> g_free(apdu);
>> }
>>
>> diff --git a/libcacard/vcard.c b/libcacard/vcard.c
>> index 6aaf085..bf342aa 100644
>> --- a/libcacard/vcard.c
>> +++ b/libcacard/vcard.c
>> @@ -51,9 +51,7 @@ vcard_buffer_response_delete(VCardBufferResponse *buffer_response)
>> if (buffer_response == NULL) {
>> return;
>> }
>> - if (buffer_response->buffer) {
>> - g_free(buffer_response->buffer);
>> - }
>> + g_free(buffer_response->buffer);
>> g_free(buffer_response);
>> }
>>
>> @@ -121,10 +119,8 @@ vcard_delete_applet(VCardApplet *applet)
>> applet->applet_private_free(applet->applet_private);
>> applet->applet_private = NULL;
>
> Dead store here...
>
>> }
>> - if (applet->aid) {
>> - g_free(applet->aid);
>> - applet->aid = NULL;
>> - }
>> + g_free(applet->aid);
>> + applet->aid = NULL;
>
> ... and here (didn't check if there are more out of context).
>
> As usual, no good deed goes unpunished!
Preexisting. I can try to clean them up in a follow-up patch. Okay?
WARNING: multiple messages have this Message-ID (diff)
From: Markus Armbruster <armbru@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-trivial@nongnu.org, alevy@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] libcacard: Drop superfluous conditionals around g_free()
Date: Fri, 06 Jun 2014 18:59:02 +0200 [thread overview]
Message-ID: <87fvjidlex.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <5391EEDA.7030207@redhat.com> (Paolo Bonzini's message of "Fri, 06 Jun 2014 18:39:54 +0200")
Paolo Bonzini <pbonzini@redhat.com> writes:
> Il 06/06/2014 18:32, Markus Armbruster ha scritto:
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>> libcacard/cac.c | 14 ++++----------
>> libcacard/card_7816.c | 12 +++---------
>> libcacard/vcard.c | 10 +++-------
>> libcacard/vcard_emul_nss.c | 4 +---
>> libcacard/vreader.c | 4 +---
>> 5 files changed, 12 insertions(+), 32 deletions(-)
>>
>> diff --git a/libcacard/cac.c b/libcacard/cac.c
>> index 0a0163d..ae8c378 100644
>> --- a/libcacard/cac.c
>> +++ b/libcacard/cac.c
>> @@ -100,10 +100,8 @@ cac_applet_pki_reset(VCard *card, int channel)
>> pki_applet = &(applet_private->u.pki_data);
>>
>> pki_applet->cert_buffer = NULL;
>> - if (pki_applet->sign_buffer) {
>> - g_free(pki_applet->sign_buffer);
>> - pki_applet->sign_buffer = NULL;
>> - }
>> + g_free(pki_applet->sign_buffer);
>> + pki_applet->sign_buffer = NULL;
>> pki_applet->cert_buffer_len = 0;
>> pki_applet->sign_buffer_len = 0;
>> return VCARD_DONE;
>> @@ -285,12 +283,8 @@ cac_delete_pki_applet_private(VCardAppletPrivate *applet_private)
>> return;
>> }
>> pki_applet_data = &(applet_private->u.pki_data);
>> - if (pki_applet_data->cert != NULL) {
>> - g_free(pki_applet_data->cert);
>> - }
>> - if (pki_applet_data->sign_buffer != NULL) {
>> - g_free(pki_applet_data->sign_buffer);
>> - }
>> + g_free(pki_applet_data->cert);
>> + g_free(pki_applet_data->sign_buffer);
>> if (pki_applet_data->key != NULL) {
>> vcard_emul_delete_key(pki_applet_data->key);
>> }
>> diff --git a/libcacard/card_7816.c b/libcacard/card_7816.c
>> index a54f880..814fa16 100644
>> --- a/libcacard/card_7816.c
>> +++ b/libcacard/card_7816.c
>> @@ -172,16 +172,12 @@ vcard_response_delete(VCardResponse *response)
>> switch (response->b_type) {
>> case VCARD_MALLOC:
>> /* everything was malloc'ed */
>> - if (response->b_data) {
>> - g_free(response->b_data);
>> - }
>> + g_free(response->b_data);
>> g_free(response);
>> break;
>> case VCARD_MALLOC_DATA:
>> /* only the data buffer was malloc'ed */
>> - if (response->b_data) {
>> - g_free(response->b_data);
>> - }
>> + g_free(response->b_data);
>> break;
>> case VCARD_MALLOC_STRUCT:
>> /* only the structure was malloc'ed */
>> @@ -358,9 +354,7 @@ vcard_apdu_delete(VCardAPDU *apdu)
>> if (apdu == NULL) {
>> return;
>> }
>> - if (apdu->a_data) {
>> - g_free(apdu->a_data);
>> - }
>> + g_free(apdu->a_data);
>> g_free(apdu);
>> }
>>
>> diff --git a/libcacard/vcard.c b/libcacard/vcard.c
>> index 6aaf085..bf342aa 100644
>> --- a/libcacard/vcard.c
>> +++ b/libcacard/vcard.c
>> @@ -51,9 +51,7 @@ vcard_buffer_response_delete(VCardBufferResponse *buffer_response)
>> if (buffer_response == NULL) {
>> return;
>> }
>> - if (buffer_response->buffer) {
>> - g_free(buffer_response->buffer);
>> - }
>> + g_free(buffer_response->buffer);
>> g_free(buffer_response);
>> }
>>
>> @@ -121,10 +119,8 @@ vcard_delete_applet(VCardApplet *applet)
>> applet->applet_private_free(applet->applet_private);
>> applet->applet_private = NULL;
>
> Dead store here...
>
>> }
>> - if (applet->aid) {
>> - g_free(applet->aid);
>> - applet->aid = NULL;
>> - }
>> + g_free(applet->aid);
>> + applet->aid = NULL;
>
> ... and here (didn't check if there are more out of context).
>
> As usual, no good deed goes unpunished!
Preexisting. I can try to clean them up in a follow-up patch. Okay?
next prev parent reply other threads:[~2014-06-06 16:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-06 16:32 [Qemu-trivial] [PATCH] libcacard: Drop superfluous conditionals around g_free() Markus Armbruster
2014-06-06 16:32 ` [Qemu-devel] " Markus Armbruster
2014-06-06 16:39 ` [Qemu-trivial] " Paolo Bonzini
2014-06-06 16:39 ` [Qemu-devel] " Paolo Bonzini
2014-06-06 16:59 ` Markus Armbruster [this message]
2014-06-06 16:59 ` Markus Armbruster
2014-06-06 17:20 ` [Qemu-trivial] " Paolo Bonzini
2014-06-06 17:20 ` [Qemu-devel] " Paolo Bonzini
2014-06-06 19:30 ` [Qemu-trivial] [PATCH 2/1] libcacard: Clean up dead stores before g_free() Markus Armbruster
2014-06-06 19:30 ` [Qemu-devel] " Markus Armbruster
2014-06-06 21:33 ` [Qemu-trivial] " Eric Blake
2014-06-06 21:33 ` Eric Blake
2014-06-08 13:45 ` [Qemu-trivial] [PATCH] libcacard: Drop superfluous conditionals around g_free() Michael Tokarev
2014-06-08 13:45 ` [Qemu-devel] " Michael Tokarev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fvjidlex.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=alevy@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.