Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

__kill_pgrp_info: simplify the calculation of return value

No need to calculate/check the "success" variable, we can kill it and update
retval in the main loop unless it is zero.

Link: https://lkml.kernel.org/r/20230823171455.GA12188@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Suggested-by: David Laight <David.Laight@ACULAB.COM>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Oleg Nesterov and committed by
Andrew Morton
39835204 8e1f3851

+11 -6
+11 -6
kernel/signal.c
··· 1471 1471 int __kill_pgrp_info(int sig, struct kernel_siginfo *info, struct pid *pgrp) 1472 1472 { 1473 1473 struct task_struct *p = NULL; 1474 - int retval, success; 1474 + int ret = -ESRCH; 1475 1475 1476 - success = 0; 1477 - retval = -ESRCH; 1478 1476 do_each_pid_task(pgrp, PIDTYPE_PGID, p) { 1479 1477 int err = group_send_sig_info(sig, info, p, PIDTYPE_PGID); 1480 - success |= !err; 1481 - retval = err; 1478 + /* 1479 + * If group_send_sig_info() succeeds at least once ret 1480 + * becomes 0 and after that the code below has no effect. 1481 + * Otherwise we return the last err or -ESRCH if this 1482 + * process group is empty. 1483 + */ 1484 + if (ret) 1485 + ret = err; 1482 1486 } while_each_pid_task(pgrp, PIDTYPE_PGID, p); 1483 - return success ? 0 : retval; 1487 + 1488 + return ret; 1484 1489 } 1485 1490 1486 1491 int kill_pid_info(int sig, struct kernel_siginfo *info, struct pid *pid)