diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-06-24 21:31:22 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-06-24 21:31:22 +0000 |
commit | 983bfad2108c3cdd9f100c6f0d1cde00343056dc (patch) | |
tree | 131d133d84dc68a06f542b822d22a918533616c2 /cpukit/libfs/src/imfs | |
parent | 2010-06-24 Gedare Bloom <giddyup44@yahoo.com> (diff) | |
download | rtems-983bfad2108c3cdd9f100c6f0d1cde00343056dc.tar.bz2 |
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.
Diffstat (limited to 'cpukit/libfs/src/imfs')
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_creat.c | 10 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_debug.c | 30 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_directory.c | 3 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_eval.c | 3 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_fsunmount.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_getchild.c | 10 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_initsupp.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/ioman.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/memfile.c | 94 |
9 files changed, 85 insertions, 71 deletions
diff --git a/cpukit/libfs/src/imfs/imfs_creat.c b/cpukit/libfs/src/imfs/imfs_creat.c index f1253ea327..a993890190 100644 --- a/cpukit/libfs/src/imfs/imfs_creat.c +++ b/cpukit/libfs/src/imfs/imfs_creat.c @@ -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; } /* diff --git a/cpukit/libfs/src/imfs/imfs_debug.c b/cpukit/libfs/src/imfs/imfs_debug.c index eb7541bb6a..5c5db89941 100644 --- a/cpukit/libfs/src/imfs/imfs_debug.c +++ b/cpukit/libfs/src/imfs/imfs_debug.c @@ -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; diff --git a/cpukit/libfs/src/imfs/imfs_directory.c b/cpukit/libfs/src/imfs/imfs_directory.c index daab68f1de..c7612455e2 100644 --- a/cpukit/libfs/src/imfs/imfs_directory.c +++ b/cpukit/libfs/src/imfs/imfs_directory.c @@ -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( diff --git a/cpukit/libfs/src/imfs/imfs_eval.c b/cpukit/libfs/src/imfs/imfs_eval.c index d6bf8f8faa..8692024e14 100644 --- a/cpukit/libfs/src/imfs/imfs_eval.c +++ b/cpukit/libfs/src/imfs/imfs_eval.c @@ -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 ); } diff --git a/cpukit/libfs/src/imfs/imfs_fsunmount.c b/cpukit/libfs/src/imfs/imfs_fsunmount.c index 19a26ffd04..b65c20e60d 100644 --- a/cpukit/libfs/src/imfs/imfs_fsunmount.c +++ b/cpukit/libfs/src/imfs/imfs_fsunmount.c @@ -20,8 +20,6 @@ #include <unistd.h> #include <stdlib.h> -#include <assert.h> - #include "imfs.h" #include <rtems/libio_.h> diff --git a/cpukit/libfs/src/imfs/imfs_getchild.c b/cpukit/libfs/src/imfs/imfs_getchild.c index 2b47ba2714..dc66e55102 100644 --- a/cpukit/libfs/src/imfs/imfs_getchild.c +++ b/cpukit/libfs/src/imfs/imfs_getchild.c @@ -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; diff --git a/cpukit/libfs/src/imfs/imfs_initsupp.c b/cpukit/libfs/src/imfs/imfs_initsupp.c index 519bfd9c18..629a2a1a65 100644 --- a/cpukit/libfs/src/imfs/imfs_initsupp.c +++ b/cpukit/libfs/src/imfs/imfs_initsupp.c @@ -20,8 +20,6 @@ #include <unistd.h> #include <stdlib.h> -#include <assert.h> - #include "imfs.h" #include <rtems/libio_.h> #include <rtems/seterr.h> diff --git a/cpukit/libfs/src/imfs/ioman.c b/cpukit/libfs/src/imfs/ioman.c index ffdf340ef5..1bfdfbf926 100644 --- a/cpukit/libfs/src/imfs/ioman.c +++ b/cpukit/libfs/src/imfs/ioman.c @@ -22,8 +22,6 @@ #include <unistd.h> #include <string.h> -#include <assert.h> - #include <rtems.h> #include <rtems/libio_.h> #include <rtems/seterr.h> diff --git a/cpukit/libfs/src/imfs/memfile.c b/cpukit/libfs/src/imfs/memfile.c index 19a767dca6..a1193c8c88 100644 --- a/cpukit/libfs/src/imfs/memfile.c +++ b/cpukit/libfs/src/imfs/memfile.c @@ -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 ) { |