From 7b4520258d1d449bd14c83a6b6490be8375e4a35 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 13 Sep 2017 08:25:33 +0200 Subject: libio: Simplify rtems_libio_iop() Remove the file descriptor validation. This is the job of rtems_libio_check_fd(). Use an inline function instread of a macro. Update #3132. --- cpukit/libcsupport/include/rtems/libio_.h | 20 +++++++++++++------- cpukit/libcsupport/src/fstat.c | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h index c2fb975bf7..85f9c8e0a5 100644 --- a/cpukit/libcsupport/include/rtems/libio_.h +++ b/cpukit/libcsupport/include/rtems/libio_.h @@ -89,15 +89,21 @@ extern rtems_filesystem_mount_table_entry_t rtems_filesystem_null_mt_entry; */ extern rtems_filesystem_global_location_t rtems_filesystem_global_location_null; -/* - * rtems_libio_iop +/** + * @brief Maps a file descriptor to the iop. + * + * The file descriptor must be a valid index into the iop table. + * + * @param[in] fd The file descriptor. * - * Macro to return the file descriptor pointer. + * @return The iop corresponding to the specified file descriptor. + * + * @see rtems_libio_check_fd(). */ - -#define rtems_libio_iop(_fd) \ - ((((uint32_t)(_fd)) < rtems_libio_number_iops) ? \ - &rtems_libio_iops[_fd] : 0) +static inline rtems_libio_t *rtems_libio_iop( int fd ) +{ + return &rtems_libio_iops[ fd ]; +} /* * rtems_libio_iop_to_descriptor diff --git a/cpukit/libcsupport/src/fstat.c b/cpukit/libcsupport/src/fstat.c index 8b39c438f4..4c284bd408 100644 --- a/cpukit/libcsupport/src/fstat.c +++ b/cpukit/libcsupport/src/fstat.c @@ -36,8 +36,8 @@ int fstat( /* * Now process the stat() request. */ - iop = rtems_libio_iop( fd ); rtems_libio_check_fd( fd ); + iop = rtems_libio_iop( fd ); rtems_libio_check_is_open(iop); /* -- cgit v1.2.3