[PATCH] sparse-disk: check return value from semaphore_obtain/release

Gedare Bloom gedare at rtems.org
Thu Sep 5 18:22:31 UTC 2013


In case obtain/release is unsuccessful, cause a fatal error.
---
 cpukit/libblock/src/sparse-disk.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/cpukit/libblock/src/sparse-disk.c b/cpukit/libblock/src/sparse-disk.c
index 987ab6d..ab6a25d 100644
--- a/cpukit/libblock/src/sparse-disk.c
+++ b/cpukit/libblock/src/sparse-disk.c
@@ -236,8 +236,12 @@ static int sparse_disk_read_write(
   uint8_t                *buff;
   size_t                  buff_size;
   unsigned int            bytes_handled;
+  rtems_status_code       sc;
 
-  rtems_semaphore_obtain( sparse_disk->mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
+  sc = rtems_semaphore_obtain(sparse_disk->mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
+  if (sc != RTEMS_SUCCESSFUL) {
+      rtems_fatal_error_occurred( 0xdeadbeef );
+  }
 
   for ( req_buffer = 0;
         ( 0 <= rv ) && ( req_buffer < req->bufnum );
@@ -267,7 +271,10 @@ static int sparse_disk_read_write(
     }
   }
 
-  rtems_semaphore_release( sparse_disk->mutex );
+  sc = rtems_semaphore_release( sparse_disk->mutex );
+  if (sc != RTEMS_SUCCESSFUL) {
+      rtems_fatal_error_occurred( 0xdeadbeef );
+  }
 
   if ( 0 > rv )
     rtems_blkdev_request_done( req, RTEMS_IO_ERROR );
-- 
1.7.1




More information about the devel mailing list