diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-06-28 22:14:35 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-06-28 22:14:35 +0000 |
commit | 45fcb767c3d32d764053c8694825e3ac2da02e1c (patch) | |
tree | 238e6a6472ec35f18aaf54e5bae0a88af0da9e5d /cpukit/libcsupport/src | |
parent | 2010-06-28 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-45fcb767c3d32d764053c8694825e3ac2da02e1c.tar.bz2 |
2010-06-28 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/src/__brk.c, libcsupport/src/__gettod.c,
libcsupport/src/__times.c, libcsupport/src/fchdir.c,
libcsupport/src/ftrylockfile.c, libcsupport/src/getpwent.c,
libcsupport/src/gxx_wrappers.c, libcsupport/src/libio_sockets.c,
libcsupport/src/pipe.c: Use rtems_set_errno_and_return_minus_one()
where it was missed before.
Diffstat (limited to 'cpukit/libcsupport/src')
-rw-r--r-- | cpukit/libcsupport/src/__brk.c | 4 | ||||
-rw-r--r-- | cpukit/libcsupport/src/__gettod.c | 8 | ||||
-rw-r--r-- | cpukit/libcsupport/src/__times.c | 7 | ||||
-rw-r--r-- | cpukit/libcsupport/src/fchdir.c | 2 | ||||
-rw-r--r-- | cpukit/libcsupport/src/ftrylockfile.c | 4 | ||||
-rw-r--r-- | cpukit/libcsupport/src/getpwent.c | 47 | ||||
-rw-r--r-- | cpukit/libcsupport/src/gxx_wrappers.c | 2 | ||||
-rw-r--r-- | cpukit/libcsupport/src/libio_sockets.c | 7 | ||||
-rw-r--r-- | cpukit/libcsupport/src/pipe.c | 8 |
9 files changed, 41 insertions, 48 deletions
diff --git a/cpukit/libcsupport/src/__brk.c b/cpukit/libcsupport/src/__brk.c index 8cc630a827..1a358d14cd 100644 --- a/cpukit/libcsupport/src/__brk.c +++ b/cpukit/libcsupport/src/__brk.c @@ -20,12 +20,12 @@ #if defined(RTEMS_NEWLIB) && !defined(HAVE___BRK) #include <errno.h> +#include <rtems/seterr.h> int __brk( const void *endds __attribute__((unused)) ) { - errno = EINVAL; - return -1; + rtems_set_errno_and_return_minus_one( EINVAL ); } #endif diff --git a/cpukit/libcsupport/src/__gettod.c b/cpukit/libcsupport/src/__gettod.c index fdf6014799..05db4ab9d0 100644 --- a/cpukit/libcsupport/src/__gettod.c +++ b/cpukit/libcsupport/src/__gettod.c @@ -21,6 +21,7 @@ #include <sys/time.h> #include <errno.h> #include <rtems.h> +#include <rtems/seterr.h> #if defined(RTEMS_NEWLIB) && !defined(HAVE_GETTIMEOFDAY) /* @@ -32,16 +33,13 @@ int gettimeofday( ) { /* struct timezone* tzp = (struct timezone*) __tz; */ - if ( !tp ) { - errno = EFAULT; - return -1; - } + if ( !tp ) + rtems_set_errno_and_return_minus_one( EFAULT ); /* * POSIX does not seem to allow for not having a TOD so we just * grab the time of day. */ - _TOD_Get_timeval( tp ); /* diff --git a/cpukit/libcsupport/src/__times.c b/cpukit/libcsupport/src/__times.c index c14aa99395..f44142bede 100644 --- a/cpukit/libcsupport/src/__times.c +++ b/cpukit/libcsupport/src/__times.c @@ -22,6 +22,7 @@ #include <sys/time.h> #include <errno.h> #include <assert.h> +#include <rtems/seterr.h> #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ #include <rtems/score/timestamp.h> #endif @@ -32,10 +33,8 @@ clock_t _times( { rtems_interval ticks; - if ( !ptms ) { - errno = EFAULT; - return -1; - } + if ( !ptms ) + rtems_set_errno_and_return_minus_one( EFAULT ); /* * This call does not depend on TOD being initialized and can't fail. diff --git a/cpukit/libcsupport/src/fchdir.c b/cpukit/libcsupport/src/fchdir.c index 0f3cf9ebb3..6ff2ca12ee 100644 --- a/cpukit/libcsupport/src/fchdir.c +++ b/cpukit/libcsupport/src/fchdir.c @@ -79,7 +79,7 @@ int fchdir( if (rtems_filesystem_evaluate_path(".", 1, 0, &loc, 0)) { /* cloning failed; restore original and bail out */ rtems_filesystem_current = saved; - return -1; + return -1; } /* release the old one */ rtems_filesystem_freenode( &saved ); diff --git a/cpukit/libcsupport/src/ftrylockfile.c b/cpukit/libcsupport/src/ftrylockfile.c index cd21faeb05..924690e44f 100644 --- a/cpukit/libcsupport/src/ftrylockfile.c +++ b/cpukit/libcsupport/src/ftrylockfile.c @@ -13,11 +13,13 @@ #if defined(RTEMS_NEWLIB) && !defined(HAVE_FTRYLOCKFILE) && defined(HAVE_DECL_FTRYLOCKFILE) #include <stdio.h> +#include <rtems/seterr.h> +#include <errno.h> /* This is a non-functional stub */ int ftrylockfile(FILE* file) { - return -1; + rtems_set_errno_and_return_minus_one( ENOTSUP ); } #endif diff --git a/cpukit/libcsupport/src/getpwent.c b/cpukit/libcsupport/src/getpwent.c index a4b47e50fa..210f4bedd5 100644 --- a/cpukit/libcsupport/src/getpwent.c +++ b/cpukit/libcsupport/src/getpwent.c @@ -24,6 +24,7 @@ #include <ctype.h> #include <rtems/libio_.h> +#include <rtems/seterr.h> /* * Static, thread-unsafe, buffers @@ -188,31 +189,28 @@ static int getpw_r( init_etc_passwd_group(); - if ((fp = fopen("/etc/passwd", "r")) == NULL) { - errno = EINVAL; - return -1; - } + if ((fp = fopen("/etc/passwd", "r")) == NULL) + rtems_set_errno_and_return_minus_one( EINVAL ); + for(;;) { - if (!scanpw(fp, pwd, buffer, bufsize)) { - errno = EINVAL; - fclose(fp); - return -1; - } + if (!scanpw(fp, pwd, buffer, bufsize)) + goto error_einval; + if (name) { match = (strcmp(pwd->pw_name, name) == 0); - } - else { + } else { match = (pwd->pw_uid == uid); } + if (match) { fclose(fp); *result = pwd; return 0; } } +error_einval: fclose(fp); - errno = EINVAL; - return -1; + rtems_set_errno_and_return_minus_one( EINVAL ); } int getpwnam_r( @@ -347,31 +345,28 @@ static int getgr_r( init_etc_passwd_group(); - if ((fp = fopen("/etc/group", "r")) == NULL) { - errno = EINVAL; - return -1; - } + if ((fp = fopen("/etc/group", "r")) == NULL) + rtems_set_errno_and_return_minus_one( EINVAL ); + for(;;) { - if (!scangr(fp, grp, buffer, bufsize)) { - errno = EINVAL; - fclose(fp); - return -1; - } + if (!scangr(fp, grp, buffer, bufsize)) + goto error_einval; + if (name) { match = (strcmp(grp->gr_name, name) == 0); - } - else { + } else { match = (grp->gr_gid == gid); } + if (match) { fclose(fp); *result = grp; return 0; } } +error_einval: fclose(fp); - errno = EINVAL; - return -1; + rtems_set_errno_and_return_minus_one( EINVAL ); } int getgrnam_r( diff --git a/cpukit/libcsupport/src/gxx_wrappers.c b/cpukit/libcsupport/src/gxx_wrappers.c index 02cdb22904..102cf61855 100644 --- a/cpukit/libcsupport/src/gxx_wrappers.c +++ b/cpukit/libcsupport/src/gxx_wrappers.c @@ -105,7 +105,7 @@ int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *)) #endif /* register with RTEMS the buffer that will hold the key values */ if( rtems_task_variable_add( RTEMS_SELF, (void **)new_key, dtor ) == RTEMS_SUCCESSFUL ) - return 0; + return 0; return -1; } diff --git a/cpukit/libcsupport/src/libio_sockets.c b/cpukit/libcsupport/src/libio_sockets.c index db7562b4e9..a311c5fb0b 100644 --- a/cpukit/libcsupport/src/libio_sockets.c +++ b/cpukit/libcsupport/src/libio_sockets.c @@ -62,10 +62,9 @@ int rtems_bsdnet_makeFdForSocket( int fd; iop = rtems_libio_allocate(); - if (iop == 0) { - errno = ENFILE; - return -1; - } + if (iop == 0) + rtems_set_errno_and_return_minus_one( ENFILE ); + fd = iop - rtems_libio_iops; iop->flags |= LIBIO_FLAGS_WRITE | LIBIO_FLAGS_READ; iop->data0 = fd; diff --git a/cpukit/libcsupport/src/pipe.c b/cpukit/libcsupport/src/pipe.c index ef8c820483..13b2eb5dc6 100644 --- a/cpukit/libcsupport/src/pipe.c +++ b/cpukit/libcsupport/src/pipe.c @@ -17,6 +17,7 @@ #include <errno.h> #include <sys/types.h> +#include <rtems/seterr.h> extern int pipe_create(int filsdes[2]); @@ -24,9 +25,8 @@ int pipe( int filsdes[2] ) { - if (filsdes == NULL) { - errno = EFAULT; - return -1; - } + if (filsdes == NULL) + rtems_set_errno_and_return_minus_one( EFAULT ); + return pipe_create(filsdes); } |