Remove unneccessary local variable initializations and remove local variable declarations in for-loops

This commit is contained in:
TakayukiMatsuo
2021-02-26 17:17:32 +09:00
parent 2d0207fc60
commit 78e2e37fd6
2 changed files with 14 additions and 26 deletions

View File

@ -2401,7 +2401,7 @@ static void test_wolfSSL_EVP_PKEY_print_public(void)
WOLFSSL_BIO* wbio = NULL; WOLFSSL_BIO* wbio = NULL;
WOLFSSL_EVP_PKEY* pkey = NULL; WOLFSSL_EVP_PKEY* pkey = NULL;
char line[256] = { 0 }; char line[256] = { 0 };
int i;
printf(testingFmt, "wolfSSL_EVP_PKEY_print_public()"); printf(testingFmt, "wolfSSL_EVP_PKEY_print_public()");
/* test error cases */ /* test error cases */
@ -2442,7 +2442,7 @@ static void test_wolfSSL_EVP_PKEY_print_public(void)
/* skip to the end of modulus element*/ /* skip to the end of modulus element*/
for( int i = 0; i < 7 ;i++) { for( i = 0; i < 7 ;i++) {
BIO_gets(wbio, line, sizeof(line)); BIO_gets(wbio, line, sizeof(line));
} }
@ -2493,7 +2493,7 @@ static void test_wolfSSL_EVP_PKEY_print_public(void)
sizeof(" 00:c2:35:2d:ec:83:83:6c:73:13:9e:52:7c:74:c8:\n")),0); sizeof(" 00:c2:35:2d:ec:83:83:6c:73:13:9e:52:7c:74:c8:\n")),0);
/* skip to the end of pub element*/ /* skip to the end of pub element*/
for( int i = 0; i < 17 ;i++) { for( i = 0; i < 17 ;i++) {
BIO_gets(wbio, line, sizeof(line)); BIO_gets(wbio, line, sizeof(line));
} }
@ -2503,7 +2503,7 @@ static void test_wolfSSL_EVP_PKEY_print_public(void)
sizeof("P:\n")),0); sizeof("P:\n")),0);
/* skip to the end of P element*/ /* skip to the end of P element*/
for( int i = 0; i < 18 ;i++) { for( i = 0; i < 18 ;i++) {
BIO_gets(wbio, line, sizeof(line)); BIO_gets(wbio, line, sizeof(line));
} }
@ -2513,7 +2513,7 @@ static void test_wolfSSL_EVP_PKEY_print_public(void)
sizeof("Q:\n")),0); sizeof("Q:\n")),0);
/* skip to the end of Q element*/ /* skip to the end of Q element*/
for( int i = 0; i < 3 ;i++) { for( i = 0; i < 3 ;i++) {
BIO_gets(wbio, line, sizeof(line)); BIO_gets(wbio, line, sizeof(line));
} }
BIO_gets(wbio, line, sizeof(line)); BIO_gets(wbio, line, sizeof(line));
@ -2522,7 +2522,7 @@ static void test_wolfSSL_EVP_PKEY_print_public(void)
sizeof("G:\n")),0); sizeof("G:\n")),0);
/* skip to the end of G element*/ /* skip to the end of G element*/
for( int i = 0; i < 18 ;i++) { for( i = 0; i < 18 ;i++) {
BIO_gets(wbio, line, sizeof(line)); BIO_gets(wbio, line, sizeof(line));
} }
/* should reach EOF */ /* should reach EOF */
@ -2568,7 +2568,7 @@ static void test_wolfSSL_EVP_PKEY_print_public(void)
sizeof(" 04:55:bf:f4:0f:44:50:9a:3d:ce:9b:b7:f0:c5:4d:\n")),0); sizeof(" 04:55:bf:f4:0f:44:50:9a:3d:ce:9b:b7:f0:c5:4d:\n")),0);
/* skip to the end of pub element*/ /* skip to the end of pub element*/
for( int i = 0; i < 4 ;i++) { for( i = 0; i < 4 ;i++) {
BIO_gets(wbio, line, sizeof(line)); BIO_gets(wbio, line, sizeof(line));
} }
@ -2624,7 +2624,7 @@ static void test_wolfSSL_EVP_PKEY_print_public(void)
sizeof(" 34:41:bf:e9:f2:11:bf:05:db:b2:72:a8:29:cc:bd:\n")),0); sizeof(" 34:41:bf:e9:f2:11:bf:05:db:b2:72:a8:29:cc:bd:\n")),0);
/* skip to the end of public-key element*/ /* skip to the end of public-key element*/
for( int i = 0; i < 17 ;i++) { for( i = 0; i < 17 ;i++) {
BIO_gets(wbio, line, sizeof(line)); BIO_gets(wbio, line, sizeof(line));
} }
@ -2639,7 +2639,7 @@ static void test_wolfSSL_EVP_PKEY_print_public(void)
sizeof(" 00:d3:b2:99:84:5c:0a:4c:e7:37:cc:fc:18:37:01:\n")),0); sizeof(" 00:d3:b2:99:84:5c:0a:4c:e7:37:cc:fc:18:37:01:\n")),0);
/* skip to the end of prime element*/ /* skip to the end of prime element*/
for( int i = 0; i < 17 ;i++) { for( i = 0; i < 17 ;i++) {
BIO_gets(wbio, line, sizeof(line)); BIO_gets(wbio, line, sizeof(line));
} }
@ -2665,6 +2665,7 @@ static void test_wolfSSL_EVP_PKEY_print_public(void)
(void)wbio; (void)wbio;
(void)rbio; (void)rbio;
(void)line; (void)line;
(void)i;
printf(resultFmt, passed); printf(resultFmt, passed);
#endif /* OPENSSL_EXTRA */ #endif /* OPENSSL_EXTRA */
} }
@ -22600,9 +22601,10 @@ static int test_wc_DhPublicKeyDecode(void)
{ {
int ret = 0; int ret = 0;
word32 inOutIdx; word32 inOutIdx;
DhKey key;
#if defined(WOLFSSL_DH_EXTRA) && defined(USE_CERT_BUFFERS_2048) #if defined(WOLFSSL_DH_EXTRA) && defined(USE_CERT_BUFFERS_2048)
DhKey key;
printf(testingFmt, "test_wc_DhPublicKeyDecode()"); printf(testingFmt, "test_wc_DhPublicKeyDecode()");
if (ret == 0) { if (ret == 0) {
@ -22643,7 +22645,6 @@ static int test_wc_DhPublicKeyDecode(void)
printf(resultFmt, ret == 0 ? passed : failed); printf(resultFmt, ret == 0 ? passed : failed);
#endif #endif
(void)inOutIdx; (void)inOutIdx;
(void)key;
return ret; return ret;
} }

View File

@ -6890,10 +6890,6 @@ static int DumpElement(WOLFSSL_BIO* out, const byte* input,
left = len % 15; left = len % 15;
/* print pub element */ /* print pub element */
idx = 0;
wsz = Indent(indent, buff + idx);
idx += wsz;
while (line) { while (line) {
idx = 0; idx = 0;
@ -6913,8 +6909,6 @@ static int DumpElement(WOLFSSL_BIO* out, const byte* input,
wolfSSL_BIO_write(out, buff, idx); wolfSSL_BIO_write(out, buff, idx);
XMEMSET(buff, 0, sizeof(buff)); XMEMSET(buff, 0, sizeof(buff));
idx = 0;
wsz = 0;
line--; line--;
} }
idx = 0; idx = 0;
@ -6953,11 +6947,12 @@ static int PrintPubKeyRSA(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
word32 localIdx; word32 localIdx;
word32 oid; word32 oid;
byte tag; byte tag;
(void)pctx;
int idx = 0; int idx = 0;
int wsz = 0; int wsz = 0;
word32 i; word32 i;
(void)pctx;
if (GetSequence(pkey, &inOutIdx, &length, pkeySz) < 0) if (GetSequence(pkey, &inOutIdx, &length, pkeySz) < 0)
return WOLFSSL_FAILURE; return WOLFSSL_FAILURE;
@ -7024,8 +7019,6 @@ static int PrintPubKeyRSA(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
/* print out public key elements */ /* print out public key elements */
idx = 0; idx = 0;
wsz = 0;
wsz = Indent(indent, buff + idx); wsz = Indent(indent, buff + idx);
idx += wsz; idx += wsz;
@ -7135,8 +7128,6 @@ static int PrintPubKeyEC(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
nistCurveName = wolfSSL_EC_curve_nid2nist(nid); nistCurveName = wolfSSL_EC_curve_nid2nist(nid);
idx = 0; idx = 0;
wsz = 0;
wsz = Indent(indent, buff + idx); wsz = Indent(indent, buff + idx);
idx += wsz; idx += wsz;
@ -7305,8 +7296,6 @@ static int PrintPubKeyDSA(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
ySz = length; ySz = length;
idx = 0; idx = 0;
wsz = 0;
wsz = Indent(indent, buff + idx); wsz = Indent(indent, buff + idx);
idx += wsz; idx += wsz;
@ -7462,8 +7451,6 @@ static int PrintPubKeyDH(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
/* print elements */ /* print elements */
idx = 0; idx = 0;
wsz = 0;
wsz = Indent(indent, buff + idx); wsz = Indent(indent, buff + idx);
idx += wsz; idx += wsz;