Skip to content

Commit b18d011

Browse files
authored
Merge pull request #24 from dgarske/portability
Portability fixes
2 parents ffb7f06 + 91a8b5f commit b18d011

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

tests/pkcs11mtt.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#include <stdio.h>
3434

35-
#ifdef _POSIX_THREADS
35+
#if defined(_POSIX_THREADS) && !defined(SINGLE_THREADED)
3636
#include <wolfssl/wolfcrypt/misc.h>
3737
#include <wolfpkcs11/pkcs11.h>
3838

@@ -49,14 +49,14 @@ static void* dlib;
4949
#endif
5050
static CK_FUNCTION_LIST* funcList;
5151
static int slot;
52-
const char* tokenName = "wolfpkcs11";
52+
static const char* tokenName = "wolfpkcs11";
5353

5454
/* FIPS requires pin to be at least 14 characters, since it is used for
5555
* the HMAC key */
5656
static byte* soPin = (byte*)"password123456";
5757
static int soPinLen = 14;
58-
byte* userPin = (byte*)"wolfpkcs11-test";
59-
int userPinLen;
58+
static byte* userPin = (byte*)"wolfpkcs11-test";
59+
static int userPinLen;
6060

6161
#if !defined(NO_RSA) || defined(HAVE_ECC) || !defined(NO_DH)
6262
static CK_OBJECT_CLASS pubKeyClass = CKO_PUBLIC_KEY;
@@ -6482,7 +6482,11 @@ static void Usage(void)
64826482
printf("<num> Test case number to try\n");
64836483
}
64846484

6485+
#ifndef NO_MAIN_DRIVER
64856486
int main(int argc, char* argv[])
6487+
#else
6488+
int pkcs11test_mtt(int argc, char* argv[])
6489+
#endif
64866490
{
64876491
int ret;
64886492
CK_RV rv;
@@ -6603,12 +6607,16 @@ int main(int argc, char* argv[])
66036607

66046608
#else
66056609

6610+
#ifndef NO_MAIN_DRIVER
66066611
int main(int argc, char* argv[])
6612+
#else
6613+
int pkcs11test_mtt(int argc, char* argv[])
6614+
#endif
66076615
{
66086616
(void)argc;
66096617
(void)argv;
66106618
fprintf(stderr, "%s: multi-threaded example not compiled in!\n", argv[0]);
66116619
return 0;
66126620
}
66136621

6614-
#endif /* _POSIX_THREADS */
6622+
#endif /* _POSIX_THREADS && !SINGLE_THREADED */

tests/pkcs11str.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ static void* dlib;
132132
#endif
133133
static CK_FUNCTION_LIST* funcList;
134134
static int slot = 0;
135-
const char* tokenName = "wolfpkcs11";
135+
static const char* tokenName = "wolfpkcs11";
136136

137137
/* FIPS requires pin to be at least 14 characters, since it is used for
138138
* the HMAC key */
139139
static byte* soPin = (byte*)"password123456";
140140
static int soPinLen = 14;
141-
byte* userPin = (byte*)"wolfpkcs11-test";
142-
int userPinLen;
141+
static byte* userPin = (byte*)"wolfpkcs11-test";
142+
static int userPinLen;
143143

144144
#if !defined(NO_RSA) || defined(HAVE_ECC) || !defined(NO_DH)
145145
static CK_OBJECT_CLASS pubKeyClass = CKO_PUBLIC_KEY;
@@ -909,7 +909,11 @@ static int string_matches(const char* arg, const char* str)
909909
return XSTRNCMP(arg, str, len) == 0;
910910
}
911911

912+
#ifndef NO_MAIN_DRIVER
912913
int main(int argc, char* argv[])
914+
#else
915+
int pkcs11test_str(int argc, char* argv[])
916+
#endif
913917
{
914918
int ret;
915919
CK_RV rv;

tests/pkcs11test.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ static void* dlib;
5959
#endif
6060
static CK_FUNCTION_LIST* funcList;
6161
static int slot = 0;
62-
const char* tokenName = "wolfpkcs11";
62+
static const char* tokenName = "wolfpkcs11";
6363

6464
/* FIPS requires pin to be at least 14 characters, since it is used for
6565
* the HMAC key */
6666
static byte* soPin = (byte*)"password123456";
6767
static int soPinLen = 14;
68-
byte* userPin = (byte*)"wolfpkcs11-test";
69-
int userPinLen;
68+
static byte* userPin = (byte*)"wolfpkcs11-test";
69+
static int userPinLen;
7070

7171
#if !defined(NO_RSA) || defined(HAVE_ECC) || !defined(NO_DH)
7272
static CK_OBJECT_CLASS pubKeyClass = CKO_PUBLIC_KEY;
@@ -7896,7 +7896,11 @@ static void Usage(void)
78967896
printf("<num> Test case number to try\n");
78977897
}
78987898

7899+
#ifndef NO_MAIN_DRIVER
78997900
int main(int argc, char* argv[])
7901+
#else
7902+
int pkcs11test_test(int argc, char* argv[])
7903+
#endif
79007904
{
79017905
int ret;
79027906
CK_RV rv;
@@ -7974,7 +7978,7 @@ int main(int argc, char* argv[])
79747978
fprintf(stderr, "%d: %s\n", i + 1, testFunc[i].name);
79757979
return 0;
79767980
}
7977-
else if (isdigit(argv[0][0])) {
7981+
else if (isdigit((int)argv[0][0])) {
79787982
testCase = atoi(*argv);
79797983
if (testCase <= 0 || testCase > testFuncCnt) {
79807984
fprintf(stderr, "Test case out of range: %s\n", *argv);

0 commit comments

Comments
 (0)