mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 15:15:44 +00:00
changed code which set errno and then returned -1 to use the macro
set_errno_and_return_minus_one.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/watchdog.h>
|
||||
#include <rtems/posix/seterr.h>
|
||||
#include <rtems/posix/mqueue.h>
|
||||
#include <rtems/posix/time.h>
|
||||
|
||||
@@ -76,8 +77,7 @@ int _POSIX_Message_queue_Create_support(
|
||||
|
||||
if ( !the_mq ) {
|
||||
_Thread_Enable_dispatch();
|
||||
seterrno( ENFILE );
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENFILE );
|
||||
}
|
||||
|
||||
if ( pshared == PTHREAD_PROCESS_SHARED &&
|
||||
@@ -85,8 +85,7 @@ int _POSIX_Message_queue_Create_support(
|
||||
the_mq->Object.id, FALSE ) ) ) {
|
||||
_POSIX_Message_queue_Free( the_mq );
|
||||
_Thread_Enable_dispatch();
|
||||
seterrno( ENFILE );
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENFILE );
|
||||
}
|
||||
|
||||
the_mq->process_shared = pshared;
|
||||
@@ -134,8 +133,7 @@ int _POSIX_Message_queue_Create_support(
|
||||
|
||||
_POSIX_Message_queue_Free( the_mq );
|
||||
_Thread_Enable_dispatch();
|
||||
seterrno( ENOSPC );
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSPC );
|
||||
}
|
||||
|
||||
|
||||
@@ -323,10 +321,8 @@ int mq_unlink(
|
||||
|
||||
status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
|
||||
|
||||
if ( !status ) {
|
||||
seterrno( status );
|
||||
return -1;
|
||||
}
|
||||
if ( !status )
|
||||
set_errno_and_return_minus_one( status );
|
||||
|
||||
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
|
||||
switch ( location ) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/tod.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/posix/seterr.h>
|
||||
#include <rtems/posix/priority.h>
|
||||
#include <rtems/posix/time.h>
|
||||
|
||||
@@ -23,8 +24,7 @@ int sched_setparam(
|
||||
const struct sched_param *param
|
||||
)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSYS );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -37,8 +37,7 @@ int sched_getparam(
|
||||
const struct sched_param *param
|
||||
)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSYS );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -53,8 +52,7 @@ int sched_setscheduler(
|
||||
const struct sched_param *param
|
||||
)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSYS );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -66,8 +64,7 @@ int sched_getscheduler(
|
||||
pid_t pid
|
||||
)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSYS );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -87,8 +84,7 @@ int sched_get_priority_max(
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
|
||||
return POSIX_SCHEDULER_MAXIMUM_PRIORITY;
|
||||
@@ -111,8 +107,7 @@ int sched_get_priority_min(
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
|
||||
return POSIX_SCHEDULER_MINIMUM_PRIORITY;
|
||||
|
||||
@@ -64,8 +64,7 @@ int _POSIX_Semaphore_Create_support(
|
||||
|
||||
if ( !the_semaphore ) {
|
||||
_Thread_Enable_dispatch();
|
||||
seterrno( ENOMEM );
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOMEM );
|
||||
}
|
||||
|
||||
if ( pshared == PTHREAD_PROCESS_SHARED &&
|
||||
@@ -73,8 +72,7 @@ int _POSIX_Semaphore_Create_support(
|
||||
the_semaphore->Object.id, FALSE ) ) ) {
|
||||
_POSIX_Semaphore_Free( the_semaphore );
|
||||
_Thread_Enable_dispatch();
|
||||
seterrno( EAGAIN );
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( EAGAIN );
|
||||
}
|
||||
|
||||
the_semaphore->process_shared = pshared;
|
||||
@@ -382,10 +380,8 @@ int sem_unlink(
|
||||
|
||||
status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
|
||||
|
||||
if ( !status ) {
|
||||
seterrno( status );
|
||||
return -1;
|
||||
}
|
||||
if ( !status )
|
||||
set_errno_and_return_minus_one( status );
|
||||
|
||||
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
|
||||
switch ( location ) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/tod.h>
|
||||
|
||||
#include <rtems/posix/seterr.h>
|
||||
#include <rtems/posix/time.h>
|
||||
|
||||
/*PAGE
|
||||
@@ -63,10 +64,8 @@ time_t time(
|
||||
{
|
||||
time_t seconds_since_epoch;
|
||||
|
||||
if ( !_TOD_Is_set() ) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if ( !_TOD_Is_set() )
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
/*
|
||||
* Internally the RTEMS epoch is 1988. This must be taken into account.
|
||||
@@ -118,10 +117,8 @@ int clock_settime(
|
||||
tod.ticks = (tp->tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND) /
|
||||
_TOD_Microseconds_per_tick;
|
||||
|
||||
if ( !_TOD_Validate( &tod ) ) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if ( !_TOD_Validate( &tod ) )
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
/*
|
||||
* We can't use the tp->tv_sec field because it is based on
|
||||
@@ -146,8 +143,7 @@ int clock_settime(
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
}
|
||||
return 0;
|
||||
@@ -171,10 +167,8 @@ int clock_gettime(
|
||||
switch ( clock_id ) {
|
||||
|
||||
case CLOCK_REALTIME:
|
||||
if ( !_TOD_Is_set() ) { /* XXX does posix allow it to not be set? */
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if ( !_TOD_Is_set() ) /* XXX does posix allow it to not be set? */
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
_ISR_Disable( level );
|
||||
seconds = _TOD_Seconds_since_epoch;
|
||||
@@ -199,8 +193,7 @@ int clock_gettime(
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
}
|
||||
return 0;
|
||||
@@ -229,8 +222,7 @@ int clock_getres(
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
}
|
||||
return 0;
|
||||
@@ -247,10 +239,8 @@ int nanosleep(
|
||||
{
|
||||
Watchdog_Interval ticks;
|
||||
|
||||
if ( rqtp->tv_nsec < 0 || rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if ( rqtp->tv_nsec < 0 || rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND )
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
/* XXX this is interruptible by a posix signal */
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/posix/seterr.h>
|
||||
|
||||
pid_t _POSIX_types_Ppid = 0;
|
||||
uid_t _POSIX_types_Uid = 0;
|
||||
@@ -175,8 +176,7 @@ pid_t getpgrp( void )
|
||||
|
||||
pid_t setsid( void )
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSYS );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -189,8 +189,7 @@ int setpgid(
|
||||
pid_t pgid
|
||||
)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSYS );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/watchdog.h>
|
||||
#include <rtems/posix/seterr.h>
|
||||
#include <rtems/posix/mqueue.h>
|
||||
#include <rtems/posix/time.h>
|
||||
|
||||
@@ -76,8 +77,7 @@ int _POSIX_Message_queue_Create_support(
|
||||
|
||||
if ( !the_mq ) {
|
||||
_Thread_Enable_dispatch();
|
||||
seterrno( ENFILE );
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENFILE );
|
||||
}
|
||||
|
||||
if ( pshared == PTHREAD_PROCESS_SHARED &&
|
||||
@@ -85,8 +85,7 @@ int _POSIX_Message_queue_Create_support(
|
||||
the_mq->Object.id, FALSE ) ) ) {
|
||||
_POSIX_Message_queue_Free( the_mq );
|
||||
_Thread_Enable_dispatch();
|
||||
seterrno( ENFILE );
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENFILE );
|
||||
}
|
||||
|
||||
the_mq->process_shared = pshared;
|
||||
@@ -134,8 +133,7 @@ int _POSIX_Message_queue_Create_support(
|
||||
|
||||
_POSIX_Message_queue_Free( the_mq );
|
||||
_Thread_Enable_dispatch();
|
||||
seterrno( ENOSPC );
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSPC );
|
||||
}
|
||||
|
||||
|
||||
@@ -323,10 +321,8 @@ int mq_unlink(
|
||||
|
||||
status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
|
||||
|
||||
if ( !status ) {
|
||||
seterrno( status );
|
||||
return -1;
|
||||
}
|
||||
if ( !status )
|
||||
set_errno_and_return_minus_one( status );
|
||||
|
||||
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
|
||||
switch ( location ) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/tod.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/posix/seterr.h>
|
||||
#include <rtems/posix/priority.h>
|
||||
#include <rtems/posix/time.h>
|
||||
|
||||
@@ -23,8 +24,7 @@ int sched_setparam(
|
||||
const struct sched_param *param
|
||||
)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSYS );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -37,8 +37,7 @@ int sched_getparam(
|
||||
const struct sched_param *param
|
||||
)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSYS );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -53,8 +52,7 @@ int sched_setscheduler(
|
||||
const struct sched_param *param
|
||||
)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSYS );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -66,8 +64,7 @@ int sched_getscheduler(
|
||||
pid_t pid
|
||||
)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSYS );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -87,8 +84,7 @@ int sched_get_priority_max(
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
|
||||
return POSIX_SCHEDULER_MAXIMUM_PRIORITY;
|
||||
@@ -111,8 +107,7 @@ int sched_get_priority_min(
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
|
||||
return POSIX_SCHEDULER_MINIMUM_PRIORITY;
|
||||
|
||||
@@ -64,8 +64,7 @@ int _POSIX_Semaphore_Create_support(
|
||||
|
||||
if ( !the_semaphore ) {
|
||||
_Thread_Enable_dispatch();
|
||||
seterrno( ENOMEM );
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOMEM );
|
||||
}
|
||||
|
||||
if ( pshared == PTHREAD_PROCESS_SHARED &&
|
||||
@@ -73,8 +72,7 @@ int _POSIX_Semaphore_Create_support(
|
||||
the_semaphore->Object.id, FALSE ) ) ) {
|
||||
_POSIX_Semaphore_Free( the_semaphore );
|
||||
_Thread_Enable_dispatch();
|
||||
seterrno( EAGAIN );
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( EAGAIN );
|
||||
}
|
||||
|
||||
the_semaphore->process_shared = pshared;
|
||||
@@ -382,10 +380,8 @@ int sem_unlink(
|
||||
|
||||
status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
|
||||
|
||||
if ( !status ) {
|
||||
seterrno( status );
|
||||
return -1;
|
||||
}
|
||||
if ( !status )
|
||||
set_errno_and_return_minus_one( status );
|
||||
|
||||
the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
|
||||
switch ( location ) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/tod.h>
|
||||
|
||||
#include <rtems/posix/seterr.h>
|
||||
#include <rtems/posix/time.h>
|
||||
|
||||
/*PAGE
|
||||
@@ -63,10 +64,8 @@ time_t time(
|
||||
{
|
||||
time_t seconds_since_epoch;
|
||||
|
||||
if ( !_TOD_Is_set() ) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if ( !_TOD_Is_set() )
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
/*
|
||||
* Internally the RTEMS epoch is 1988. This must be taken into account.
|
||||
@@ -118,10 +117,8 @@ int clock_settime(
|
||||
tod.ticks = (tp->tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND) /
|
||||
_TOD_Microseconds_per_tick;
|
||||
|
||||
if ( !_TOD_Validate( &tod ) ) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if ( !_TOD_Validate( &tod ) )
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
/*
|
||||
* We can't use the tp->tv_sec field because it is based on
|
||||
@@ -146,8 +143,7 @@ int clock_settime(
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
}
|
||||
return 0;
|
||||
@@ -171,10 +167,8 @@ int clock_gettime(
|
||||
switch ( clock_id ) {
|
||||
|
||||
case CLOCK_REALTIME:
|
||||
if ( !_TOD_Is_set() ) { /* XXX does posix allow it to not be set? */
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if ( !_TOD_Is_set() ) /* XXX does posix allow it to not be set? */
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
_ISR_Disable( level );
|
||||
seconds = _TOD_Seconds_since_epoch;
|
||||
@@ -199,8 +193,7 @@ int clock_gettime(
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
}
|
||||
return 0;
|
||||
@@ -229,8 +222,7 @@ int clock_getres(
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
}
|
||||
return 0;
|
||||
@@ -247,10 +239,8 @@ int nanosleep(
|
||||
{
|
||||
Watchdog_Interval ticks;
|
||||
|
||||
if ( rqtp->tv_nsec < 0 || rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if ( rqtp->tv_nsec < 0 || rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND )
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
/* XXX this is interruptible by a posix signal */
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/posix/seterr.h>
|
||||
|
||||
pid_t _POSIX_types_Ppid = 0;
|
||||
uid_t _POSIX_types_Uid = 0;
|
||||
@@ -175,8 +176,7 @@ pid_t getpgrp( void )
|
||||
|
||||
pid_t setsid( void )
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSYS );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -189,8 +189,7 @@ int setpgid(
|
||||
pid_t pgid
|
||||
)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
set_errno_and_return_minus_one( ENOSYS );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user