Skip to content

Commit 4b20f1a

Browse files
committed
examples, tests: terminate the ES_ERROR messages with a newline
ES_ERROR() passes its arguments straight to fprintf(stderr, ...), so a message with no trailing newline runs into whatever the shell or the test harness prints next. - 7 sites in the echoserver, 6 in tests/auth.c, 8 in the Espressif copy of the echoserver, which carries the same macro and takes this kind of cross-cutting fix (e91ff50, ab8058d) - the two wrapped format strings already ended with a newline
1 parent 9731cfe commit 4b20f1a

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

examples/echoserver/echoserver.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3159,13 +3159,13 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
31593159

31603160
case 'p':
31613161
if (myoptarg == NULL) {
3162-
ES_ERROR("NULL port value");
3162+
ES_ERROR("NULL port value\n");
31633163
}
31643164
else {
31653165
port = (word16)atoi(myoptarg);
31663166
#if !defined(NO_MAIN_DRIVER)
31673167
if (port == 0) {
3168-
ES_ERROR("port number cannot be 0");
3168+
ES_ERROR("port number cannot be 0\n");
31693169
}
31703170
#endif
31713171
}
@@ -3397,20 +3397,20 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
33973397
kbAuthData.promptLanguageSz = 0;
33983398
kbAuthData.prompts = (byte**)WMALLOC(sizeof(byte*), NULL, 0);
33993399
if (kbAuthData.prompts == NULL) {
3400-
ES_ERROR("Error allocating prompts");
3400+
ES_ERROR("Error allocating prompts\n");
34013401
}
34023402
kbAuthData.promptLengths = (word32*)WMALLOC(sizeof(word32), NULL, 0);
34033403
if (kbAuthData.promptLengths == NULL) {
34043404
WFREE(kbAuthData.prompts, NULL, 0);
3405-
ES_ERROR("Error allocating promptLengths");
3405+
ES_ERROR("Error allocating promptLengths\n");
34063406
}
34073407
kbAuthData.prompts[0] = (byte*)"KB Auth Password: ";
34083408
kbAuthData.promptLengths[0] = 18;
34093409
kbAuthData.promptEcho = (byte*)WMALLOC(sizeof(byte), NULL, 0);
34103410
if (kbAuthData.promptEcho == NULL) {
34113411
WFREE(kbAuthData.prompts, NULL, 0);
34123412
WFREE(kbAuthData.promptLengths, NULL, 0);
3413-
ES_ERROR("Error allocating promptEcho");
3413+
ES_ERROR("Error allocating promptEcho\n");
34143414
}
34153415
kbAuthData.promptEcho[0] = 0;
34163416
LoadKeyboardList(keyboardList, &pwMapList, &kbAuthData);
@@ -3432,7 +3432,7 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
34323432
keyLoadBuf = (byte*)WMALLOC(EXAMPLE_KEYLOAD_BUFFER_SZ,
34333433
NULL, 0);
34343434
if (keyLoadBuf == NULL) {
3435-
ES_ERROR("Error allocating keyLoadBuf");
3435+
ES_ERROR("Error allocating keyLoadBuf\n");
34363436
}
34373437
#else
34383438
keyLoadBuf = buf;
@@ -3788,7 +3788,7 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
37883788
&clientAddrSz);
37893789
#endif
37903790
if (clientFd == -1) {
3791-
ES_ERROR("tcp accept failed");
3791+
ES_ERROR("tcp accept failed\n");
37923792
}
37933793

37943794
if (nonBlock)

ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/echoserver.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,13 +2658,13 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
26582658

26592659
case 'p':
26602660
if (myoptarg == NULL) {
2661-
ES_ERROR("NULL port value");
2661+
ES_ERROR("NULL port value\n");
26622662
}
26632663
else {
26642664
port = (word16)atoi(myoptarg);
26652665
#if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API)
26662666
if (port == 0) {
2667-
ES_ERROR("port number cannot be 0");
2667+
ES_ERROR("port number cannot be 0\n");
26682668
}
26692669
#endif
26702670
}
@@ -2748,7 +2748,7 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
27482748

27492749
#ifdef WOLFSSH_TEST_BLOCK
27502750
if (!nonBlock) {
2751-
ES_ERROR("Use -N when testing forced non blocking");
2751+
ES_ERROR("Use -N when testing forced non blocking\n");
27522752
}
27532753
#endif
27542754

@@ -2881,20 +2881,20 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
28812881
kbAuthData.promptLanguageSz = 0;
28822882
kbAuthData.prompts = (byte**)WMALLOC(sizeof(byte*), NULL, 0);
28832883
if (kbAuthData.prompts == NULL) {
2884-
ES_ERROR("Error allocating prompts");
2884+
ES_ERROR("Error allocating prompts\n");
28852885
}
28862886
kbAuthData.promptLengths = (word32*)WMALLOC(sizeof(word32), NULL, 0);
28872887
if (kbAuthData.promptLengths == NULL) {
28882888
WFREE(kbAuthData.prompts, NULL, 0);
2889-
ES_ERROR("Error allocating promptLengths");
2889+
ES_ERROR("Error allocating promptLengths\n");
28902890
}
28912891
kbAuthData.prompts[0] = (byte*)"KB Auth Password: ";
28922892
kbAuthData.promptLengths[0] = 18;
28932893
kbAuthData.promptEcho = (byte*)WMALLOC(sizeof(byte), NULL, 0);
28942894
if (kbAuthData.promptEcho == NULL) {
28952895
WFREE(kbAuthData.prompts, NULL, 0);
28962896
WFREE(kbAuthData.promptLengths, NULL, 0);
2897-
ES_ERROR("Error allocating promptEcho");
2897+
ES_ERROR("Error allocating promptEcho\n");
28982898
}
28992899
kbAuthData.promptEcho[0] = 0;
29002900
wolfSSH_SetKeyboardAuthPrompts(ctx, keyboardCallback);
@@ -2913,7 +2913,7 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
29132913
keyLoadBuf = (byte*)WMALLOC(EXAMPLE_KEYLOAD_BUFFER_SZ,
29142914
NULL, 0);
29152915
if (keyLoadBuf == NULL) {
2916-
ES_ERROR("Error allocating keyLoadBuf");
2916+
ES_ERROR("Error allocating keyLoadBuf\n");
29172917
}
29182918
#else
29192919
keyLoadBuf = buf;
@@ -3200,7 +3200,7 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
32003200
&clientAddrSz);
32013201
#endif
32023202
if (clientFd == -1) {
3203-
ES_ERROR("tcp accept failed");
3203+
ES_ERROR("tcp accept failed\n");
32043204
}
32053205

32063206
if (nonBlock)

tests/auth.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,20 +1814,20 @@ static THREAD_RETURN WOLFSSH_THREAD server_thread(void* args)
18141814
promptData.prompts =
18151815
(byte**)WMALLOC(sizeof(byte*) * kbResponseCount, NULL, 0);
18161816
if (promptData.prompts == NULL) {
1817-
ES_ERROR("Could not allocate prompts");
1817+
ES_ERROR("Could not allocate prompts\n");
18181818
}
18191819
promptData.promptLengths =
18201820
(word32*)WMALLOC(sizeof(word32) * kbResponseCount, NULL, 0);
18211821
if (promptData.promptLengths == NULL) {
18221822
WFREE(promptData.prompts, NULL, 0);
1823-
ES_ERROR("Could not allocate promptLengths");
1823+
ES_ERROR("Could not allocate promptLengths\n");
18241824
}
18251825
promptData.promptEcho =
18261826
(byte*)WMALLOC(sizeof(byte) * kbResponseCount, NULL, 0);
18271827
if (promptData.promptEcho == NULL) {
18281828
WFREE(promptData.prompts, NULL, 0);
18291829
WFREE(promptData.promptLengths, NULL, 0);
1830-
ES_ERROR("Could not allocate promptEcho");
1830+
ES_ERROR("Could not allocate promptEcho\n");
18311831
}
18321832
for (word32 prompt = 0; prompt < kbResponseCount; prompt++) {
18331833
promptData.prompts[prompt] = (byte*)"Password: ";
@@ -1870,13 +1870,13 @@ static THREAD_RETURN WOLFSSH_THREAD server_thread(void* args)
18701870

18711871
clientFd = accept(listenFd, (struct sockaddr*)&clientAddr, &clientAddrSz);
18721872
if (clientFd == -1) {
1873-
ES_ERROR("tcp accept failed");
1873+
ES_ERROR("tcp accept failed\n");
18741874
}
18751875
wolfSSH_set_fd(ssh, (int)clientFd);
18761876

18771877
ret = wolfSSH_accept(ssh);
18781878
if (ret && !unbalanced) {
1879-
ES_ERROR("wolfSSH Accept Error");
1879+
ES_ERROR("wolfSSH Accept Error\n");
18801880
}
18811881

18821882
ret = wolfSSH_shutdown(ssh);
@@ -1900,7 +1900,7 @@ static THREAD_RETURN WOLFSSH_THREAD server_thread(void* args)
19001900
wolfSSH_CTX_free(ctx);
19011901

19021902
if (ret) {
1903-
ES_ERROR("wolfSSH Shutdown Error");
1903+
ES_ERROR("wolfSSH Shutdown Error\n");
19041904
}
19051905

19061906
WOLFSSL_RETURN_FROM_THREAD(0);

0 commit comments

Comments
 (0)