From bf5a8015e20d714c6f7f2e1c970c02db02492ee2 Mon Sep 17 00:00:00 2001 From: Ruby Martin Date: Wed, 5 Aug 2026 17:18:09 -0600 Subject: [PATCH] Define WFSEEK_SUCCESS() for instances where WFSEEK() returns non-zero success case --- wolfssh/port.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wolfssh/port.h b/wolfssh/port.h index 3be71494..1743e3fd 100644 --- a/wolfssh/port.h +++ b/wolfssh/port.h @@ -124,6 +124,7 @@ extern "C" { #define WREWIND(fs,s) NU_Seek(*(s), 0, PSEEK_SET) #define WSEEK_END PSEEK_END #define WBADFILE NULL + #define WFSEEK_SUCCESS(r) ((int)(r) >= 0) #define WS_DELIM '\\' #define WOLFSSH_O_RDWR PO_RDWR @@ -440,6 +441,7 @@ extern "C" { #define WSETTIME(fs,f,a,m) (0) #define WFSETTIME(fs,fd,a,m) (0) #define WCHDIR(fs,b) SYS_FS_DirectryChange((b)) + #define WFSEEK_SUCCESS(r) ((int)(r) >= 0) #else #include @@ -1624,6 +1626,15 @@ extern "C" { #define WOLFSSH_O_NOFOLLOW 0 #endif +/* Catch-all so callers can test a seek result unconditionally. Ports whose + * seek returns the new file position rather than a 0/-1 status define their + * own WFSEEK_SUCCESS() in the port block above; see Nucleus and MPLAB + * Harmony. Any definition must evaluate its argument exactly once, as + * callers pass the WFSEEK() call in directly. */ +#ifndef WFSEEK_SUCCESS + #define WFSEEK_SUCCESS(r) ((r) == 0) +#endif + /* wIsSymlink lives in the always-compiled port.c, but its filesystem * dependencies (WSTAT_T/WLSTAT/S_ISLNK on POSIX, WS_GetFileAttributesExA on * Windows) and its only callers exist solely in the SFTP and SCP code, so