[rtems commit] Filesystem: Remove NULL pointer check

Sebastian Huber sebh at rtems.org
Mon Jul 9 08:39:11 UTC 2012


Module:    rtems
Branch:    master
Commit:    b22ff7827917318db640834ef3f7dee073302ed9
Changeset: http://git.rtems.org/rtems/commit/?id=b22ff7827917318db640834ef3f7dee073302ed9

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Apr 13 10:01:51 2012 +0200

Filesystem: Remove NULL pointer check

---

 cpukit/libfs/src/pipe/fifo.c       |   31 +++++++++++++++----------------
 testsuites/sptests/spfifo04/init.c |   12 +-----------
 2 files changed, 16 insertions(+), 27 deletions(-)

diff --git a/cpukit/libfs/src/pipe/fifo.c b/cpukit/libfs/src/pipe/fifo.c
index 31ccfc8..ca33f6a 100644
--- a/cpukit/libfs/src/pipe/fifo.c
+++ b/cpukit/libfs/src/pipe/fifo.c
@@ -622,24 +622,23 @@ int pipe_ioctl(
 {
   int rv = 0;
 
-  if (buffer != NULL) {
-    if (PIPE_LOCK(pipe)) {
-      switch (cmd) {
-        case RTEMS_IOCTL_SELECT:
-          rv = pipe_select(pipe, buffer);
-          break;
-        case FIONREAD:
-          /* Return length of pipe */
-          *(unsigned int *) buffer = pipe->Length;
-          break;
-      }
-
-      PIPE_UNLOCK(pipe);
-    } else {
-      rv = -EINTR;
+  if (PIPE_LOCK(pipe)) {
+    switch (cmd) {
+      case RTEMS_IOCTL_SELECT:
+        rv = pipe_select(pipe, buffer);
+        break;
+      case FIONREAD:
+        /* Return length of pipe */
+        *(unsigned int *) buffer = pipe->Length;
+        break;
+      default:
+        rv = -EINVAL;
+        break;
     }
+
+    PIPE_UNLOCK(pipe);
   } else {
-    rv = -EFAULT;
+    rv = -EINTR;
   }
 
   return rv;
diff --git a/testsuites/sptests/spfifo04/init.c b/testsuites/sptests/spfifo04/init.c
index 628d980..2a3ac46 100644
--- a/testsuites/sptests/spfifo04/init.c
+++ b/testsuites/sptests/spfifo04/init.c
@@ -52,11 +52,6 @@ rtems_task Init(
   rtems_test_assert( offset == -1 );
   rtems_test_assert( errno == ESPIPE );
 
-  puts( "Init - ioctl: FIONBIO -- Expected EFAULT" );
-  status = ioctl( fd, FIONBIO, NULL );
-  rtems_test_assert( status == -1 );
-  rtems_test_assert( errno == EFAULT );
-
   puts( "Init - ioctl: FIONBIO -- OK" );
   status = ioctl( fd, FIONBIO, &flag );
   rtems_test_assert( status == 0 );
@@ -67,15 +62,10 @@ rtems_task Init(
   rtems_test_assert( status == 0 );
 
   puts( "Init - ioctl: Dummy Command -- Expected EINVAL" );
-  status = ioctl( fd, -1, NULL );
+  status = ioctl( fd, -1 );
   rtems_test_assert( status == -1 );
   rtems_test_assert( errno == EINVAL );
 
-  puts( "Init - ioctl: FIONREAD -- Expected EFAULT" );
-  status = ioctl( fd, FIONREAD, NULL );
-  rtems_test_assert( status == -1 );
-  rtems_test_assert( errno == EFAULT );
-
   puts( "Init - ioctl: FIONREAD -- OK" );
   status = ioctl( fd, FIONREAD, &pipe_length );
   rtems_test_assert( status == 0 );




More information about the vc mailing list