From patchwork Mon May 25 20:59:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 135637 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5B0C14BA23E1 for ; Mon, 25 May 2026 21:00:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B0C14BA23E1 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 135914BA23DD for ; Mon, 25 May 2026 20:59:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 135914BA23DD Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 135914BA23DD Authentication-Results: sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779742773; cv=none; b=LFtwCLDXUmboMEGDzLUbvcGWsUQkIeeicVv8tGfFTc05uAidKG73rH/Rh8daKPuE/Kta/dq2pF7WMkYXiY3KAK/L/tJ7TXZ+h9dNQRL89TaxNJnxWGonB8E6VpiZIOk1+5waFloOYt/RGyX25169PADYlx1mWyBVPBLTqXl4IJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779742773; c=relaxed/simple; bh=1+DT/BHxpG1L5p98GdTLsPY7zdg3BAaU6prsRgZnDE8=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=WziEJFwnmsfGy+yh+Rduvmx58SLs9FK0aUl5pBYBWGCyLZywD3/SMwTf8MaOOwrbh/HVyilOsh/KVrLVHERF3KuXk4EprDB42z1B6LH/m81npI6Y8zGeZAIUIgDQ9nKzNf9v/VOeJEDH1scB/2f9sar09ztIk3cpOyJ1fTEPoGk= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 135914BA23DD Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 29DB8A0119; Mon, 25 May 2026 22:59:31 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I2L73asyPXn5; Mon, 25 May 2026 22:59:31 +0200 (CEST) Received: from end (aamiens-653-1-40-48.w83-192.abo.wanadoo.fr [83.192.199.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 0CCF4A0118; Mon, 25 May 2026 22:59:30 +0200 (CEST) Received: from samy by end with local (Exim 4.99.2) (envelope-from ) id 1wRcOY-0000000FWHU-0Sue; Mon, 25 May 2026 22:59:30 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Diego Nieto Cid , commit-hurd@gnu.org Subject: [hurd, commited] hurd: clamp the setpriority prio argument to the range [-NZERO, NZERO-1] Date: Mon, 25 May 2026 22:59:29 +0200 Message-ID: <20260525205929.3698998-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_PBL, SPF_HELO_PASS, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org From: Diego Nieto Cid 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] ) --- 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) {