Skip to content

Commit ab82f89

Browse files
sivileridvrogozh
authored andcommitted
win32 compat: Fix setenv/unsetenv return values
The return values did not match the calls to the delegated functions. Signed-off-by: Sil Vilerino <[email protected]>
1 parent ecd26b3 commit ab82f89

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

test/compat_win32.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,27 @@
3030
extern "C" {
3131
#endif
3232

33+
/* The setenv() function returns zero on success, or -1 on error, with
34+
* errno set to indicate the cause of the error.
35+
*
36+
* SetEnvironmentVariableA Return value
37+
* If the function succeeds, the return value is nonzero.
38+
* If the function fails, the return value is zero.
39+
*/
3340
inline int setenv(const char *varname, const char *value_string, int overwrite)
3441
{
35-
return SetEnvironmentVariableA(varname, value_string);
42+
return SetEnvironmentVariableA(varname, value_string) ? 0 : -1;
3643
}
3744

45+
/* The unsetenv() function returns zero on success, or -1 on error,
46+
* with errno set to indicate the cause of the error.
47+
* SetEnvironmentVariableA Return value
48+
* If the function succeeds, the return value is nonzero.
49+
* If the function fails, the return value is zero.
50+
*/
3851
inline int unsetenv(const char *varname)
3952
{
40-
return SetEnvironmentVariableA(varname, NULL);
53+
return SetEnvironmentVariableA(varname, NULL) ? 0 : -1;
4154
}
4255

4356
#ifdef __cplusplus

0 commit comments

Comments
 (0)