2010-08-02 Joel Sherrill <joel.sherrill@oarcorp.com>

* libfs/src/imfs/imfs_creat.c, libfs/src/imfs/imfs_eval.c,
	libfs/src/imfs/imfs_mknod.c, libfs/src/imfs/imfs_readlink.c,
	libfs/src/pipe/fifo.c: Clean up for coverage improvements and
	formatting.
This commit is contained in:
Joel Sherrill
2010-08-02 18:27:23 +00:00
parent 5114d3ffd2
commit 8851c0a5ef
6 changed files with 54 additions and 82 deletions

View File

@@ -1,3 +1,10 @@
2010-08-02 Joel Sherrill <joel.sherrill@oarcorp.com>
* libfs/src/imfs/imfs_creat.c, libfs/src/imfs/imfs_eval.c,
libfs/src/imfs/imfs_mknod.c, libfs/src/imfs/imfs_readlink.c,
libfs/src/pipe/fifo.c: Clean up for coverage improvements and
formatting.
2010-08-02 Joel Sherrill <joel.sherrill@oarcorp.com> 2010-08-02 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/stackchk/check.c: If this port does not allocate the * libmisc/stackchk/check.c: If this port does not allocate the

View File

@@ -64,42 +64,28 @@ IMFS_jnode_t *IMFS_create_node(
/* /*
* Set the type specific information * Set the type specific information
*/ */
switch (type) { if ( type == IMFS_DIRECTORY ) {
case IMFS_DIRECTORY:
rtems_chain_initialize_empty(&node->info.directory.Entries); rtems_chain_initialize_empty(&node->info.directory.Entries);
break; } else if ( type == IMFS_HARD_LINK ) {
case IMFS_HARD_LINK:
node->info.hard_link.link_node = info->hard_link.link_node; node->info.hard_link.link_node = info->hard_link.link_node;
break; } else if ( type == IMFS_SYM_LINK ) {
case IMFS_SYM_LINK:
node->info.sym_link.name = info->sym_link.name; node->info.sym_link.name = info->sym_link.name;
break; } else if ( type == IMFS_DEVICE ) {
case IMFS_DEVICE:
node->info.device.major = info->device.major; node->info.device.major = info->device.major;
node->info.device.minor = info->device.minor; node->info.device.minor = info->device.minor;
break; } else if ( type == IMFS_LINEAR_FILE ) {
case IMFS_LINEAR_FILE:
node->info.linearfile.size = 0; node->info.linearfile.size = 0;
node->info.linearfile.direct = 0; node->info.linearfile.direct = 0;
if ( type == IMFS_MEMORY_FILE ) {
case IMFS_MEMORY_FILE:
node->info.file.size = 0; node->info.file.size = 0;
node->info.file.indirect = 0; node->info.file.indirect = 0;
node->info.file.doubly_indirect = 0; node->info.file.doubly_indirect = 0;
node->info.file.triply_indirect = 0; node->info.file.triply_indirect = 0;
break; }
} else if ( type == IMFS_FIFO ) {
case IMFS_FIFO:
node->info.fifo.pipe = NULL; node->info.fifo.pipe = NULL;
break; } else {
default:
IMFS_assert(0); IMFS_assert(0);
break;
} }
/* /*

View File

@@ -70,7 +70,6 @@ int IMFS_Set_handlers(
* The following routine evaluates that we have permission * The following routine evaluates that we have permission
* to do flags on the node. * to do flags on the node.
*/ */
int IMFS_evaluate_permission( int IMFS_evaluate_permission(
rtems_filesystem_location_info_t *node, rtems_filesystem_location_info_t *node,
int flags int flags
@@ -136,14 +135,11 @@ int IMFS_evaluate_hard_link(
/* /*
* Check for things that should never happen. * Check for things that should never happen.
*/ */
IMFS_assert( jnode->type == IMFS_HARD_LINK );
if ( jnode->type != IMFS_HARD_LINK )
rtems_fatal_error_occurred (0xABCD0000);
/* /*
* Set the hard link value and the handlers. * Set the hard link value and the handlers.
*/ */
node->node_access = jnode->info.hard_link.link_node; node->node_access = jnode->info.hard_link.link_node;
IMFS_Set_handlers( node ); IMFS_Set_handlers( node );
@@ -177,19 +173,13 @@ int IMFS_evaluate_sym_link(
/* /*
* Check for things that should never happen. * Check for things that should never happen.
*/ */
IMFS_assert( jnode->type == IMFS_SYM_LINK )
if ( jnode->type != IMFS_SYM_LINK ) IMFS_assert( jnode->Parent )
rtems_fatal_error_occurred (0xABCD0000);
if ( !jnode->Parent )
rtems_fatal_error_occurred( 0xBAD00000 );
/* /*
* Move the node_access to either the symbolic links parent or * Move the node_access to either the symbolic links parent or
* root depending on the symbolic links path. * root depending on the symbolic links path.
*/ */
node->node_access = jnode->Parent; node->node_access = jnode->Parent;
rtems_filesystem_get_sym_start_loc( rtems_filesystem_get_sym_start_loc(
@@ -201,7 +191,6 @@ int IMFS_evaluate_sym_link(
/* /*
* Use eval path to evaluate the path of the symbolic link. * Use eval path to evaluate the path of the symbolic link.
*/ */
result = IMFS_eval_path( result = IMFS_eval_path(
&jnode->info.sym_link.name[i], &jnode->info.sym_link.name[i],
strlen( &jnode->info.sym_link.name[i] ), strlen( &jnode->info.sym_link.name[i] ),
@@ -214,7 +203,6 @@ int IMFS_evaluate_sym_link(
/* /*
* Verify we have the correct permissions for this node. * Verify we have the correct permissions for this node.
*/ */
if ( !IMFS_evaluate_permission( node, flags ) ) if ( !IMFS_evaluate_permission( node, flags ) )
rtems_set_errno_and_return_minus_one( EACCES ); rtems_set_errno_and_return_minus_one( EACCES );
@@ -226,7 +214,6 @@ int IMFS_evaluate_sym_link(
* *
* The following routine returns the real node pointed to by a link. * The following routine returns the real node pointed to by a link.
*/ */
int IMFS_evaluate_link( int IMFS_evaluate_link(
rtems_filesystem_location_info_t *node, /* IN/OUT */ rtems_filesystem_location_info_t *node, /* IN/OUT */
int flags /* IN */ int flags /* IN */
@@ -578,19 +565,23 @@ int IMFS_eval_path(
/* /*
* If we are at a link follow it. * If we are at a link follow it.
*/ */
if ( node->type == IMFS_HARD_LINK ) { if ( node->type == IMFS_HARD_LINK ) {
IMFS_evaluate_hard_link( pathloc, 0 ); IMFS_evaluate_hard_link( pathloc, 0 );
node = pathloc->node_access; node = pathloc->node_access;
if ( !node )
rtems_set_errno_and_return_minus_one( ENOTDIR ); /*
* It would be a design error if we evaluated the link and
* was broken.
*/
IMFS_assert( node );
} else if ( node->type == IMFS_SYM_LINK ) { } else if ( node->type == IMFS_SYM_LINK ) {
result = IMFS_evaluate_sym_link( pathloc, 0 ); result = IMFS_evaluate_sym_link( pathloc, 0 );
/*
* In contrast to a hard link, it is possible to have a broken
* symbolic link.
*/
node = pathloc->node_access; node = pathloc->node_access;
if ( result == -1 ) if ( result == -1 )
return -1; return -1;
@@ -599,7 +590,6 @@ int IMFS_eval_path(
/* /*
* Only a directory can be decended into. * Only a directory can be decended into.
*/ */
if ( node->type != IMFS_DIRECTORY ) if ( node->type != IMFS_DIRECTORY )
rtems_set_errno_and_return_minus_one( ENOTDIR ); rtems_set_errno_and_return_minus_one( ENOTDIR );
@@ -607,7 +597,6 @@ int IMFS_eval_path(
* If we are at a node that is a mount point. Set loc to the * If we are at a node that is a mount point. Set loc to the
* new fs root node and let them finish evaluating the path. * new fs root node and let them finish evaluating the path.
*/ */
if ( node->info.directory.mt_fs != NULL ) { if ( node->info.directory.mt_fs != NULL ) {
newloc = node->info.directory.mt_fs->mt_fs_root; newloc = node->info.directory.mt_fs->mt_fs_root;
*pathloc = newloc; *pathloc = newloc;
@@ -619,7 +608,6 @@ int IMFS_eval_path(
/* /*
* Otherwise find the token name in the present location. * Otherwise find the token name in the present location.
*/ */
node = IMFS_find_match_in_dir( node, token ); node = IMFS_find_match_in_dir( node, token );
if ( !node ) if ( !node )
rtems_set_errno_and_return_minus_one( ENOENT ); rtems_set_errno_and_return_minus_one( ENOENT );

View File

@@ -53,12 +53,10 @@ int IMFS_mknod(
else if ( S_ISBLK(mode) || S_ISCHR(mode) ) { else if ( S_ISBLK(mode) || S_ISCHR(mode) ) {
type = IMFS_DEVICE; type = IMFS_DEVICE;
rtems_filesystem_split_dev_t( dev, info.device.major, info.device.minor ); rtems_filesystem_split_dev_t( dev, info.device.major, info.device.minor );
} } else if (S_ISFIFO(mode))
else if (S_ISFIFO(mode))
type = IMFS_FIFO; type = IMFS_FIFO;
else { else
rtems_set_errno_and_return_minus_one( EINVAL ); IMFS_assert( 0 );
}
/* /*
* Allocate and fill in an IMFS jnode * Allocate and fill in an IMFS jnode
@@ -70,14 +68,7 @@ int IMFS_mknod(
* existed. The result was simpler code which should not have * existed. The result was simpler code which should not have
* this path. * this path.
*/ */
new_node = IMFS_create_node( new_node = IMFS_create_node( pathloc, type, new_name, mode, &info );
pathloc,
type,
new_name,
mode,
&info
);
if ( !new_node ) if ( !new_node )
rtems_set_errno_and_return_minus_one( ENOMEM ); rtems_set_errno_and_return_minus_one( ENOMEM );

View File

@@ -34,8 +34,7 @@ int IMFS_readlink(
node = loc->node_access; node = loc->node_access;
if ( node->type != IMFS_SYM_LINK ) IMFS_assert( node->type == IMFS_SYM_LINK );
rtems_set_errno_and_return_minus_one( EINVAL );
for( i=0; ((i<bufsize) && (node->info.sym_link.name[i] != '\0')); i++ ) for( i=0; ((i<bufsize) && (node->info.sym_link.name[i] != '\0')); i++ )
buf[i] = node->info.sym_link.name[i]; buf[i] = node->info.sym_link.name[i];

View File

@@ -190,10 +190,11 @@ static void pipe_unlock(void)
rtems_status_code sc = RTEMS_SUCCESSFUL; rtems_status_code sc = RTEMS_SUCCESSFUL;
sc = rtems_semaphore_release(pipe_semaphore); sc = rtems_semaphore_release(pipe_semaphore);
#ifdef RTEMS_DEBUG
if (sc != RTEMS_SUCCESSFUL) { if (sc != RTEMS_SUCCESSFUL) {
/* FIXME */
rtems_fatal_error_occurred(0xdeadbeef); rtems_fatal_error_occurred(0xdeadbeef);
} }
#endif
} }
/* /*
@@ -248,15 +249,15 @@ int pipe_release(
pipe_control_t *pipe = *pipep; pipe_control_t *pipe = *pipep;
uint32_t mode; uint32_t mode;
if (pipe_lock()) #if defined(RTEMS_DEBUG)
/* WARN pipe not freed and pipep not set to NULL! */ /* WARN pipe not freed and pipep not set to NULL! */
/* FIXME */ if (pipe_lock())
rtems_fatal_error_occurred(0xdeadbeef); rtems_fatal_error_occurred(0xdeadbeef);
if (!PIPE_LOCK(pipe))
/* WARN pipe not released! */ /* WARN pipe not released! */
/* FIXME */ if (!PIPE_LOCK(pipe))
rtems_fatal_error_occurred(0xdeadbeef); rtems_fatal_error_occurred(0xdeadbeef);
#endif
mode = LIBIO_ACCMODE(iop); mode = LIBIO_ACCMODE(iop);
if (mode & LIBIO_FLAGS_READ) if (mode & LIBIO_FLAGS_READ)