Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2e438d9
Convert fork_exec to pre-inlined-argparser Argument Clinic
arhadthedev Jul 2, 2022
514a377
Make flag parameters boolean
arhadthedev Jul 2, 2022
f6ffbb7
Regenerate clinic 3.10 files using clinic 3.12
arhadthedev Jul 2, 2022
bed7d60
Fix forced arg format
arhadthedev Jul 2, 2022
603be00
Fixed a non-existent name left after renaming
arhadthedev Jul 3, 2022
a0646e6
Revert named arguments in multiprocessing/util.py
arhadthedev Jul 3, 2022
86edd0e
Add a NEWS entry
arhadthedev Jul 3, 2022
fe48164
Move uninitialized variables closer to their initialization
arhadthedev Jul 5, 2022
90bb494
Mark do_fork_exec as C11 _Noreturn and remove `return 0` hack
arhadthedev Jul 5, 2022
d0a586c
Address the review on undefined gid/uid
arhadthedev Jul 5, 2022
df6bb72
Fix an unitialized PID
arhadthedev Jul 6, 2022
c927533
Remove confusing out-of-place variable definitions
arhadthedev Jul 7, 2022
9cb1268
Fix fluke (?) "pid may be used uninitialized in this function"
arhadthedev Jul 7, 2022
18e8821
Fix a minor grammar error
arhadthedev Jul 7, 2022
c822f10
Address Gregory's review
arhadthedev Jul 26, 2022
0c6725e
Merge branch 'main' into burn-posixsubprocess-with-ac
arhadthedev Jan 15, 2023
2535f5e
Update a clinic file
arhadthedev Jan 15, 2023
6822d10
Remove a redundant initialization already covered in all `if` branche…
arhadthedev Jan 15, 2023
e09851f
Bring groups -> extra_groups from the main
arhadthedev Jan 26, 2023
a75cc40
Merge branch 'main' into burn-posixsubprocess-with-ac
arhadthedev Jan 26, 2023
d070f06
Merge branch 'main' into burn-posixsubprocess-with-ac
arhadthedev Mar 22, 2023
7251169
Fix reading from uninitialized `pid`
arhadthedev Apr 12, 2023
4ec550d
Merge branch 'main' into burn-posixsubprocess-with-ac
arhadthedev Apr 15, 2023
c7e1a5e
Minimize the diff
arhadthedev Apr 15, 2023
cda283a
Merge branch 'main' into burn-posixsubprocess-with-ac
arhadthedev Apr 23, 2023
2356ec5
Merge branch 'main' into burn-posixsubprocess-with-ac
gpshead Apr 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move uninitialized variables closer to their initialization
  • Loading branch information
arhadthedev committed Aug 24, 2022
commit fe48164a1a0f81b515291d4da55eec250b262c72
19 changes: 9 additions & 10 deletions Modules/_posixsubprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,14 +873,12 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
PyObject *converted_args = NULL, *fast_args = NULL;
PyObject *preexec_fn_args_tuple = NULL;
int call_setgid = 0, call_setgroups = 0, call_setuid = 0;
uid_t uid;
gid_t gid, *groups = NULL;
gid_t *groups = NULL;
PyObject *cwd_obj2 = NULL;
const char *cwd;
pid_t pid = -1;
const char *cwd = NULL;
int need_to_reenable_gc = 0;
char *const *exec_array, *const *argv = NULL, *const *envp = NULL;
Py_ssize_t arg_num, num_groups = 0;
char *const *argv = NULL, *const *envp = NULL;
Py_ssize_t num_groups = 0;
int need_after_fork = 0;
int saved_errno = 0;

Expand Down Expand Up @@ -913,7 +911,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
need_to_reenable_gc = PyGC_Disable();
}

exec_array = _PySequence_BytesToCharpArray(executable_list);
char *const *exec_array = _PySequence_BytesToCharpArray(executable_list);
if (!exec_array)
goto cleanup;

Expand All @@ -931,7 +929,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
converted_args = PyTuple_New(num_args);
if (converted_args == NULL)
goto cleanup;
for (arg_num = 0; arg_num < num_args; ++arg_num) {
for (Py_ssize_t arg_num = 0; arg_num < num_args; ++arg_num) {
PyObject *borrowed_arg, *converted_arg;
if (PySequence_Fast_GET_SIZE(fast_args) != num_args) {
PyErr_SetString(PyExc_RuntimeError, "args changed during iteration");
Expand Down Expand Up @@ -960,8 +958,6 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
if (PyUnicode_FSConverter(cwd_obj, &cwd_obj2) == 0)
goto cleanup;
cwd = PyBytes_AsString(cwd_obj2);
} else {
cwd = NULL;
}

if (groups_list != Py_None) {
Expand Down Expand Up @@ -1001,6 +997,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
Py_DECREF(elem);
goto cleanup;
} else {
gid_t gid;
if (!_Py_Gid_Converter(elem, &gid)) {
Py_DECREF(elem);
PyErr_SetString(PyExc_ValueError, "invalid group id");
Expand Down Expand Up @@ -1031,6 +1028,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
#endif /* HAVE_SETREUID */
}

uid_t uid;
if (uid_object != Py_None) {
#ifdef HAVE_SETREUID
if (!_Py_Uid_Converter(uid_object, &uid))
Expand Down Expand Up @@ -1080,6 +1078,7 @@ subprocess_fork_exec_impl(PyObject *module, PyObject *process_args,
}
#endif

pid_t pid;
pid = do_fork_exec(exec_array, argv, envp, cwd,
p2cread, p2cwrite, c2pread, c2pwrite,
errread, errwrite, errpipe_read, errpipe_write,
Expand Down