[glibc] hurd: clamp the setpriority prio argument to the range [-NZERO, NZERO-1]
Samuel Thibault via Glibc-cvs <[email protected]> Mon, 25 May 2026 20:59:19 +0000 (GMT)
| Newsgroups | gmane.comp.lib.glibc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=58ae7f8f0c1d7e69adbe07ef374ac65706dda0ba commit 58ae7f8f0c1d7e69adbe07ef374ac65706dda0ba Author: Diego Nieto Cid <[email protected]> Date: Mon May 25 22:56:42 2026 +0200 hurd: clamp the setpriority prio argument to the range [-NZERO, NZERO-1] The Open Group Base Specifications Issue 8 getpriority ( https://pubs.opengroup.org/onlinepubs/9799919799/ ) << The nice value is in the range [0,2*{NZERO} -1], while the return value for getpriority() and the third parameter for setpriority() are in the range [-{NZERO},{NZERO} -1]. >> So given that NZERO is defined to 20, we shall use it to clamp to the range specified by POSIX. That range is then mapped to something similar to [0, 2*{NZERO}-1], as specified by POSIX, through the usage of the macro NICE_TO_MACH_PRIORITY and MACH_PRIORITY_TO_NICE. (i.e. [5, 45] ) Diff: --- sysdeps/mach/hurd/setpriority.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/mach/hurd/setpriority.c b/sysdeps/mach/hurd/setpriority.c index 23d678bf40..8107098991 100644 --- a/sysdeps/mach/hurd/setpriority.c +++ b/sysdeps/mach/hurd/setpriority.c @@ -28,7 +28,7 @@ __setpriority (enum __priority_which which, id_t who, int prio) error_t pidloser, priloser; unsigned int npids, ntasks, nwin, nperm, nacces; - prio = MAX (0, MIN (2 * NZERO - 1, prio)); + prio = MAX ((-NZERO), MIN ((NZERO - 1), prio)); error_t setonepriority (pid_t pid, struct procinfo *pi) {