Changeset 9247d3f in rtems


Ignore:
Timestamp:
Feb 5, 2015, 3:58:09 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
60cf8a5
Parents:
e4d35d8
git-author:
Sebastian Huber <sebastian.huber@…> (02/05/15 15:58:09)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/12/15 19:53:35)
Message:

IMFS: Simplify IMFS_symlink()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/src/imfs/imfs_symlink.c

    re4d35d8 r9247d3f  
    2121#include "imfs.h"
    2222
    23 #include <stdlib.h>
    2423#include <string.h>
    2524
     
    3332)
    3433{
    35   char         *dup_target;
    3634  IMFS_jnode_t *new_node;
    37 
    38   /*
    39    * Duplicate link name
    40    */
    41   dup_target = strdup(target);
    42   if (dup_target == NULL) {
    43     rtems_set_errno_and_return_minus_one(ENOMEM);
    44   }
    4535
    4636  /*
     
    5040    parentloc,
    5141    &IMFS_node_control_sym_link,
    52     sizeof( IMFS_sym_link_t ),
     42    sizeof( IMFS_sym_link_t ) + strlen( target ) + 1,
    5343    name,
    5444    namelen,
    5545    ( S_IFLNK | ( S_IRWXU | S_IRWXG | S_IRWXO )),
    56     dup_target
     46    RTEMS_DECONST( char *, target )
    5747  );
    5848
    59   if (new_node == NULL) {
    60     free(dup_target);
    61     rtems_set_errno_and_return_minus_one(ENOMEM);
     49  if ( new_node == NULL ) {
     50    rtems_set_errno_and_return_minus_one( ENOMEM );
    6251  }
    6352
     
    119108  IMFS_sym_link_t *sym_link = (IMFS_sym_link_t *) node;
    120109
    121   sym_link->name = arg;
     110  sym_link->name = (char *) sym_link + sizeof( *sym_link );
     111  strcpy( sym_link->name, arg );
    122112
    123113  return node;
    124 }
    125 
    126 static void IMFS_node_destroy_sym_link( IMFS_jnode_t *node )
    127 {
    128   IMFS_sym_link_t *sym_link = (IMFS_sym_link_t *) node;
    129 
    130   free( sym_link->name );
    131 
    132   IMFS_node_destroy_default( node );
    133114}
    134115
     
    137118  .node_initialize = IMFS_node_initialize_sym_link,
    138119  .node_remove = IMFS_node_remove_default,
    139   .node_destroy = IMFS_node_destroy_sym_link
     120  .node_destroy = IMFS_node_destroy_default
    140121};
Note: See TracChangeset for help on using the changeset viewer.