Skip to content

Commit

Permalink
nuttx/sched: Remove explicit references to errno. That is a problem f…
Browse files Browse the repository at this point in the history
…rom within the kernel for certain configurations
  • Loading branch information
gregory-nutt committed Aug 28, 2014
1 parent 9ab67dc commit 0ab1b0d
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion sched/clock/clock_gettimeofday.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int gettimeofday(struct timeval *tp, void *tzp)
#ifdef CONFIG_DEBUG
if (!tp)
{
errno = EINVAL;
set_errno(EINVAL);
return ERROR;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion sched/environ/env_putenv.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ int putenv(FAR const char *string)
return ret;

errout:
errno = ret;
set_errno(ret);
return ERROR;
}

Expand Down
2 changes: 1 addition & 1 deletion sched/environ/env_setenv.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ int setenv(FAR const char *name, FAR const char *value, int overwrite)
errout_with_lock:
sched_unlock();
errout:
errno = ret;
set_errno(ret);
return ERROR;
}

Expand Down
2 changes: 1 addition & 1 deletion sched/errno/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

ERRNO_SRCS = errno_getptr.c

ifeq ($(CONFIG_NUTTX_KERNEL),y)
ifeq ($(CONFIG_LIB_SYSCALL),y)
ERRNO_SRCS += errno_get.c errno_set.c
endif

Expand Down
5 changes: 3 additions & 2 deletions sched/pthread/pthread_setschedprio.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int pthread_setschedprio(pthread_t thread, int prio)

/* Set the errno to some non-zero value (failsafe) */

errno = EINVAL;
set_errno(EINVAL);

/* Call sched_setparam() to change the priority */

Expand All @@ -114,7 +114,8 @@ int pthread_setschedprio(pthread_t thread, int prio)
{
/* If sched_setparam() fails, return the errno */

ret = errno;
ret = get_errno();
}

return ret;
}
4 changes: 2 additions & 2 deletions sched/sched/sched_setparam.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int sched_setparam(pid_t pid, const struct sched_param *param)

if (!param)
{
errno = EINVAL;
set_errno(EINVAL);
return ERROR;
}

Expand All @@ -142,7 +142,7 @@ int sched_setparam(pid_t pid, const struct sched_param *param)
{
/* No task with this pid was found */

errno = ESRCH;
set_errno(ESRCH);
sched_unlock();
return ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion sched/sched/sched_setpriority.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int sched_setpriority(FAR struct tcb_s *tcb, int sched_priority)
if (sched_priority < SCHED_PRIORITY_MIN ||
sched_priority > SCHED_PRIORITY_MAX)
{
errno = EINVAL;
set_errno(EINVAL);
return ERROR;
}

Expand Down
4 changes: 2 additions & 2 deletions sched/sched/sched_setscheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ int sched_setscheduler(pid_t pid, int policy,
if (policy != SCHED_FIFO)
#endif
{
errno = EINVAL;
set_errno(EINVAL);
return ERROR;
}

Expand All @@ -138,7 +138,7 @@ int sched_setscheduler(pid_t pid, int policy,
tcb = sched_gettcb(pid);
if (!tcb)
{
errno = ESRCH;
set_errno(ESRCH);
return ERROR;
}

Expand Down
2 changes: 1 addition & 1 deletion sched/semaphore/sem_destroy.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int sem_destroy (FAR sem_t *sem)
}
else
{
errno = -EINVAL;
set_errno(EINVAL);
return ERROR;
}
}
4 changes: 2 additions & 2 deletions sched/task/task_posixspawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static int posix_spawn_exec(FAR pid_t *pidp, FAR const char *path,
pid = exec(path, (FAR char * const *)argv, symtab, nsymbols);
if (pid < 0)
{
ret = errno;
ret = get_errno();
sdbg("ERROR: exec failed: %d\n", ret);
goto errout;
}
Expand Down Expand Up @@ -403,7 +403,7 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path,
ret = sched_getparam(0, &param);
if (ret < 0)
{
int errcode = errno;
int errcode = get_errno();

sdbg("ERROR: sched_getparam failed: %d\n", errcode);
spawn_semgive(&g_spawn_parmsem);
Expand Down
4 changes: 2 additions & 2 deletions sched/task/task_spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static int task_spawn_exec(FAR pid_t *pidp, FAR const char *name,
pid = TASK_CREATE(name, priority, stacksize, entry, argv);
if (pid < 0)
{
ret = errno;
ret = get_errno();
sdbg("ERROR: TASK_CREATE failed: %d\n", ret);
goto errout;
}
Expand Down Expand Up @@ -395,7 +395,7 @@ int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry,
ret = sched_getparam(0, &param);
if (ret < 0)
{
int errcode = errno;
int errcode = get_errno();

sdbg("ERROR: sched_getparam failed: %d\n", errcode);
spawn_semgive(&g_spawn_parmsem);
Expand Down
8 changes: 4 additions & 4 deletions sched/task/task_spawnparms.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static inline int spawn_dup2(FAR struct spawn_dup2_file_action_s *action)
ret = dup2(action->fd1, action->fd2);
if (ret < 0)
{
int errcode = errno;
int errcode = get_errno();

sdbg("ERROR: dup2 failed: %d\n", errcode);
return errcode;
Expand All @@ -130,7 +130,7 @@ static inline int spawn_open(FAR struct spawn_open_file_action_s *action)
fd = open(action->path, action->oflags, action->mode);
if (fd < 0)
{
ret = errno;
ret = get_errno();
sdbg("ERROR: open failed: %d\n", ret);
}

Expand All @@ -147,7 +147,7 @@ static inline int spawn_open(FAR struct spawn_open_file_action_s *action)
ret = dup2(fd, action->fd);
if (ret < 0)
{
ret = errno;
ret = get_errno();
sdbg("ERROR: dup2 failed: %d\n", ret);
}

Expand Down Expand Up @@ -184,7 +184,7 @@ void spawn_semtake(FAR sem_t *sem)
do
{
ret = sem_wait(sem);
ASSERT(ret == 0 || errno == EINTR);
ASSERT(ret == 0 || get_errno() == EINTR);
}
while (ret != 0);
}
Expand Down
6 changes: 3 additions & 3 deletions sched/timer/timer_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp, FAR timer_t *timer

if (!timerid || clockid != CLOCK_REALTIME)
{
errno = EINVAL;
set_errno(EINVAL);
return ERROR;
}

Expand All @@ -193,7 +193,7 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp, FAR timer_t *timer
wdog = wd_create();
if (!wdog)
{
errno = EAGAIN;
set_errno(EAGAIN);
return ERROR;
}

Expand All @@ -202,7 +202,7 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp, FAR timer_t *timer
ret = timer_allocate();
if (!ret)
{
errno = EAGAIN;
set_errno(EAGAIN);
return ERROR;
}

Expand Down
2 changes: 1 addition & 1 deletion sched/timer/timer_getoverrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@

int timer_getoverrun(timer_t timerid)
{
errno = ENOSYS;
set_errno(ENOSYS);
return ERROR;
}

Expand Down
2 changes: 1 addition & 1 deletion sched/timer/timer_settime.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ int timer_settime(timer_t timerid, int flags, FAR const struct itimerspec *value

if (!timer || !value)
{
errno = EINVAL;
set_errno(EINVAL);
return ERROR;
}

Expand Down

0 comments on commit 0ab1b0d

Please sign in to comment.