From: Rich Felker <dalias@libc.org>
To: yan.li.cn@windriver.com
Cc: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] add check for pthread_attr_setschedparam().
Date: Tue, 24 Dec 2024 04:41:04 -0500 [thread overview]
Message-ID: <20241224094104.GD10433@brightrain.aerifal.cx> (raw)
In-Reply-To: <20241224020301.1673274-1-yan.li.cn@windriver.com>
On Tue, Dec 24, 2024 at 10:03:01AM +0800, yan.li.cn@windriver.com wrote:
> From: Yan Li <yan.li.cn@windriver.com>
>
> ---
> src/thread/pthread_attr_setschedparam.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
> mode change 100644 => 100755 src/thread/pthread_attr_setschedparam.c
>
> diff --git a/src/thread/pthread_attr_setschedparam.c b/src/thread/pthread_attr_setschedparam.c
> old mode 100644
> new mode 100755
> index d4c1204f..4e28415e
> --- a/src/thread/pthread_attr_setschedparam.c
> +++ b/src/thread/pthread_attr_setschedparam.c
> @@ -2,6 +2,13 @@
>
> int pthread_attr_setschedparam(pthread_attr_t *restrict a, const struct sched_param *restrict param)
> {
> - a->_a_prio = param->sched_priority;
> - return 0;
> + int min = sched_get_priority_min (a->_a_policy);
> + int max = sched_get_priority_max (a->_a_policy);
> +
> + if (min < 0 || max < 0 || param->sched_priority < min || param->sched_priority > max){
> + return EINVAL;
> + }
> +
> + a->_a_prio = param->sched_priority;
> + return 0;
> }
> --
> 2.34.1
I don't see a good motivation for this change. The error conditions
are MAY FAIL, not SHALL FAIL, and checking for them incurs two useless
syscalls on every call to a function that's otherwise syscall-free.
Rich
next prev parent reply other threads:[~2024-12-24 9:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-24 2:03 yan.li.cn
2024-12-24 9:41 ` Rich Felker [this message]
2024-12-24 14:00 ` Markus Wichmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241224094104.GD10433@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.com \
--cc=yan.li.cn@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).