C++ warning fixes (assuan excluded)

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@863 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
aet 2003-01-14 19:55:45 +00:00
parent a89e65bfb3
commit b1eff66867
9 changed files with 35 additions and 34 deletions

View File

@ -128,7 +128,7 @@ static int flex_init(struct sc_card *card)
{
struct flex_private_data *data;
if (!(data = malloc(sizeof(struct flex_private_data))))
if (!(data = (struct flex_private_data *) malloc(sizeof(struct flex_private_data))))
return SC_ERROR_OUT_OF_MEMORY;
data->card_type = flex_identify_card(card);

View File

@ -49,7 +49,7 @@ ctbcs_build_input_apdu(sc_apdu_t *apdu, int echo, const char *prompt,
if (prompt && *prompt) {
apdu->cse = SC_APDU_CASE_4_SHORT;
apdu->data = prompt;
apdu->data = (u8 *) prompt;
apdu->lc = apdu->datalen = strlen(prompt);
}

View File

@ -304,6 +304,21 @@ struct sc_reader {
#define SC_PIN_ENCODING_ASCII 0
#define SC_PIN_ENCODING_BCD 1
struct sc_pin_cmd_pin {
const char *prompt; /* Prompt to display */
const u8 *data; /* PIN, if given by the appliction */
int len; /* set to -1 to get pin from pin pad */
size_t min_length; /* min/max length of PIN */
size_t max_length;
int encoding; /* ASCII-numeric, BCD, etc */
size_t pad_length; /* filled in by the card driver */
u8 pad_char;
size_t offset; /* offset relative to the APDU's
* argument buffer, where the
* PIN should go */
};
struct sc_pin_cmd_data {
unsigned int cmd;
@ -312,21 +327,7 @@ struct sc_pin_cmd_data {
unsigned int pin_type; /* usually SC_AC_CHV */
int pin_reference;
struct sc_pin_cmd_pin {
const char *prompt; /* Prompt to display */
const u8 *data; /* PIN, if given by the appliction */
int len; /* set to -1 to get pin from pin pad */
size_t min_length; /* min/max length of PIN */
size_t max_length;
int encoding; /* ASCII-numeric, BCD, etc */
size_t pad_length; /* filled in by the card driver */
u8 pad_char;
size_t offset; /* offset relative to the APDU's
* argument buffer, where the
* PIN should go */
} pin1, pin2;
struct sc_pin_cmd_pin pin1, pin2;
struct sc_apdu *apdu; /* APDU of the PIN command */
};

View File

@ -47,7 +47,7 @@ asn1_decode_data_object(struct sc_context *ctx, u8 **dataobj, size_t *datalen,
int r;
int data_len;
data=malloc(buflen+64);
data = (u8 *) malloc(buflen+64);
if (data == NULL) {
return SC_ERROR_OUT_OF_MEMORY;
}
@ -59,7 +59,7 @@ asn1_decode_data_object(struct sc_context *ctx, u8 **dataobj, size_t *datalen,
free(data);
return r;
}
*dataobj = malloc(*datalen);
*dataobj = (u8 *) malloc(*datalen);
memcpy(*dataobj, data, *datalen);
free(data);
return 0;

View File

@ -961,7 +961,7 @@ int sc_pkcs15_parse_df(struct sc_pkcs15_card *p15card,
}
obj_len = p - oldp;
obj->der.value = malloc(obj_len);
obj->der.value = (u8 *) malloc(obj_len);
if (obj->der.value == NULL) {
r = SC_ERROR_OUT_OF_MEMORY;
goto ret;

View File

@ -74,7 +74,7 @@ sc_pkcs11_openssl_md_init(sc_pkcs11_operation_t *op)
if (!op || !(mt = op->type) || !(md = (EVP_MD *) mt->mech_data))
return CKR_ARGUMENTS_BAD;
if (!(md_ctx = calloc(1, sizeof(*md_ctx))))
if (!(md_ctx = (EVP_MD_CTX *) calloc(1, sizeof(*md_ctx))))
return CKR_HOST_MEMORY;
EVP_DigestInit(md_ctx, md);
op->priv_data = md_ctx;

View File

@ -30,7 +30,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Too long input file.\n");
return 1;
}
len = sc_base64_decode(buf, outbuf, sizeof(outbuf));
len = sc_base64_decode((const char *) buf, outbuf, sizeof(outbuf));
if (len < 0) {
fprintf(stderr, "Base64 decoding failed: %s\n", sc_strerror(len));
return 1;

View File

@ -300,7 +300,7 @@ main(int argc, char * const argv[])
pin = opt_pin;
if (!pin || !*pin)
return 1;
rv = p11->C_Login(session, CKU_USER, pin, strlen(pin));
rv = p11->C_Login(session, CKU_USER, (CK_UTF8CHAR *) pin, strlen(pin));
if (rv != CKR_OK)
p11_fatal("C_Login", rv);
}
@ -804,12 +804,12 @@ test_digest(CK_SLOT_ID slot)
CKM_MD5,
CKM_SHA_1,
CKM_RIPEMD160,
-1
0xffffff
};
unsigned char *digests[] = {
"\x7a\x08\xb0\x7e\x84\x64\x17\x03\xe5\xf2\xc8\x36\xaa\x59\xa1\x70",
"\x29\xb0\xe7\x87\x82\x71\x64\x5f\xff\xb7\xee\xc7\xdb\x4a\x74\x73\xa1\xc0\x0b\xc1",
"\xda\x79\xa5\x8f\xb8\x83\x3d\x61\xf6\x32\x16\x17\xe3\xfd\xf0\x56\x26\x5f\xb7\xcd"
(unsigned char *) "\x7a\x08\xb0\x7e\x84\x64\x17\x03\xe5\xf2\xc8\x36\xaa\x59\xa1\x70",
(unsigned char *) "\x29\xb0\xe7\x87\x82\x71\x64\x5f\xff\xb7\xee\xc7\xdb\x4a\x74\x73\xa1\xc0\x0b\xc1",
(unsigned char *) "\xda\x79\xa5\x8f\xb8\x83\x3d\x61\xf6\x32\x16\x17\xe3\xfd\xf0\x56\x26\x5f\xb7\xcd"
};
CK_ULONG digestLens[] = {
16,
@ -891,9 +891,9 @@ test_digest(CK_SLOT_ID slot)
data[10 * i + j] = (unsigned char) (0x30 + j);
i = -1;
i = 0xffffff;
while (1) {
if (mechTypes[++i] == -1)
if (mechTypes[++i] == 0xffffff)
break;
ck_mech.mechanism = mechTypes[i];
@ -992,7 +992,7 @@ test_signature(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
CKM_SHA1_RSA_PKCS,
CKM_MD5_RSA_PKCS,
CKM_RIPEMD160_RSA_PKCS,
-1
0xffffff
};
unsigned char *datas[] = {
/* PCKS1_wrap(SHA1_encode(SHA-1(verifyData))),
@ -1001,7 +1001,7 @@ test_signature(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
NULL,
/* SHA1_encode(SHA-1(verifyData)) */
"\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14\x29\xb0\xe7\x87\x82\x71\x64\x5f\xff\xb7\xee\xc7\xdb\x4a\x74\x73\xa1\xc0\x0b\xc1",
(unsigned char *) "\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14\x29\xb0\xe7\x87\x82\x71\x64\x5f\xff\xb7\xee\xc7\xdb\x4a\x74\x73\xa1\xc0\x0b\xc1",
verifyData,
verifyData,
@ -1153,9 +1153,9 @@ test_signature(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
datas[0] = data;
dataLens[0] = dataLen;
i = -1;
i = 0xffffff;
while (1) {
if (mechTypes[++i] == -1)
if (mechTypes[++i] == 0xffffff)
break;
ck_mech.mechanism = mechTypes[i];

View File

@ -1157,7 +1157,7 @@ do_read_data_object(const char *name, u8 **out, size_t *outlen)
size_t filesize = determine_filesize(name);
int c;
*out = malloc(filesize);
*out = (u8 *) malloc(filesize);
if (*out == NULL) {
return SC_ERROR_OUT_OF_MEMORY;
}