Below is a small patch to plpa_dispatch.c to avoid verbose if-else
statements.
Brian
--- plpa_dispatch.c 2008-03-11 11:59:23.000000000 -0400
+++ plpa_dispatch.c 2008-03-12 23:05:56.000000000 -0400
@@ -110,17 +110,11 @@ int PLPA_NAME(sched_setaffinity)(pid_t p
memcpy(&tmp, cpuset, cpusetsize);
}
- /* Now do the syscall */
- ret = syscall(__NR_sched_setaffinity, pid, PLPA_NAME(len),
&tmp);
-
- /* Return 0 upon success. According to
+ /* Now do the syscall:
+ Return 0 upon success. According to
http://www.open-mpi.org/community/lists/plpa-users/
2006/02/0016.php,
all the kernel implementations return >= 0 upon success. */
- if (ret >= 0) {
- return 0;
- } else {
- return ret;
- }
+ return (ret = syscall(__NR_sched_setaffinity, pid, PLPA_NAME
(len), &tmp)) >= 0 ? 0 : ret;
break;
case PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED):
@@ -184,17 +178,11 @@ int PLPA_NAME(sched_getaffinity)(pid_t p
memset(cpuset, 0, cpusetsize);
}
- /* Now do the syscall */
- ret = syscall(__NR_sched_getaffinity, pid, PLPA_NAME(len),
cpuset);
-
- /* Return 0 upon success. According to
+ /* Now do the syscall:
+ Return 0 upon success. According to
http://www.open-mpi.org/community/lists/plpa-users/
2006/02/0016.php,
all the kernel implementations return >= 0 upon success. */
- if (ret >= 0) {
- return 0;
- } else {
- return ret;
- }
+ return (ret = syscall(__NR_sched_getaffinity, pid, PLPA_NAME
(len), cpuset)) >= 0 ? 0 : ret;
break;
case PLPA_NAME_CAPS(PROBE_NOT_SUPPORTED):
|