about summary refs log tree commit diff
path: root/nptl/pthread_attr_setschedparam.c
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2013-04-22 10:28:31 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2013-04-22 10:28:31 +0530
commitda1304bcc8d718f40e58d92726c0fbc7b0d0794d (patch)
tree872f3f44330b1ec4faa83e22bf356ad31ef14b73 /nptl/pthread_attr_setschedparam.c
parent2169712d9c140d1b011470393c64258b2db3a4cd (diff)
downloadglibc-da1304bcc8d718f40e58d92726c0fbc7b0d0794d.tar.gz
glibc-da1304bcc8d718f40e58d92726c0fbc7b0d0794d.tar.xz
glibc-da1304bcc8d718f40e58d92726c0fbc7b0d0794d.zip
Consolidate pthread_attr value validation
Define inline functions that wrap around validation for each of the
pthread attributes to reduce duplication in code.
Diffstat (limited to 'nptl/pthread_attr_setschedparam.c')
-rw-r--r--nptl/pthread_attr_setschedparam.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/nptl/pthread_attr_setschedparam.c b/nptl/pthread_attr_setschedparam.c
index ec1a8bd444..a167f153d1 100644
--- a/nptl/pthread_attr_setschedparam.c
+++ b/nptl/pthread_attr_setschedparam.c
@@ -30,11 +30,10 @@ __pthread_attr_setschedparam (attr, param)
   assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   struct pthread_attr *iattr = (struct pthread_attr *) attr;
 
-  int min = sched_get_priority_min (iattr->schedpolicy);
-  int max = sched_get_priority_max (iattr->schedpolicy);
-  if (min == -1 || max == -1
-      || param->sched_priority > max || param->sched_priority < min)
-    return EINVAL;
+  int ret = check_sched_priority_attr (param->sched_priority,
+				       iattr->schedpolicy);
+  if (ret)
+    return ret;
 
   /* Copy the new values.  */
   memcpy (&iattr->schedparam, param, sizeof (struct sched_param));