summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-13 08:25:33 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-14 07:02:29 +0200
commit7b4520258d1d449bd14c83a6b6490be8375e4a35 (patch)
treeddd172091250daebee6de889557ae844c2499860
parent5eb67f3ad04ee1cbacc38b474397a620d3064e1c (diff)
downloadrtems-7b4520258d1d449bd14c83a6b6490be8375e4a35.tar.bz2
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.
-rw-r--r--cpukit/libcsupport/include/rtems/libio_.h20
-rw-r--r--cpukit/libcsupport/src/fstat.c2
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);
/*