[PATCH 3/4] Filesystem: Use rtems_libio_iop_to_descriptor()

Joel Sherrill joel.sherrill at oarcorp.com
Mon Feb 2 14:37:42 UTC 2015


On 2/2/2015 8:25 AM, Sebastian Huber wrote:
> Drop parameter check from previously unused
> rtems_libio_iop_to_descriptor().
> ---
>  cpukit/libcsupport/include/rtems/libio_.h  | 2 +-
>  cpukit/libcsupport/src/fcntl.c             | 2 +-
>  cpukit/libcsupport/src/open.c              | 2 +-
>  cpukit/libnetworking/rtems/rtems_syscall.c | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h
> index d021c1b..1300d39 100644
> --- a/cpukit/libcsupport/include/rtems/libio_.h
> +++ b/cpukit/libcsupport/include/rtems/libio_.h
> @@ -107,7 +107,7 @@ extern rtems_filesystem_global_location_t rtems_filesystem_global_location_null;
>   */
>  
>  #define rtems_libio_iop_to_descriptor(_iop) \
> -   ((!(_iop)) ? -1 : (_iop - rtems_libio_iops))
> +  ((_iop) - &rtems_libio_iops[0])
You dropped a NULL check. What is the rationale? Should it be
a debug assert?
>  
>  /*
>   *  rtems_libio_check_is_open
> diff --git a/cpukit/libcsupport/src/fcntl.c b/cpukit/libcsupport/src/fcntl.c
> index 5a10f91..ddaf447 100644
> --- a/cpukit/libcsupport/src/fcntl.c
> +++ b/cpukit/libcsupport/src/fcntl.c
> @@ -47,7 +47,7 @@ static int duplicate_iop( rtems_libio_t *iop )
>       */
>      rv = (*diop->pathinfo.handlers->open_h)( diop, NULL, oflag, 0 );
>      if ( rv == 0 ) {
> -      rv = diop - rtems_libio_iops;
> +      rv = rtems_libio_iop_to_descriptor( diop );
>      } else {
>        rtems_libio_free( diop );
>      }
> diff --git a/cpukit/libcsupport/src/open.c b/cpukit/libcsupport/src/open.c
> index 399b5a4..4fb2ea2 100644
> --- a/cpukit/libcsupport/src/open.c
> +++ b/cpukit/libcsupport/src/open.c
> @@ -66,7 +66,7 @@ static int do_open(
>  )
>  {
>    int rv = 0;
> -  int fd = iop - rtems_libio_iops;
> +  int fd = rtems_libio_iop_to_descriptor( iop );
>    int rwflag = oflag + 1;
>    bool read_access = (rwflag & _FREAD) == _FREAD;
>    bool write_access = (rwflag & _FWRITE) == _FWRITE;
> diff --git a/cpukit/libnetworking/rtems/rtems_syscall.c b/cpukit/libnetworking/rtems/rtems_syscall.c
> index 1063798..c0dccf6 100644
> --- a/cpukit/libnetworking/rtems/rtems_syscall.c
> +++ b/cpukit/libnetworking/rtems/rtems_syscall.c
> @@ -83,7 +83,7 @@ rtems_bsdnet_makeFdForSocket (void *so)
>    if (iop == 0)
>        rtems_set_errno_and_return_minus_one( ENFILE );
>  
> -  fd = iop - rtems_libio_iops;
> +  fd = rtems_libio_iop_to_descriptor(iop);
>    iop->flags |= LIBIO_FLAGS_WRITE | LIBIO_FLAGS_READ;
>    iop->data0 = fd;
>    iop->data1 = so;

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985




More information about the devel mailing list