From e3e8ee659c41eb3b510462eb2f9300a1b1f01708 Mon Sep 17 00:00:00 2001 From: frankmorgner Date: Tue, 24 Apr 2012 11:28:14 +0000 Subject: [PATCH] fixed clang compiler warnings git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@777 96b47cad-a561-4643-ad3b-153ac7d7599c --- npa/src/example.c | 2 +- npa/src/npa-tool.c | 34 +++++++++++++++++----------------- npa/src/npa.c | 10 +++++++--- npa/src/scutil.c | 4 ++-- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/npa/src/example.c b/npa/src/example.c index c5a2ac3..7560e24 100644 --- a/npa/src/example.c +++ b/npa/src/example.c @@ -75,7 +75,7 @@ main (int argc, char **argv) * You could set your PIN with pin=“123456”; or just leave it at NULL to be * asked for it. The same applies to the new PIN newpin. */ pace_input.pin_id = PACE_PIN; - pace_input.pin = pin; + pace_input.pin = (unsigned char *) pin; pace_input.pin_length = pin ? strlen(pin) : 0; r = EstablishPACEChannel(NULL, card, pace_input, &pace_output, diff --git a/npa/src/npa-tool.c b/npa/src/npa-tool.c index 6ee1e3c..9503ece 100644 --- a/npa/src/npa-tool.c +++ b/npa/src/npa-tool.c @@ -213,9 +213,9 @@ main (int argc, char **argv) exit(2); } if (strlen(can) > pace_input.pin_length) { - fprintf(stderr, "%s too big, only %d digits allowed.\n", + fprintf(stderr, "%s too big, only %u digits allowed.\n", npa_secret_name(pace_input.pin_id), - pace_input.pin_length); + (unsigned int) pace_input.pin_length); exit(2); } } @@ -230,9 +230,9 @@ main (int argc, char **argv) exit(2); } if (strlen(can) > pace_input.pin_length) { - fprintf(stderr, "%s too big, only %d digits allowed.\n", + fprintf(stderr, "%s too big, only %u digits allowed.\n", npa_secret_name(pace_input.pin_id), - pace_input.pin_length); + (unsigned int) pace_input.pin_length); exit(2); } } @@ -247,9 +247,9 @@ main (int argc, char **argv) exit(2); } if (strlen(puk) > pace_input.pin_length) { - fprintf(stderr, "%s too big, only %d digits allowed.\n", + fprintf(stderr, "%s too big, only %u digits allowed.\n", npa_secret_name(pace_input.pin_id), - pace_input.pin_length); + (unsigned int) pace_input.pin_length); exit(2); } } @@ -259,10 +259,10 @@ main (int argc, char **argv) exit(1); } - pace_input.pin = secretbuf; + pace_input.pin = (unsigned char *) secretbuf; do { - sprintf(secretbuf, "%0*llu", pace_input.pin_length, secret); + sprintf(secretbuf, "%0*llu", (unsigned int) pace_input.pin_length, secret); gettimeofday(&tv, NULL); printf("%u,%06u: Trying %s=%s\n", @@ -292,7 +292,7 @@ main (int argc, char **argv) if (cmdline.resume_flag) { pace_input.pin_id = PACE_CAN; if (can) { - pace_input.pin = can; + pace_input.pin = (unsigned char *) can; pace_input.pin_length = strlen(can); } else { pace_input.pin = NULL; @@ -306,7 +306,7 @@ main (int argc, char **argv) pace_input.pin_id = PACE_PIN; if (pin) { - pace_input.pin = pin; + pace_input.pin = (unsigned char *) pin; pace_input.pin_length = strlen(pin); } else { pace_input.pin = NULL; @@ -322,7 +322,7 @@ main (int argc, char **argv) if (cmdline.unblock_flag) { pace_input.pin_id = PACE_PUK; if (puk) { - pace_input.pin = puk; + pace_input.pin = (unsigned char *) puk; pace_input.pin_length = strlen(puk); } else { pace_input.pin = NULL; @@ -343,7 +343,7 @@ main (int argc, char **argv) if (cmdline.new_pin_given) { pace_input.pin_id = PACE_PIN; if (pin) { - pace_input.pin = pin; + pace_input.pin = (unsigned char *) pin; pace_input.pin_length = strlen(pin); } else { pace_input.pin = NULL; @@ -369,25 +369,25 @@ main (int argc, char **argv) if (cmdline.pin_given) { pace_input.pin_id = PACE_PIN; if (pin) { - pace_input.pin = pin; + pace_input.pin = (unsigned char *) pin; pace_input.pin_length = strlen(pin); } } else if (cmdline.can_given) { pace_input.pin_id = PACE_CAN; if (can) { - pace_input.pin = can; + pace_input.pin = (unsigned char *) can; pace_input.pin_length = strlen(can); } } else if (cmdline.mrz_given) { pace_input.pin_id = PACE_MRZ; if (mrz) { - pace_input.pin = mrz; + pace_input.pin = (unsigned char *) mrz; pace_input.pin_length = strlen(mrz); } } else if (cmdline.puk_given) { pace_input.pin_id = PACE_PUK; if (puk) { - pace_input.pin = puk; + pace_input.pin = (unsigned char *) puk; pace_input.pin_length = strlen(puk); } } else { @@ -401,7 +401,7 @@ main (int argc, char **argv) if (r < 0) goto err; printf("Established PACE channel with %s.\n", - npa_secret_name(pace_input.pin_id), cmdline.translate_arg); + npa_secret_name(pace_input.pin_id)); if (cmdline.translate_given) { FILE *input; diff --git a/npa/src/npa.c b/npa/src/npa.c index 382bf07..48f71c2 100644 --- a/npa/src/npa.c +++ b/npa/src/npa.c @@ -1465,8 +1465,10 @@ npa_sm_authenticate(sc_card_t *card, const struct sm_ctx *ctx, struct npa_sm_ctx *eacsmctx = ctx->priv_data; inbuf = BUF_MEM_create_init(data, datalen); - if (!inbuf) + if (!inbuf) { + r = SC_ERROR_OUT_OF_MEMORY; goto err; + } macbuf = EAC_authenticate(eacsmctx->ctx, eacsmctx->ssc, inbuf); if (!macbuf) { @@ -1514,8 +1516,10 @@ npa_sm_verify_authentication(sc_card_t *card, const struct sm_ctx *ctx, struct npa_sm_ctx *eacsmctx = ctx->priv_data; inbuf = BUF_MEM_create_init(macdata, macdatalen); - if (!inbuf) + if (!inbuf) { + r = SC_ERROR_OUT_OF_MEMORY; goto err; + } my_mac = EAC_authenticate(eacsmctx->ctx, eacsmctx->ssc, inbuf); if (!my_mac) { @@ -1624,7 +1628,7 @@ npa_sm_pre_transmit(sc_card_t *card, const struct sm_ctx *ctx, } switch (CVC_check_description(cvc_cert, - eacsmctx->certificate_description->data, + (unsigned char *) eacsmctx->certificate_description->data, eacsmctx->certificate_description->length)) { case 1: sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, diff --git a/npa/src/scutil.c b/npa/src/scutil.c index a09e2a7..6cf7a15 100644 --- a/npa/src/scutil.c +++ b/npa/src/scutil.c @@ -92,10 +92,10 @@ void _bin_log(sc_context_t *ctx, int type, const char *file, int line, buf[0] = 0; sc_do_log(ctx, type, file, line, func, "\n%s (%u byte%s):\n%s", - label, len, len==1?"":"s", buf); + label, (unsigned int) len, len==1?"":"s", buf); } else { fprintf(f, "%s (%u byte%s):\n%s\n", - label, len, len==1?"":"s", sc_dump_hex(data, len)); + label, (unsigned int) len, len==1?"":"s", sc_dump_hex(data, len)); } }