Fix a test for valid scheduling policies

This commit is contained in:
Gregory Nutt
2015-07-24 10:20:22 -06:00
parent 4490744def
commit c6c424583d
3 changed files with 10 additions and 50 deletions
+8 -24
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* libc/pthread/pthread_attrsetschedpolicy.c * libc/pthread/pthread_attrsetschedpolicy.c
* *
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2011, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -45,26 +45,6 @@
#include <debug.h> #include <debug.h>
#include <errno.h> #include <errno.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Type Declarations
****************************************************************************/
/****************************************************************************
* Global Variables
****************************************************************************/
/****************************************************************************
* Private Variables
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -92,11 +72,15 @@ int pthread_attr_setschedpolicy(FAR pthread_attr_t *attr, int policy)
sdbg("attr=0x%p policy=%d\n", attr, policy); sdbg("attr=0x%p policy=%d\n", attr, policy);
if (!attr ||
(policy != SCHED_FIFO
#if CONFIG_RR_INTERVAL > 0 #if CONFIG_RR_INTERVAL > 0
if (!attr || (policy != SCHED_FIFO && policy != SCHED_RR)) && policy != SCHED_RR
#else
if (!attr || policy != SCHED_FIFO )
#endif #endif
#ifdef CONFIG_SCHED_SPORADIC
&& policy != SCHED_SPORADIC
#endif
))
{ {
ret = EINVAL; ret = EINVAL;
} }
+1 -25
View File
@@ -48,30 +48,6 @@
#include "sched/sched.h" #include "sched/sched.h"
#include "clock/clock.h" #include "clock/clock.h"
/************************************************************************
* Pre-processor Definitions
************************************************************************/
/************************************************************************
* Private Type Declarations
************************************************************************/
/************************************************************************
* Global Variables
************************************************************************/
/************************************************************************
* Private Variables
************************************************************************/
/************************************************************************
* Private Function Prototypes
************************************************************************/
/************************************************************************
* Private Functions
************************************************************************/
/************************************************************************ /************************************************************************
* Public Functions * Public Functions
************************************************************************/ ************************************************************************/
@@ -126,7 +102,7 @@ int sched_rr_get_interval(pid_t pid, struct timespec *interval)
return ERROR; return ERROR;
} }
/* Otherwise, lookup the TCB associated with this pid */ /* Otherwise, lookup the TCB associated with this PID */
else else
{ {