Skip to content

Commit 2ff40fc

Browse files
committed
reduce indentation
1 parent 42d5119 commit 2ff40fc

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

Modules/_remote_debugging/subprocess.c

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ find_children_bfs(pid_t target_pid, int recursive,
107107
if (pid_array_init(&to_process) < 0) {
108108
goto done;
109109
}
110-
111110
if (pid_array_append(&to_process, target_pid) < 0) {
112111
goto done;
113112
}
@@ -117,20 +116,18 @@ find_children_bfs(pid_t target_pid, int recursive,
117116
pid_t current_pid = to_process.pids[process_idx++];
118117

119118
for (size_t i = 0; i < pid_count; i++) {
120-
if (ppids[i] == current_pid) {
121-
pid_t child_pid = all_pids[i];
122-
123-
if (!pid_array_contains(result, child_pid)) {
124-
if (pid_array_append(result, child_pid) < 0) {
125-
goto done;
126-
}
127-
128-
if (recursive) {
129-
if (pid_array_append(&to_process, child_pid) < 0) {
130-
goto done;
131-
}
132-
}
133-
}
119+
if (ppids[i] != current_pid) {
120+
continue;
121+
}
122+
pid_t child_pid = all_pids[i];
123+
if (pid_array_contains(result, child_pid)) {
124+
continue;
125+
}
126+
if (pid_array_append(result, child_pid) < 0) {
127+
goto done;
128+
}
129+
if (recursive && pid_array_append(&to_process, child_pid) < 0) {
130+
goto done;
134131
}
135132
}
136133

@@ -232,20 +229,19 @@ get_child_pids_platform(pid_t target_pid, int recursive, pid_array_t *result)
232229
if (entry->d_name[0] < '1' || entry->d_name[0] > '9') {
233230
continue;
234231
}
235-
236232
char *endptr;
237233
long pid_long = strtol(entry->d_name, &endptr, 10);
238234
if (*endptr != '\0' || pid_long <= 0) {
239235
continue;
240236
}
241237
pid_t pid = (pid_t)pid_long;
242238
pid_t ppid = get_ppid_linux(pid);
243-
244-
if (ppid >= 0) {
245-
if (pid_array_append(&all_pids, pid) < 0 ||
246-
pid_array_append(&ppids, ppid) < 0) {
247-
goto done;
248-
}
239+
if (ppid < 0) {
240+
continue;
241+
}
242+
if (pid_array_append(&all_pids, pid) < 0 ||
243+
pid_array_append(&ppids, ppid) < 0) {
244+
goto done;
249245
}
250246
}
251247

@@ -321,11 +317,12 @@ get_child_pids_platform(pid_t target_pid, int recursive, pid_array_t *result)
321317
struct proc_bsdinfo proc_info;
322318
int ret = proc_pidinfo(pid_list[i], PROC_PIDTBSDINFO, 0,
323319
&proc_info, sizeof(proc_info));
324-
if (ret == sizeof(proc_info)) {
325-
pid_list[valid_count] = pid_list[i];
326-
ppids[valid_count] = proc_info.pbi_ppid;
327-
valid_count++;
320+
if (ret != sizeof(proc_info)) {
321+
continue;
328322
}
323+
pid_list[valid_count] = pid_list[i];
324+
ppids[valid_count] = proc_info.pbi_ppid;
325+
valid_count++;
329326
}
330327

331328
if (find_children_bfs(target_pid, recursive,

0 commit comments

Comments
 (0)