Skip to content

Commit bb80fdd

Browse files
committed
Do not negate the one identifier that has no positive counterpart
Found reviewing the change that precedes it. `kill(-n)' negates the identifier twice --- once to look the unit up and once, now, to compare it against this program's own --- and INT_MIN has no positive counterpart in the type, so both are undefined for that one value. A caller reaching here with it names no unit either way, so it takes the route every other identifier that names none takes.
1 parent 28d5a3d commit bb80fdd

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

port/src/okm_syscall.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,12 @@ syscall_arg_t __okm_syscall(syscall_arg_t n, syscall_arg_t a1, syscall_arg_t a2,
19231923
* the two defects before it: a call that succeeds and changes nothing
19241924
* observable is worse than one that refuses, because the caller proceeds.
19251925
* `kill(-n)' answered ESRCH here while the unit existed. */
1926-
if (pid < 0 && pid != -1) {
1926+
/* ⚠️ `pid != INT_MIN' IS NOT DEFENSIVENESS. Negating it is undefined --- it
1927+
* has no positive counterpart in the type --- and both this block and the
1928+
* comparison at its end negate. A caller reaching here with that value
1929+
* names no unit either way, so it takes the same route as any other
1930+
* identifier that names none. */
1931+
if (pid < 0 && pid != -1 && pid != INT_MIN) {
19271932
const int gi = job_index(-pid);
19281933
if (gi >= 0 && g_child[gi].has_job) {
19291934
if (sig == 0) return 0;

0 commit comments

Comments
 (0)