[rtems commit] libblock: Init deps in rtems_blkdev_create()

Sebastian Huber sebh at rtems.org
Fri May 18 08:45:19 UTC 2018


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Sat Mar  3 13:24:42 2018 +0100

libblock: Init deps in rtems_blkdev_create()

Update #3358.

---

 cpukit/include/rtems/blkdev.h      |  1 +
 cpukit/libblock/src/blkdev-imfs.c  | 14 ++++++++++----
 testsuites/libtests/block17/init.c | 10 ++++++++--
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/cpukit/include/rtems/blkdev.h b/cpukit/include/rtems/blkdev.h
index 3f829e6..929cf4f 100644
--- a/cpukit/include/rtems/blkdev.h
+++ b/cpukit/include/rtems/blkdev.h
@@ -296,6 +296,7 @@ rtems_blkdev_ioctl(rtems_disk_device *dd, uint32_t req, void *argp);
  * @retval RTEMS_INVALID_NUMBER Media block size or count is not positive.
  * @retval RTEMS_NO_MEMORY Not enough memory.
  * @retval RTEMS_UNSATISFIED Cannot create generic device node.
+ * @retval RTEMS_INCORRECT_STATE Cannot initialize bdbuf.
  *
  * @see rtems_blkdev_create_partition(), rtems_bdbuf_set_block_size(), and
  * rtems_blkdev_request.
diff --git a/cpukit/libblock/src/blkdev-imfs.c b/cpukit/libblock/src/blkdev-imfs.c
index ebe6ebb..a46babb 100644
--- a/cpukit/libblock/src/blkdev-imfs.c
+++ b/cpukit/libblock/src/blkdev-imfs.c
@@ -6,10 +6,10 @@
  */
 
 /*
- * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2012, 2018 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
- *  Obere Lagerstr. 30
+ *  Dornierstr. 4
  *  82178 Puchheim
  *  Germany
  *  <rtems at embedded-brains.de>
@@ -279,9 +279,15 @@ rtems_status_code rtems_blkdev_create(
   void *driver_data
 )
 {
-  rtems_status_code sc = RTEMS_SUCCESSFUL;
-  rtems_blkdev_imfs_context *ctx = malloc(sizeof(*ctx));
+  rtems_status_code sc;
+  rtems_blkdev_imfs_context *ctx;
+
+  sc = rtems_bdbuf_init();
+  if (sc != RTEMS_SUCCESSFUL) {
+    return RTEMS_INCORRECT_STATE;
+  }
 
+  ctx = malloc(sizeof(*ctx));
   if (ctx != NULL) {
     sc = rtems_disk_init_phys(
       &ctx->dd,
diff --git a/testsuites/libtests/block17/init.c b/testsuites/libtests/block17/init.c
index d916c73..3346c7c 100644
--- a/testsuites/libtests/block17/init.c
+++ b/testsuites/libtests/block17/init.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2013, 2018 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Dornierstr. 4
@@ -17,6 +17,7 @@
 #endif
 
 #include <rtems/bdbuf.h>
+#include <rtems/blkdev.h>
 
 #include "tmacros.h"
 
@@ -24,8 +25,13 @@ const char rtems_test_name[] = "BLOCK 17";
 
 static void test(void)
 {
-  rtems_status_code sc = rtems_bdbuf_init();
+  rtems_status_code sc;
+
+  sc = rtems_bdbuf_init();
   rtems_test_assert(sc == RTEMS_INVALID_NUMBER);
+
+  sc = rtems_blkdev_create(NULL, 0, 0, NULL, NULL);
+  rtems_test_assert(sc == RTEMS_INCORRECT_STATE);
 }
 
 static void Init(rtems_task_argument arg)



More information about the vc mailing list