[PATCH] sparse-disk: check return value from semaphore_obtain/release
Joel Sherrill
joel.sherrill at OARcorp.com
Thu Sep 5 18:43:41 UTC 2013
Sebastian may want to comment on whether we should
use 0xdeadbeef or some other unique code. He has worked
hard on the BSP fatal errors to be unique and (I suspect)
he will have a comment on this.
On 9/5/2013 1:22 PM, Gedare Bloom wrote:
> 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 );
--
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