From da1304bcc8d718f40e58d92726c0fbc7b0d0794d Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Mon, 22 Apr 2013 10:28:31 +0530 Subject: Consolidate pthread_attr value validation Define inline functions that wrap around validation for each of the pthread attributes to reduce duplication in code. --- .../unix/sysv/linux/pthread_attr_setaffinity.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'nptl/sysdeps') diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c b/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c index 8b7a499f86..b4335c56e3 100644 --- a/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c +++ b/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c @@ -25,9 +25,6 @@ #include -/* Defined in pthread_setaffinity.c. */ -extern size_t __kernel_cpumask_size attribute_hidden; -extern int __determine_cpumask_size (pid_t tid); int @@ -47,21 +44,10 @@ __pthread_attr_setaffinity_new (pthread_attr_t *attr, size_t cpusetsize, } else { - if (__kernel_cpumask_size == 0) - { - int res = __determine_cpumask_size (THREAD_SELF->tid); - if (res != 0) - /* Some serious problem. */ - return res; - } + int ret = check_cpuset_attr (cpuset, cpusetsize); - /* Check whether the new bitmask has any bit set beyond the - last one the kernel accepts. */ - for (size_t cnt = __kernel_cpumask_size; cnt < cpusetsize; ++cnt) - if (((char *) cpuset)[cnt] != '\0') - /* Found a nonzero byte. This means the user request cannot be - fulfilled. */ - return EINVAL; + if (ret) + return ret; if (iattr->cpusetsize != cpusetsize) { -- cgit 1.4.1