[Spice-devel] [cacard 5/7] Favour g_assert over assert
Christophe Fergeau
cfergeau at redhat.com
Fri Aug 10 08:04:27 UTC 2018
Most of the code base is using g_assert, use it everywhere for
consistency.
Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
---
src/cac.c | 14 +++++++-------
src/card_7816.c | 4 ++--
src/vcard.c | 2 +-
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/cac.c b/src/cac.c
index 0e713cc..a614aff 100644
--- a/src/cac.c
+++ b/src/cac.c
@@ -264,7 +264,7 @@ cac_common_process_apdu(VCard *card, VCardAPDU *apdu, VCardResponse **response)
switch (apdu->a_ins) {
case CAC_GET_PROPERTIES:
/* 5.3.3.4: Get Properties APDU */
- assert(applet_private);
+ g_assert(applet_private);
if (apdu->a_p2 != 0x00) {
/* P2 needs to be 0x00 */
@@ -330,7 +330,7 @@ cac_common_process_apdu(VCard *card, VCardAPDU *apdu, VCardResponse **response)
break;
}
- assert(applet_private);
+ g_assert(applet_private);
/* handle file id setting */
if (apdu->a_Lc != 2) {
@@ -460,7 +460,7 @@ cac_applet_pki_reset(VCard *card, int channel)
VCardAppletPrivate *applet_private;
CACPKIAppletData *pki_applet;
applet_private = vcard_get_current_applet_private(card, channel);
- assert(applet_private);
+ g_assert(applet_private);
pki_applet = &(applet_private->u.pki_data);
g_free(pki_applet->sign_buffer);
@@ -474,7 +474,7 @@ cac_applet_passthrough_reset(VCard *card, int channel)
{
VCardAppletPrivate *applet_private;
applet_private = vcard_get_current_applet_private(card, channel);
- assert(applet_private);
+ g_assert(applet_private);
g_free(applet_private->tag_buffer);
applet_private->tag_buffer = NULL;
@@ -498,7 +498,7 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
VCardStatus ret = VCARD_FAIL;
applet_private = vcard_get_current_applet_private(card, apdu->a_channel);
- assert(applet_private);
+ g_assert(applet_private);
pki_applet = &(applet_private->u.pki_data);
switch (apdu->a_ins) {
@@ -574,7 +574,7 @@ cac_applet_aca_process_apdu(VCard *card, VCardAPDU *apdu,
int format;
applet_private = vcard_get_current_applet_private(card, apdu->a_channel);
- assert(applet_private);
+ g_assert(applet_private);
aca_applet = &(applet_private->u.aca_data);
switch (apdu->a_ins) {
@@ -713,7 +713,7 @@ cac_passthrough_container_process_apdu(VCard *card, VCardAPDU *apdu,
VCardAppletPrivate *applet_private;
applet_private = vcard_get_current_applet_private(card, apdu->a_channel);
- assert(applet_private);
+ g_assert(applet_private);
pt_applet = &(applet_private->u.pt_data);
switch (apdu->a_ins) {
diff --git a/src/card_7816.c b/src/card_7816.c
index 58bdda8..7be9469 100644
--- a/src/card_7816.c
+++ b/src/card_7816.c
@@ -754,7 +754,7 @@ vcard7816_vm_process_apdu(VCard *card, VCardAPDU *apdu,
}
/* response should have been set somewhere */
- assert(*response != NULL);
+ g_assert(*response != NULL);
return VCARD_DONE;
}
@@ -795,7 +795,7 @@ vcard_process_apdu(VCard *card, VCardAPDU *apdu, VCardResponse **response)
return vcard7816_vm_process_apdu(card, apdu, response);
case VCARD_DIRECT:
/* if we are type direct, then the applet should handle everything */
- assert(!"VCARD_DIRECT: applet failure");
+ g_assert(!"VCARD_DIRECT: applet failure");
break;
default:
g_warn_if_reached();
diff --git a/src/vcard.c b/src/vcard.c
index afa3bb8..aeae011 100644
--- a/src/vcard.c
+++ b/src/vcard.c
@@ -251,7 +251,7 @@ vcard_applet_get_aid(VCardApplet *applet, int *aid_len)
void
vcard_select_applet(VCard *card, int channel, VCardApplet *applet)
{
- assert(channel < MAX_CHANNEL);
+ g_assert(channel >= 0 && channel < MAX_CHANNEL);
card->current_applet[channel] = applet;
/* reset the applet */
--
2.17.1
More information about the Spice-devel
mailing list