Skip to content

Commit fae0231

Browse files
olszomalmtrojnar
authored andcommitted
Squash compiler warnings on Windows (MSVC)
1 parent 64488de commit fae0231

File tree

7 files changed

+25
-24
lines changed

7 files changed

+25
-24
lines changed

src/eng_front.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static EVP_PKEY *load_privkey(ENGINE *engine, const char *s_key_id,
220220
return pkey;
221221
}
222222

223-
static int engine_ctrl(ENGINE *engine, int cmd, long i, void *p, void (*f) ())
223+
static int engine_ctrl(ENGINE *engine, int cmd, long i, void *p, void (*f) (void))
224224
{
225225
ENGINE_CTX *ctx;
226226

src/p11_attr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int pkcs11_getattr_var(PKCS11_CTX_private *ctx, CK_SESSION_HANDLE session,
4242

4343
templ.type = type;
4444
templ.pValue = value;
45-
templ.ulValueLen = *size;
45+
templ.ulValueLen = (CK_ULONG)*size;
4646
rv = CRYPTOKI_call(ctx, C_GetAttributeValue(session, object, &templ, 1));
4747
CRYPTOKI_checkerr(CKR_F_PKCS11_GETATTR_INT, rv);
4848
*size = templ.ulValueLen;
@@ -117,7 +117,7 @@ unsigned int pkcs11_addattr(PKCS11_TEMPLATE *tmpl, int type, void *data, size_t
117117
ap = &tmpl->attrs[tmpl->nattr++];
118118
ap->type = type;
119119
ap->pValue = data;
120-
ap->ulValueLen = size;
120+
ap->ulValueLen = (CK_ULONG)size;
121121
return n;
122122
}
123123

src/p11_ec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ static CK_ECDH1_DERIVE_PARAMS *pkcs11_ecdh_params_alloc(
558558
parms->pSharedData = NULL;
559559
parms->ulSharedDataLen = 0;
560560
parms->pPublicData = buf;
561-
parms->ulPublicDataLen = len;
561+
parms->ulPublicDataLen = (CK_ULONG)len;
562562
return parms;
563563
}
564564

src/p11_front.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ PKCS11_SLOT *PKCS11_find_next_token(PKCS11_CTX *ctx,
148148
return NULL;
149149

150150
if (current) {
151-
offset = current + 1 - slots;
151+
offset = (int)(current + 1 - slots);
152152
if (offset < 1 || (unsigned int)offset >= nslots)
153153
return NULL;
154154
} else {

src/p11_key.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ int pkcs11_authenticate(PKCS11_OBJECT_private *key, CK_SESSION_HANDLE session)
609609
/* Login with the PIN */
610610
rv = CRYPTOKI_call(ctx,
611611
C_Login(session, CKU_CONTEXT_SPECIFIC,
612-
(CK_UTF8CHAR *)pin, strlen(pin)));
612+
(CK_UTF8CHAR *)pin, (CK_ULONG)strlen(pin)));
613613
OPENSSL_cleanse(pin, MAX_PIN_LENGTH+1);
614614
OPENSSL_free(pin);
615615
return rv == CKR_USER_ALREADY_LOGGED_IN ? 0 : rv;

src/p11_pkey.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static int pkcs11_try_pkey_rsa_sign(EVP_PKEY_CTX *evp_pkey_ctx,
274274
EVP_PKEY *pkey;
275275
RSA *rsa;
276276
int rv = 0, padding;
277-
CK_ULONG size = *siglen;
277+
CK_ULONG size = (CK_ULONG)*siglen;
278278
PKCS11_OBJECT_private *key;
279279
PKCS11_SLOT_private *slot;
280280
PKCS11_CTX_private *ctx;
@@ -345,7 +345,7 @@ static int pkcs11_try_pkey_rsa_sign(EVP_PKEY_CTX *evp_pkey_ctx,
345345
rv = pkcs11_authenticate(key, session);
346346
if (rv == CKR_OK) {
347347
rv = CRYPTOKI_call(ctx,
348-
C_Sign(session, (CK_BYTE_PTR)tbs, tbslen, sig, &size));
348+
C_Sign(session, (CK_BYTE_PTR)tbs, (CK_ULONG)tbslen, sig, &size));
349349
if (rv != CKR_OK) {
350350
pkcs11_log(ctx, LOG_DEBUG, "%s:%d C_Sign rv=%d\n",
351351
__FILE__, __LINE__, rv);
@@ -378,7 +378,7 @@ static int pkcs11_try_pkey_rsa_decrypt(EVP_PKEY_CTX *evp_pkey_ctx,
378378
EVP_PKEY *pkey;
379379
RSA *rsa;
380380
int rv = 0, padding;
381-
CK_ULONG size = *outlen;
381+
CK_ULONG size = (CK_ULONG)*outlen;
382382
PKCS11_OBJECT_private *key;
383383
PKCS11_SLOT_private *slot;
384384
PKCS11_CTX_private *ctx;
@@ -450,7 +450,7 @@ static int pkcs11_try_pkey_rsa_decrypt(EVP_PKEY_CTX *evp_pkey_ctx,
450450
rv = pkcs11_authenticate(key, session);
451451
if (rv == CKR_OK) {
452452
rv = CRYPTOKI_call(ctx,
453-
C_Decrypt(session, (CK_BYTE_PTR)in, inlen, out, &size));
453+
C_Decrypt(session, (CK_BYTE_PTR)in, (CK_ULONG)inlen, out, &size));
454454
if (rv != CKR_OK) {
455455
pkcs11_log(ctx, LOG_DEBUG, "%s:%d C_Decrypt rv=%d\n",
456456
__FILE__, __LINE__, rv);
@@ -509,7 +509,7 @@ static int pkcs11_try_pkey_ec_sign(EVP_PKEY_CTX *evp_pkey_ctx,
509509
EVP_PKEY *pkey;
510510
EC_KEY *eckey;
511511
int rv = CKR_GENERAL_ERROR;
512-
CK_ULONG size = *siglen;
512+
CK_ULONG size = (CK_ULONG)*siglen;
513513
PKCS11_OBJECT_private *key;
514514
PKCS11_SLOT_private *slot;
515515
PKCS11_CTX_private *ctx;
@@ -575,7 +575,7 @@ static int pkcs11_try_pkey_ec_sign(EVP_PKEY_CTX *evp_pkey_ctx,
575575
rv = pkcs11_authenticate(key, session);
576576
if (rv == CKR_OK) {
577577
rv = CRYPTOKI_call(ctx,
578-
C_Sign(session, (CK_BYTE_PTR)tbs, tbslen, sig, &size));
578+
C_Sign(session, (CK_BYTE_PTR)tbs, (CK_ULONG)tbslen, sig, &size));
579579
if (rv != CKR_OK) {
580580
pkcs11_log(ctx, LOG_DEBUG, "%s:%d C_Sign rv=%d\n",
581581
__FILE__, __LINE__, rv);

src/util_uri.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static char *dump_expiry(const PKCS11_CERT *cert)
238238
int len = 0;
239239

240240
if (!cert || !cert->x509 || !(exp = X509_get0_notAfter(cert->x509)))
241-
return strdup("No expiry information available");
241+
return OPENSSL_strdup("No expiry information available");
242242

243243
if ((bio = BIO_new(BIO_s_mem())) == NULL)
244244
return NULL; /* Memory allocation failure */
@@ -414,7 +414,8 @@ static int parse_slot_id_string(UTIL_CTX *ctx,
414414
const char *slot_id, int *slot,
415415
char *id, size_t *id_len, char **label)
416416
{
417-
int n, i;
417+
int n;
418+
size_t i;
418419

419420
/* support for several formats */
420421
#define HEXDIGITS "01234567890ABCDEFabcdef"
@@ -613,7 +614,7 @@ static int read_from_file(UTIL_CTX *ctx,
613614
BIO_free(fp);
614615
return 0;
615616
}
616-
if (BIO_gets(fp, txt, *field_len + 1) > 0) {
617+
if (BIO_gets(fp, txt, (int)*field_len + 1) > 0) {
617618
memcpy(field, txt, *field_len);
618619
*field_len = strlen(txt);
619620
} else {
@@ -676,30 +677,30 @@ static int parse_pkcs11_uri(UTIL_CTX *ctx,
676677

677678
if (!strncmp(p, "model=", 6)) {
678679
p += 6;
679-
rv = parse_uri_attr(ctx, p, end - p, &tok->model);
680+
rv = parse_uri_attr(ctx, p, (int)(end - p), &tok->model);
680681
} else if (!strncmp(p, "manufacturer=", 13)) {
681682
p += 13;
682-
rv = parse_uri_attr(ctx, p, end - p, &tok->manufacturer);
683+
rv = parse_uri_attr(ctx, p, (int)(end - p), &tok->manufacturer);
683684
} else if (!strncmp(p, "token=", 6)) {
684685
p += 6;
685-
rv = parse_uri_attr(ctx, p, end - p, &tok->label);
686+
rv = parse_uri_attr(ctx, p, (int)(end - p), &tok->label);
686687
} else if (!strncmp(p, "serial=", 7)) {
687688
p += 7;
688-
rv = parse_uri_attr(ctx, p, end - p, &tok->serialnr);
689+
rv = parse_uri_attr(ctx, p, (int)(end - p), &tok->serialnr);
689690
} else if (!strncmp(p, "object=", 7)) {
690691
p += 7;
691-
rv = parse_uri_attr(ctx, p, end - p, &newlabel);
692+
rv = parse_uri_attr(ctx, p, (int)(end - p), &newlabel);
692693
} else if (!strncmp(p, "id=", 3)) {
693694
p += 3;
694-
rv = parse_uri_attr_len(ctx, p, end - p, id, id_len);
695+
rv = parse_uri_attr_len(ctx, p, (int)(end - p), id, id_len);
695696
id_set = 1;
696697
} else if (!strncmp(p, "pin-value=", 10)) {
697698
p += 10;
698-
rv = pin_set ? 0 : parse_uri_attr_len(ctx, p, end - p, pin, pin_len);
699+
rv = pin_set ? 0 : parse_uri_attr_len(ctx, p, (int)(end - p), pin, pin_len);
699700
pin_set = 1;
700701
} else if (!strncmp(p, "pin-source=", 11)) {
701702
p += 11;
702-
rv = pin_set ? 0 : parse_pin_source(ctx, p, end - p, pin, pin_len);
703+
rv = pin_set ? 0 : parse_pin_source(ctx, p, (int)(end - p), pin, pin_len);
703704
pin_set = 1;
704705
} else if (!strncmp(p, "type=", 5) || !strncmp(p, "object-type=", 12)) {
705706
p = strchr(p, '=') + 1;
@@ -840,7 +841,7 @@ static void *UTIL_CTX_try_load_object(UTIL_CTX *ctx,
840841
} else {
841842
strcpy(flags, "no token, ");
842843
}
843-
if ((m = strlen(flags)) != 0) {
844+
if ((m = (unsigned int)strlen(flags)) != 0) {
844845
flags[m - 2] = '\0';
845846
}
846847

0 commit comments

Comments
 (0)