mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-20 19:58:32 +08:00
2010-06-24 Joel Sherrill <joel.sherrilL@OARcorp.com>
* libfs/src/imfs/imfs_creat.c, libfs/src/imfs/imfs_debug.c, libfs/src/imfs/imfs_directory.c, libfs/src/imfs/imfs_eval.c, libfs/src/imfs/imfs_fsunmount.c, libfs/src/imfs/imfs_getchild.c, libfs/src/imfs/imfs_initsupp.c, libfs/src/imfs/ioman.c, libfs/src/imfs/memfile.c: Evaluate all assert calls in IMFS. Either made them conditional on RTEMS_DEBUG or eliminated them.
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
2010-06-24 Joel Sherrill <joel.sherrilL@OARcorp.com>
|
||||
|
||||
* libfs/src/imfs/imfs_creat.c, libfs/src/imfs/imfs_debug.c,
|
||||
libfs/src/imfs/imfs_directory.c, libfs/src/imfs/imfs_eval.c,
|
||||
libfs/src/imfs/imfs_fsunmount.c, libfs/src/imfs/imfs_getchild.c,
|
||||
libfs/src/imfs/imfs_initsupp.c, libfs/src/imfs/ioman.c,
|
||||
libfs/src/imfs/memfile.c: Evaluate all assert calls in IMFS. Either
|
||||
made them conditional on RTEMS_DEBUG or eliminated them.
|
||||
|
||||
2010-06-24 Gedare Bloom <giddyup44@yahoo.com>
|
||||
|
||||
PR 1590/cpukit
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#if defined(RTEMS_DEBUG)
|
||||
#include <assert.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "imfs.h"
|
||||
@@ -99,8 +101,10 @@ IMFS_jnode_t *IMFS_create_node(
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert(0);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#if defined(RTEMS_DEBUG)
|
||||
#include <assert.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
@@ -53,7 +55,9 @@ void IMFS_print_jnode(
|
||||
IMFS_jnode_t *the_jnode
|
||||
)
|
||||
{
|
||||
assert( the_jnode );
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert( the_jnode );
|
||||
#endif
|
||||
|
||||
fprintf(stdout, "%s", the_jnode->name );
|
||||
switch( the_jnode->type ) {
|
||||
@@ -90,23 +94,19 @@ void IMFS_print_jnode(
|
||||
|
||||
case IMFS_HARD_LINK:
|
||||
fprintf(stdout, " links not printed\n" );
|
||||
assert(0);
|
||||
break;
|
||||
return;
|
||||
|
||||
case IMFS_SYM_LINK:
|
||||
fprintf(stdout, " links not printed\n" );
|
||||
assert(0);
|
||||
break;
|
||||
return;
|
||||
|
||||
case IMFS_FIFO:
|
||||
fprintf(stdout, " FIFO not printed\n" );
|
||||
assert(0);
|
||||
break;
|
||||
return;
|
||||
|
||||
default:
|
||||
fprintf(stdout, " bad type %d\n", the_jnode->type );
|
||||
assert(0);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
puts("");
|
||||
}
|
||||
@@ -129,11 +129,11 @@ void IMFS_dump_directory(
|
||||
IMFS_jnode_t *the_jnode;
|
||||
int i;
|
||||
|
||||
assert( the_directory );
|
||||
|
||||
assert( level >= 0 );
|
||||
|
||||
assert( the_directory->type == IMFS_DIRECTORY );
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert( the_directory );
|
||||
assert( level >= 0 );
|
||||
assert( the_directory->type == IMFS_DIRECTORY );
|
||||
#endif
|
||||
|
||||
the_chain = &the_directory->info.directory.Entries;
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include "imfs.h"
|
||||
@@ -179,7 +178,7 @@ int imfs_dir_close(
|
||||
* directory
|
||||
* SEEK_CUR - offset is used as the relative byte offset from the current
|
||||
* directory position index held in the iop structure
|
||||
* SEEK_END - N/A --> This will cause an assert.
|
||||
* SEEK_END - N/A --> This will cause an EINVAL to be returned.
|
||||
*/
|
||||
|
||||
rtems_off64_t imfs_dir_lseek(
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "imfs.h"
|
||||
#include <rtems/libio_.h>
|
||||
@@ -83,7 +82,6 @@ int IMFS_evaluate_permission(
|
||||
int flags_to_test;
|
||||
|
||||
if ( !rtems_libio_is_valid_perms( flags ) ) {
|
||||
assert( 0 );
|
||||
rtems_set_errno_and_return_minus_one( EIO );
|
||||
}
|
||||
|
||||
@@ -501,7 +499,6 @@ int IMFS_eval_path(
|
||||
int result;
|
||||
|
||||
if ( !rtems_libio_is_valid_perms( flags ) ) {
|
||||
assert( 0 );
|
||||
rtems_set_errno_and_return_minus_one( EIO );
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "imfs.h"
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(RTEMS_DEBUG)
|
||||
#include <assert.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "imfs.h"
|
||||
|
||||
@@ -39,11 +41,13 @@ IMFS_jnode_t *IMFS_find_match_in_dir(
|
||||
* the IMFS code.
|
||||
*/
|
||||
|
||||
assert( directory );
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert( directory );
|
||||
assert( name );
|
||||
#endif
|
||||
if ( !name )
|
||||
return 0;
|
||||
|
||||
assert( name );
|
||||
if ( !directory )
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "imfs.h"
|
||||
#include <rtems/libio_.h>
|
||||
#include <rtems/seterr.h>
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio_.h>
|
||||
#include <rtems/seterr.h>
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems.h>
|
||||
@@ -301,11 +300,13 @@ MEMFILE_STATIC int IMFS_memfile_extend(
|
||||
* Perform internal consistency checks
|
||||
*/
|
||||
|
||||
assert( the_jnode );
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert( the_jnode );
|
||||
assert( the_jnode->type == IMFS_MEMORY_FILE );
|
||||
#endif
|
||||
if ( !the_jnode )
|
||||
rtems_set_errno_and_return_minus_one( EIO );
|
||||
|
||||
assert( the_jnode->type == IMFS_MEMORY_FILE );
|
||||
if ( the_jnode->type != IMFS_MEMORY_FILE )
|
||||
rtems_set_errno_and_return_minus_one( EIO );
|
||||
|
||||
@@ -357,11 +358,13 @@ MEMFILE_STATIC int IMFS_memfile_addblock(
|
||||
block_p memory;
|
||||
block_p *block_entry_ptr;
|
||||
|
||||
assert( the_jnode );
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert( the_jnode );
|
||||
assert( the_jnode->type == IMFS_MEMORY_FILE );
|
||||
#endif
|
||||
if ( !the_jnode )
|
||||
rtems_set_errno_and_return_minus_one( EIO );
|
||||
|
||||
assert( the_jnode->type == IMFS_MEMORY_FILE );
|
||||
if ( the_jnode->type != IMFS_MEMORY_FILE )
|
||||
rtems_set_errno_and_return_minus_one( EIO );
|
||||
|
||||
@@ -402,7 +405,9 @@ MEMFILE_STATIC int IMFS_memfile_remove_block(
|
||||
block_p ptr;
|
||||
|
||||
block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );
|
||||
assert( block_ptr );
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert( block_ptr );
|
||||
#endif
|
||||
if ( block_ptr ) {
|
||||
ptr = *block_ptr;
|
||||
*block_ptr = 0;
|
||||
@@ -431,7 +436,9 @@ void memfile_free_blocks_in_table(
|
||||
* Perform internal consistency checks
|
||||
*/
|
||||
|
||||
assert( block_table );
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert( block_table );
|
||||
#endif
|
||||
if ( !block_table )
|
||||
return;
|
||||
|
||||
@@ -490,11 +497,13 @@ int IMFS_memfile_remove(
|
||||
* Perform internal consistency checks
|
||||
*/
|
||||
|
||||
assert( the_jnode );
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert( the_jnode );
|
||||
assert( the_jnode->type == IMFS_MEMORY_FILE );
|
||||
#endif
|
||||
if ( !the_jnode )
|
||||
rtems_set_errno_and_return_minus_one( EIO );
|
||||
|
||||
assert( the_jnode->type == IMFS_MEMORY_FILE );
|
||||
if ( the_jnode->type != IMFS_MEMORY_FILE )
|
||||
rtems_set_errno_and_return_minus_one( EIO );
|
||||
|
||||
@@ -584,12 +593,14 @@ MEMFILE_STATIC ssize_t IMFS_memfile_read(
|
||||
* Perform internal consistency checks
|
||||
*/
|
||||
|
||||
assert( the_jnode );
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert( the_jnode );
|
||||
assert( the_jnode->type == IMFS_MEMORY_FILE ||
|
||||
assert( dest );
|
||||
#endif
|
||||
if ( !the_jnode )
|
||||
rtems_set_errno_and_return_minus_one( EIO );
|
||||
|
||||
assert( the_jnode->type == IMFS_MEMORY_FILE ||
|
||||
the_jnode->type == IMFS_LINEAR_FILE );
|
||||
if ( the_jnode->type != IMFS_MEMORY_FILE &&
|
||||
the_jnode->type != IMFS_LINEAR_FILE )
|
||||
rtems_set_errno_and_return_minus_one( EIO );
|
||||
@@ -598,7 +609,6 @@ MEMFILE_STATIC ssize_t IMFS_memfile_read(
|
||||
* Error checks on arguments
|
||||
*/
|
||||
|
||||
assert( dest );
|
||||
if ( !dest )
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
@@ -658,7 +668,6 @@ MEMFILE_STATIC ssize_t IMFS_memfile_read(
|
||||
if ( to_copy > my_length )
|
||||
to_copy = my_length;
|
||||
block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );
|
||||
assert( block_ptr );
|
||||
if ( !block_ptr )
|
||||
return copied;
|
||||
memcpy( dest, &(*block_ptr)[ start_offset ], to_copy );
|
||||
@@ -675,7 +684,6 @@ MEMFILE_STATIC ssize_t IMFS_memfile_read(
|
||||
to_copy = IMFS_MEMFILE_BYTES_PER_BLOCK;
|
||||
while ( my_length >= IMFS_MEMFILE_BYTES_PER_BLOCK ) {
|
||||
block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );
|
||||
assert( block_ptr );
|
||||
if ( !block_ptr )
|
||||
return copied;
|
||||
memcpy( dest, &(*block_ptr)[ 0 ], to_copy );
|
||||
@@ -689,11 +697,12 @@ MEMFILE_STATIC ssize_t IMFS_memfile_read(
|
||||
* Phase 3: possibly the first part of one block
|
||||
*/
|
||||
|
||||
assert( my_length < IMFS_MEMFILE_BYTES_PER_BLOCK );
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert( my_length < IMFS_MEMFILE_BYTES_PER_BLOCK );
|
||||
#endif
|
||||
|
||||
if ( my_length ) {
|
||||
block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );
|
||||
assert( block_ptr );
|
||||
if ( !block_ptr )
|
||||
return copied;
|
||||
memcpy( dest, &(*block_ptr)[ 0 ], my_length );
|
||||
@@ -735,11 +744,14 @@ MEMFILE_STATIC ssize_t IMFS_memfile_write(
|
||||
* Perform internal consistency checks
|
||||
*/
|
||||
|
||||
assert( the_jnode );
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert( source );
|
||||
assert( the_jnode );
|
||||
assert( the_jnode->type == IMFS_MEMORY_FILE );
|
||||
#endif
|
||||
if ( !the_jnode )
|
||||
rtems_set_errno_and_return_minus_one( EIO );
|
||||
|
||||
assert( the_jnode->type == IMFS_MEMORY_FILE );
|
||||
if ( the_jnode->type != IMFS_MEMORY_FILE )
|
||||
rtems_set_errno_and_return_minus_one( EIO );
|
||||
|
||||
@@ -747,7 +759,6 @@ MEMFILE_STATIC ssize_t IMFS_memfile_write(
|
||||
* Error check arguments
|
||||
*/
|
||||
|
||||
assert( source );
|
||||
if ( !source )
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
@@ -792,12 +803,19 @@ MEMFILE_STATIC ssize_t IMFS_memfile_write(
|
||||
if ( to_copy > my_length )
|
||||
to_copy = my_length;
|
||||
block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );
|
||||
assert( block_ptr );
|
||||
if ( !block_ptr )
|
||||
return copied;
|
||||
#if 0
|
||||
fprintf(stdout, "write %d at %d in %d: %*s\n", to_copy, start_offset, block, to_copy, src );
|
||||
#endif
|
||||
#if 0
|
||||
fprintf(
|
||||
stderr,
|
||||
"write %d at %d in %d: %*s\n",
|
||||
to_copy,
|
||||
start_offset,
|
||||
block,
|
||||
to_copy,
|
||||
src
|
||||
);
|
||||
#endif
|
||||
memcpy( &(*block_ptr)[ start_offset ], src, to_copy );
|
||||
src += to_copy;
|
||||
block++;
|
||||
@@ -812,12 +830,11 @@ fprintf(stdout, "write %d at %d in %d: %*s\n", to_copy, start_offset, block, to_
|
||||
to_copy = IMFS_MEMFILE_BYTES_PER_BLOCK;
|
||||
while ( my_length >= IMFS_MEMFILE_BYTES_PER_BLOCK ) {
|
||||
block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );
|
||||
assert( block_ptr );
|
||||
if ( !block_ptr )
|
||||
return copied;
|
||||
#if 0
|
||||
fprintf(stdout, "write %d in %d: %*s\n", to_copy, block, to_copy, src );
|
||||
#endif
|
||||
#if 0
|
||||
fprintf(stdout, "write %d in %d: %*s\n", to_copy, block, to_copy, src );
|
||||
#endif
|
||||
memcpy( &(*block_ptr)[ 0 ], src, to_copy );
|
||||
src += to_copy;
|
||||
block++;
|
||||
@@ -829,17 +846,18 @@ fprintf(stdout, "write %d in %d: %*s\n", to_copy, block, to_copy, src );
|
||||
* Phase 3: possibly the first part of one block
|
||||
*/
|
||||
|
||||
assert( my_length < IMFS_MEMFILE_BYTES_PER_BLOCK );
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert( my_length < IMFS_MEMFILE_BYTES_PER_BLOCK );
|
||||
#endif
|
||||
|
||||
to_copy = my_length;
|
||||
if ( my_length ) {
|
||||
block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );
|
||||
assert( block_ptr );
|
||||
if ( !block_ptr )
|
||||
return copied;
|
||||
#if 0
|
||||
fprintf(stdout, "write %d in %d: %*s\n", to_copy, block, to_copy, src );
|
||||
#endif
|
||||
#if 0
|
||||
fprintf(stdout, "write %d in %d: %*s\n", to_copy, block, to_copy, src );
|
||||
#endif
|
||||
memcpy( &(*block_ptr)[ 0 ], src, my_length );
|
||||
my_length = 0;
|
||||
copied += to_copy;
|
||||
@@ -900,11 +918,13 @@ block_p *IMFS_memfile_get_block_pointer(
|
||||
* Perform internal consistency checks
|
||||
*/
|
||||
|
||||
assert( the_jnode );
|
||||
#if defined(RTEMS_DEBUG)
|
||||
assert( the_jnode );
|
||||
assert( the_jnode->type == IMFS_MEMORY_FILE );
|
||||
#endif
|
||||
if ( !the_jnode )
|
||||
return NULL;
|
||||
|
||||
assert( the_jnode->type == IMFS_MEMORY_FILE );
|
||||
if ( the_jnode->type != IMFS_MEMORY_FILE )
|
||||
return NULL;
|
||||
|
||||
@@ -917,10 +937,6 @@ block_p *IMFS_memfile_get_block_pointer(
|
||||
*/
|
||||
|
||||
if ( my_block <= LAST_INDIRECT ) {
|
||||
#if 0
|
||||
fprintf(stdout, "(s %d) ", block );
|
||||
fflush(stdout);
|
||||
#endif
|
||||
p = info->indirect;
|
||||
|
||||
if ( malloc_it ) {
|
||||
|
||||
Reference in New Issue
Block a user