core: refactor check for valid pid

move into header and remove redundant condition
dev/timer
Ludwig Ortmann 9 years ago
parent ecae75a1ab
commit 2fe2a39602

@ -67,6 +67,18 @@
*/
typedef int16_t kernel_pid_t;
/**
* @brief Determine if the given pid is valid
*
* @param[in] pid The pid to check
*
* @return true if the pid is valid, false otherwise
*/
static inline int pid_is_valid(kernel_pid_t pid)
{
return ((KERNEL_PID_FIRST <= pid) && (pid <= KERNEL_PID_LAST));
}
#ifdef __cplusplus
}
#endif

@ -34,7 +34,7 @@
volatile tcb_t *thread_get(kernel_pid_t pid)
{
if ((pid != KERNEL_PID_UNDEF) && (KERNEL_PID_FIRST <= pid) && (pid <= KERNEL_PID_LAST)) {
if (pid_is_valid(pid)) {
return sched_threads[pid];
}
return NULL;

Loading…
Cancel
Save