mirror of https://github.com/wolfSSL/wolfssh.git
Fix three MinGW -Werror build failures in the regress/unit test build
MinGW-w64 does not ship arpa/inet.h; guard tests/regress.c's include the same way apps/wolfsshd/auth.c already does, since htonl/ntohl end up declared via the winsock2.h wolfSSL's headers pull in later in the same translation unit. wolfssh/test.h guarded its MSVC #pragma warning(disable:4996) with USE_WINDOWS_API alone, which is also true for MinGW's gcc; gcc treats the unrecognized pragma as an error under -Werror. Require _MSC_VER too, matching the existing ALIGN16 pragma guard in wolfssh/internal.h. wolfSSH_CleanPath's Windows/Nucleus drive-letter cleanup re-declared `i` in a nested scope, shadowing the function's own `i` used by every other loop in the function. Hoist `j` to the function's declarations (guarded by the same #if so non-Windows/Nucleus builds don't get an unused-variable warning) and drop the now-unnecessary block so the loop reuses the outer `i`. Verified locally: autoreconf + configure + make tests/regress.test tests/unit.test builds clean and both binaries pass on Linux.pull/1247/head
parent
4105c2242c
commit
83a2246471
|
|
@ -23887,6 +23887,9 @@ int wolfSSH_CleanPath(WOLFSSH* ssh, char* in, int inSz)
|
|||
byte found;
|
||||
char *path;
|
||||
void *heap = NULL;
|
||||
#if defined(WOLFSSL_NUCLEUS) || defined(USE_WINDOWS_API)
|
||||
int j;
|
||||
#endif
|
||||
|
||||
if (in == NULL || inSz <= 0) {
|
||||
return WS_BAD_ARGUMENT;
|
||||
|
|
@ -23986,19 +23989,16 @@ int wolfSSH_CleanPath(WOLFSSH* ssh, char* in, int inSz)
|
|||
}
|
||||
|
||||
/* clean up any multiple drive listed i.e. A:/A: */
|
||||
{
|
||||
int i,j;
|
||||
sz = (long)WSTRLEN(path);
|
||||
for (i = 0, j = 0; i < sz; i++) {
|
||||
if (path[i] == ':') {
|
||||
if (j == 0) j = i;
|
||||
else {
|
||||
/* @TODO only checking once */
|
||||
WMEMMOVE(path, path + i - WS_DRIVE_SIZE,
|
||||
sz - i + WS_DRIVE_SIZE);
|
||||
path[sz - i + WS_DRIVE_SIZE] = '\0';
|
||||
break;
|
||||
}
|
||||
sz = (long)WSTRLEN(path);
|
||||
for (i = 0, j = 0; i < sz; i++) {
|
||||
if (path[i] == ':') {
|
||||
if (j == 0) j = i;
|
||||
else {
|
||||
/* @TODO only checking once */
|
||||
WMEMMOVE(path, path + i - WS_DRIVE_SIZE,
|
||||
sz - i + WS_DRIVE_SIZE);
|
||||
path[sz - i + WS_DRIVE_SIZE] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <arpa/inet.h>
|
||||
#ifndef _WIN32
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
|
|
|||
Loading…
Reference in New Issue