Use do {...} while(0) construction for SC_TEST_RET, SC_FUNC_RETURN and SC_FUNC_CALLED defines

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3050 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
vtarasov 2006-11-06 11:15:09 +00:00
parent 7da8984462
commit 2d4bd463b0
5 changed files with 13 additions and 13 deletions

View File

@ -742,9 +742,9 @@ do_compute_signature(sc_card_t *card, const u8 *data, size_t datalen,
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
SC_FUNC_RETURN(card->ctx, 4, apdu.resplen)
SC_FUNC_RETURN(card->ctx, 4, apdu.resplen);
else
SC_FUNC_RETURN(card->ctx, 4, sc_check_sw(card, apdu.sw1, apdu.sw2))
SC_FUNC_RETURN(card->ctx, 4, sc_check_sw(card, apdu.sw1, apdu.sw2));
}
static int

View File

@ -1205,7 +1205,7 @@ static int piv_find_obj_by_containerid(sc_card_t *card, const u8 * str)
{
int i;
SC_FUNC_CALLED(card->ctx,4)
SC_FUNC_CALLED(card->ctx,4);
sc_debug(card->ctx, "str=0x%02X%02X\n", str[0], str[1]);
for (i = 0; piv_objects[i].enumtag; i++) {
@ -1233,7 +1233,7 @@ static int piv_select_file(sc_card_t *card, const sc_path_t *in_path,
int pathlen;
sc_file_t *file = NULL;
SC_FUNC_CALLED(card->ctx,1)
SC_FUNC_CALLED(card->ctx,1);
path = in_path->value;
pathlen = in_path->len;

View File

@ -818,9 +818,9 @@ static int iso7816_decipher(sc_card_t *card,
free(sbuf);
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
SC_FUNC_RETURN(card->ctx, 2, apdu.resplen)
SC_FUNC_RETURN(card->ctx, 2, apdu.resplen);
else
SC_FUNC_RETURN(card->ctx, 2, sc_check_sw(card, apdu.sw1, apdu.sw2))
SC_FUNC_RETURN(card->ctx, 2, sc_check_sw(card, apdu.sw1, apdu.sw2));
}
static int iso7816_build_pin_apdu(sc_card_t *card, sc_apdu_t *apdu,

View File

@ -55,12 +55,12 @@ void sc_do_log_va(struct sc_context *ctx, int type, const char *file, int line,
void sc_hex_dump(struct sc_context *ctx, const u8 * buf, size_t len, char *out, size_t outlen);
#define SC_FUNC_CALLED(ctx, level) { \
#define SC_FUNC_CALLED(ctx, level) do { \
if (ctx->debug >= level) \
sc_do_log(ctx, SC_LOG_TYPE_DEBUG, __FILE__, __LINE__, __FUNCTION__, "called\n"); \
}
} while (0)
#define SC_FUNC_RETURN(ctx, level, r) { \
#define SC_FUNC_RETURN(ctx, level, r) do { \
int _ret = r; \
if (_ret < 0 && !ctx->suppress_errors) { \
sc_do_log(ctx, SC_LOG_TYPE_ERROR, __FILE__, __LINE__, __FUNCTION__, "returning with: %s\n", sc_strerror(_ret)); \
@ -68,15 +68,15 @@ void sc_hex_dump(struct sc_context *ctx, const u8 * buf, size_t len, char *out,
sc_do_log(ctx, SC_LOG_TYPE_DEBUG, __FILE__, __LINE__, __FUNCTION__, "returning with: %d\n", _ret); \
} \
return _ret; \
}
} while(0)
#define SC_TEST_RET(ctx, r, text) { \
#define SC_TEST_RET(ctx, r, text) do { \
int _ret = (r); \
if (_ret < 0) { \
sc_do_log(ctx, SC_LOG_TYPE_ERROR, __FILE__, __LINE__, __FUNCTION__, "%s: %s\n", (text), sc_strerror(_ret)); \
return _ret; \
} \
}
} while(0)
#define sc_perror(ctx, errno, str) { \
sc_do_log(ctx, SC_LOG_TYPE_ERROR, __FILE__, __LINE__, __FUNCTION__, "%s: %s\n", str, sc_strerror(errno)); \

View File

@ -849,7 +849,7 @@ int msc_import_key(sc_card_t *card,
|| (data->dq1Length == 0 || !data->dq1Value))
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_INVALID_ARGUMENTS);
} else {
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_INVALID_ARGUMENTS)
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_INVALID_ARGUMENTS);
}
if(data->keyType == 0x02) {