gh-94518: [_posixsubprocess] Replace variable validity flags with reserved values #94687
+22
−26
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.
Currently,
Modules/_posixsubprocess.c
uses variables supplied with flags of whether the variable was initialized with a value. However it confuses both a reader (another mental connection required to constantly keep in mind across functions) and a compiler (warnings on potentially uninitialized variables). We can use a fact that these variables are of types with special values not used by anything else. This PR replaces the dedicated flags with these token values.Namely:
gid
:call_setgid = False
→gid = -1
uid
:call_setuid = False
→uid = -1
groups
:call_setgroups = False
→groups = NULL
(obtained with(groups_list != Py_None) ? groups : NULL
)This PR is required for gh-94519.
PS.: @tiran I applied your suggestion from gh-94519 as this, separate PR to keep that one limited in scope and reviewable.