libutil: return 0 from setEnv on success on Windows - #16354
Merged
Conversation
The header describes these as POSIX-like, where success is 0 and failure -1. SetEnvironmentVariable reports the opposite, nonzero for success, and negating it gave -1 for success and 0 for failure. No caller checks the return value today, so nothing is currently broken by it; the first thing to look was a test. Assisted-by: Claude Code (claude-opus-5)
Ericson2314
enabled auto-merge
August 24, 2026 18:48
Ericson2314
approved these changes
Aug 24, 2026
Member
|
@awsmadi I am going to approve and queue this as an incremental improvement, but I suspect that what we really want to happen is that these wrapper functions return Let's look into that in a follow-up PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
environment-variables.hhdescribes these as POSIX-like: "Like POSIXsetenv, butalways overrides." POSIX returns 0 on success and -1 on failure.
SetEnvironmentVariablereports the opposite, nonzero for success, and negating itproduced -1 for success and 0 for failure.
So on Windows all four of
setEnv,setEnvOs,unsetenvandunsetEnvOsreturned-1 when they worked.
Nothing is broken by this today: no caller in the tree checks the return value. The
first thing to look at it was a test I was writing for a different change, which
failed on
ASSERT_EQ(setEnvOs(name, OS_STR("")), 0)with "Which is: -1".Two tests in
libutil-testscovering the convention. They pass on both platformsand fail on Windows without this change.
nix-util-testspasses at 784 under Wine and builds clean natively.