[rtems commit] imfs: Simplify IMFS_create_node()

Sebastian Huber sebh at rtems.org
Wed Mar 4 08:46:26 UTC 2020


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Sat Feb 29 11:43:42 2020 +0100

imfs: Simplify IMFS_create_node()

Update #3894.

---

 cpukit/libfs/src/imfs/imfs_creat.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/cpukit/libfs/src/imfs/imfs_creat.c b/cpukit/libfs/src/imfs/imfs_creat.c
index b72ae49..e476d74 100644
--- a/cpukit/libfs/src/imfs/imfs_creat.c
+++ b/cpukit/libfs/src/imfs/imfs_creat.c
@@ -33,6 +33,7 @@ IMFS_jnode_t *IMFS_create_node(
 )
 {
   IMFS_jnode_t *allocated_node;
+  char         *allocated_name;
   IMFS_jnode_t *node;
 
   allocated_node = calloc( 1, node_size + namelen );
@@ -42,10 +43,12 @@ IMFS_jnode_t *IMFS_create_node(
     return NULL;
   }
 
+  allocated_name = (char *) allocated_node + node_size;
+  allocated_name = memcpy( allocated_name, name, namelen );
   node = IMFS_initialize_node(
     allocated_node,
     node_control,
-    (char *) allocated_node + node_size,
+    allocated_name,
     namelen,
     mode,
     arg
@@ -53,8 +56,6 @@ IMFS_jnode_t *IMFS_create_node(
   if ( node != NULL ) {
     IMFS_jnode_t *parent = parentloc->node_access;
 
-    memcpy( RTEMS_DECONST( char *, node->name ), name, namelen );
-
     /*
      *  This node MUST have a parent, so put it in that directory list.
      */



More information about the vc mailing list