From b0c533ed376fe69068ab63396eca17de3bbbeab7 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 28 Aug 2014 17:00:24 -0600 Subject: nuttx/sched: Remove explicit references to errno. That is a problem from within the kernel for certain configurations --- nuttx/sched/clock/clock_gettimeofday.c | 2 +- nuttx/sched/environ/env_putenv.c | 2 +- nuttx/sched/environ/env_setenv.c | 2 +- nuttx/sched/errno/Make.defs | 2 +- nuttx/sched/pthread/pthread_setschedprio.c | 5 +++-- nuttx/sched/sched/sched_setparam.c | 4 ++-- nuttx/sched/sched/sched_setpriority.c | 2 +- nuttx/sched/sched/sched_setscheduler.c | 4 ++-- nuttx/sched/semaphore/sem_destroy.c | 2 +- nuttx/sched/task/task_posixspawn.c | 4 ++-- nuttx/sched/task/task_spawn.c | 4 ++-- nuttx/sched/task/task_spawnparms.c | 8 ++++---- nuttx/sched/timer/timer_create.c | 6 +++--- nuttx/sched/timer/timer_getoverrun.c | 2 +- nuttx/sched/timer/timer_settime.c | 2 +- 15 files changed, 26 insertions(+), 25 deletions(-) (limited to 'nuttx') diff --git a/nuttx/sched/clock/clock_gettimeofday.c b/nuttx/sched/clock/clock_gettimeofday.c index 46db6e698..22a58d052 100644 --- a/nuttx/sched/clock/clock_gettimeofday.c +++ b/nuttx/sched/clock/clock_gettimeofday.c @@ -93,7 +93,7 @@ int gettimeofday(struct timeval *tp, void *tzp) #ifdef CONFIG_DEBUG if (!tp) { - errno = EINVAL; + set_errno(EINVAL); return ERROR; } #endif diff --git a/nuttx/sched/environ/env_putenv.c b/nuttx/sched/environ/env_putenv.c index 74120f7af..e0a69bf93 100644 --- a/nuttx/sched/environ/env_putenv.c +++ b/nuttx/sched/environ/env_putenv.c @@ -113,7 +113,7 @@ int putenv(FAR const char *string) return ret; errout: - errno = ret; + set_errno(ret); return ERROR; } diff --git a/nuttx/sched/environ/env_setenv.c b/nuttx/sched/environ/env_setenv.c index c00efb304..e78cc8c89 100644 --- a/nuttx/sched/environ/env_setenv.c +++ b/nuttx/sched/environ/env_setenv.c @@ -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; } diff --git a/nuttx/sched/errno/Make.defs b/nuttx/sched/errno/Make.defs index 481b39812..b96d49bee 100644 --- a/nuttx/sched/errno/Make.defs +++ b/nuttx/sched/errno/Make.defs @@ -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 diff --git a/nuttx/sched/pthread/pthread_setschedprio.c b/nuttx/sched/pthread/pthread_setschedprio.c index 4d8c6c731..ff0536b3a 100644 --- a/nuttx/sched/pthread/pthread_setschedprio.c +++ b/nuttx/sched/pthread/pthread_setschedprio.c @@ -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 */ @@ -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; } diff --git a/nuttx/sched/sched/sched_setparam.c b/nuttx/sched/sched/sched_setparam.c index 2d954a23b..74da23035 100644 --- a/nuttx/sched/sched/sched_setparam.c +++ b/nuttx/sched/sched/sched_setparam.c @@ -115,7 +115,7 @@ int sched_setparam(pid_t pid, const struct sched_param *param) if (!param) { - errno = EINVAL; + set_errno(EINVAL); return ERROR; } @@ -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; } diff --git a/nuttx/sched/sched/sched_setpriority.c b/nuttx/sched/sched/sched_setpriority.c index ab2b0ec8e..177148a3a 100644 --- a/nuttx/sched/sched/sched_setpriority.c +++ b/nuttx/sched/sched/sched_setpriority.c @@ -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; } diff --git a/nuttx/sched/sched/sched_setscheduler.c b/nuttx/sched/sched/sched_setscheduler.c index 62aa9cac2..d70e24f70 100644 --- a/nuttx/sched/sched/sched_setscheduler.c +++ b/nuttx/sched/sched/sched_setscheduler.c @@ -122,7 +122,7 @@ int sched_setscheduler(pid_t pid, int policy, if (policy != SCHED_FIFO) #endif { - errno = EINVAL; + set_errno(EINVAL); return ERROR; } @@ -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; } diff --git a/nuttx/sched/semaphore/sem_destroy.c b/nuttx/sched/semaphore/sem_destroy.c index 790fe3ee4..c4b0fc216 100644 --- a/nuttx/sched/semaphore/sem_destroy.c +++ b/nuttx/sched/semaphore/sem_destroy.c @@ -120,7 +120,7 @@ int sem_destroy (FAR sem_t *sem) } else { - errno = -EINVAL; + set_errno(EINVAL); return ERROR; } } diff --git a/nuttx/sched/task/task_posixspawn.c b/nuttx/sched/task/task_posixspawn.c index 2973cb544..5a831b95a 100644 --- a/nuttx/sched/task/task_posixspawn.c +++ b/nuttx/sched/task/task_posixspawn.c @@ -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; } @@ -403,7 +403,7 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, ret = sched_getparam(0, ¶m); if (ret < 0) { - int errcode = errno; + int errcode = get_errno(); sdbg("ERROR: sched_getparam failed: %d\n", errcode); spawn_semgive(&g_spawn_parmsem); diff --git a/nuttx/sched/task/task_spawn.c b/nuttx/sched/task/task_spawn.c index bc0eef13f..2f556120f 100644 --- a/nuttx/sched/task/task_spawn.c +++ b/nuttx/sched/task/task_spawn.c @@ -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; } @@ -395,7 +395,7 @@ int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry, ret = sched_getparam(0, ¶m); if (ret < 0) { - int errcode = errno; + int errcode = get_errno(); sdbg("ERROR: sched_getparam failed: %d\n", errcode); spawn_semgive(&g_spawn_parmsem); diff --git a/nuttx/sched/task/task_spawnparms.c b/nuttx/sched/task/task_spawnparms.c index 7a8cad6c4..20a02d083 100644 --- a/nuttx/sched/task/task_spawnparms.c +++ b/nuttx/sched/task/task_spawnparms.c @@ -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; @@ -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); } @@ -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); } @@ -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); } diff --git a/nuttx/sched/timer/timer_create.c b/nuttx/sched/timer/timer_create.c index 71a83546f..3c1a4c1d3 100644 --- a/nuttx/sched/timer/timer_create.c +++ b/nuttx/sched/timer/timer_create.c @@ -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; } @@ -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; } @@ -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; } diff --git a/nuttx/sched/timer/timer_getoverrun.c b/nuttx/sched/timer/timer_getoverrun.c index aa8eab3aa..c0a34c33a 100644 --- a/nuttx/sched/timer/timer_getoverrun.c +++ b/nuttx/sched/timer/timer_getoverrun.c @@ -104,7 +104,7 @@ int timer_getoverrun(timer_t timerid) { - errno = ENOSYS; + set_errno(ENOSYS); return ERROR; } diff --git a/nuttx/sched/timer/timer_settime.c b/nuttx/sched/timer/timer_settime.c index 716d05caf..1039a1fa7 100644 --- a/nuttx/sched/timer/timer_settime.c +++ b/nuttx/sched/timer/timer_settime.c @@ -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; } -- cgit v1.2.3