From 09f98cb16522a8deda5bf45d1267f8cd789ddc88 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 10 Jan 2014 13:36:33 +0000 Subject: [PATCH] Fix a bunch of compiler warnings in the tests, including: * Resolve set-but-not-used issues * Resolve incorrect const notation (I checked with George first to see what const notation he actually wanted) * Comment out unused code (didn't delete it because it's useful debugging code) * Resolve int<-->void* casting * Resolved signed / unsigned comparisons This commit was SVN r30225. --- test/class/ompi_rb_tree.c | 6 ++-- test/class/opal_bitmap.c | 12 +++++--- test/class/opal_hash_table.c | 6 ++++ test/class/opal_pointer_array.c | 4 +-- test/class/opal_tree.c | 6 ++-- test/datatype/ddt_raw.c | 4 +-- test/datatype/ddt_test.c | 6 ++-- test/datatype/opal_datatype_test.c | 10 +++---- test/datatype/opal_ddt_lib.c | 4 +-- test/datatype/opal_ddt_lib.h | 8 ++--- test/datatype/position.c | 3 ++ test/datatype/to_self.c | 47 +++++++++++++++--------------- 12 files changed, 64 insertions(+), 52 deletions(-) diff --git a/test/class/ompi_rb_tree.c b/test/class/ompi_rb_tree.c index 2e492a7fb2..063a04014b 100644 --- a/test/class/ompi_rb_tree.c +++ b/test/class/ompi_rb_tree.c @@ -347,7 +347,7 @@ void test2(void) ((ompi_test_rb_value_t *) new_value)->key.bottom = mem[i]; ((ompi_test_rb_value_t *) new_value)->key.top = (void *) ((size_t) mem[i] + size - 1); - ((ompi_test_rb_value_t *) new_value)->registered_mpools[0] = (void *) i; + ((ompi_test_rb_value_t *) new_value)->registered_mpools[0] = (void *)(intptr_t) i; rc = ompi_rb_tree_insert(&tree, &((ompi_test_rb_value_t *)new_value)->key, new_value); if(OMPI_SUCCESS != rc) @@ -365,7 +365,7 @@ void test2(void) if(NULL == result) { test_failure("lookup returned null!"); - } else if(i != ((int) ((ompi_test_rb_value_t *) result)->registered_mpools[0])) + } else if(i != ((int)(intptr_t) ((ompi_test_rb_value_t *) result)->registered_mpools[0])) { test_failure("lookup returned wrong node!"); } @@ -373,7 +373,7 @@ void test2(void) if(NULL == result) { test_failure("lookup returned null!"); - } else if(i != ((int) ((ompi_test_rb_value_t *) result)->registered_mpools[0])) + } else if(i != ((int)(intptr_t) ((ompi_test_rb_value_t *) result)->registered_mpools[0])) { test_failure("lookup returned wrong node!"); } diff --git a/test/class/opal_bitmap.c b/test/class/opal_bitmap.c index 8c5b3df7d3..bcc1f1fe2b 100644 --- a/test/class/opal_bitmap.c +++ b/test/class/opal_bitmap.c @@ -295,8 +295,10 @@ int find_and_set(opal_bitmap_t *bm, int bit) int clear_all(opal_bitmap_t *bm) { - int i, err; - err = opal_bitmap_clear_all_bits(bm); + int i; + if (OPAL_SUCCESS != opal_bitmap_clear_all_bits(bm)) { + return ERR_CODE; + } for (i = 0; i < bm->array_size; ++i) if (bm->bitmap[i] != 0) { fprintf(error_out, "ERROR: clear_all for bitmap arry entry %d\n\n", @@ -309,8 +311,10 @@ int clear_all(opal_bitmap_t *bm) int set_all(opal_bitmap_t *bm) { - int i, err; - err = opal_bitmap_set_all_bits(bm); + int i; + if (OPAL_SUCCESS != opal_bitmap_set_all_bits(bm)) { + return ERR_CODE; + } for (i = 0; i < bm->array_size; ++i) if (bm->bitmap[i] != 0xff) { fprintf(error_out, "ERROR: set_all for bitmap arry entry %d\n\n", i); diff --git a/test/class/opal_hash_table.c b/test/class/opal_hash_table.c index e3f6a99baf..35df9f6aa2 100644 --- a/test/class/opal_hash_table.c +++ b/test/class/opal_hash_table.c @@ -76,10 +76,16 @@ static void validate_table(opal_hash_table_t *table, char *keys[], int is_numeri if ( 1 == is_numeric_keys ) { ret = opal_hash_table_get_value_uint32(table, atoi(keys[j]), (void**) &value.uvalue); + if (OPAL_SUCCESS != ret) { + test_failure("opal_hash_table_get_value_uint32 failed"); + } } else { ret = opal_hash_table_get_value_ptr(table, keys[j], strlen(keys[j]), &value.vvalue); + if (OPAL_SUCCESS != ret) { + test_failure("opal_hash_table_get_value_ptr failed"); + } } test_verify_str(keys[j+1], value.vvalue); } diff --git a/test/class/opal_pointer_array.c b/test/class/opal_pointer_array.c index cfd8443a9f..67e07275f5 100644 --- a/test/class/opal_pointer_array.c +++ b/test/class/opal_pointer_array.c @@ -44,11 +44,11 @@ static void test(bool thread_usage){ value_t *test_data; int len_test_data,i,test_len_in_array,error_cnt; int ele_index; - int use_threads,error_code; + int error_code; value_t value; /* initialize thread levels */ - use_threads=(int)opal_set_using_threads(thread_usage); + opal_set_using_threads(thread_usage); array=OBJ_NEW(opal_pointer_array_t); assert(array); diff --git a/test/class/opal_tree.c b/test/class/opal_tree.c index cd6bbb265c..abbd6efce9 100644 --- a/test/class/opal_tree.c +++ b/test/class/opal_tree.c @@ -47,7 +47,7 @@ int main(int argc, char **argv) opal_tree_t tree, x; opal_buffer_t *serial_tree; size_t i, j, tree_size, size_levels, size_elements, total_elements; - int err_order, err_ancestor, err_parent, rc; + int err_order, err_ancestor, rc; unsigned key; test_data_t *elements; opal_tree_item_t *item, *rm_item; @@ -126,7 +126,6 @@ int main(int argc, char **argv) /* check that we have correct tree ordering */ err_order = 0; err_ancestor = 0; - err_parent = 0; if (!opal_tree_is_empty(&tree)) { item = opal_tree_get_root(&tree); i = 0; @@ -186,6 +185,9 @@ int main(int argc, char **argv) tree_size=opal_tree_get_size(&tree); item = opal_tree_find_with(opal_tree_get_root(&tree), (void*)&key); rm_item = opal_tree_remove_subtree(item); + if (NULL == rm_item) { + test_failure(" rm_item should not be NULL"); + } /* validate the tree count adjusted */ if (5 != (tree_size - opal_tree_get_size(&tree))) { test_failure(" failed subtree removal tree size test"); diff --git a/test/datatype/ddt_raw.c b/test/datatype/ddt_raw.c index cca543c66a..a0c3023a9c 100644 --- a/test/datatype/ddt_raw.c +++ b/test/datatype/ddt_raw.c @@ -46,7 +46,7 @@ static int test_upper( unsigned int length ) ompi_datatype_t *pdt; opal_convertor_t * pConv; int rc = OMPI_SUCCESS; - unsigned int i, iov_count, split_chunk, total_length; + unsigned int i, iov_count, total_length; size_t max_data; struct iovec iov[5]; TIMER_DATA_TYPE start, end; @@ -65,8 +65,6 @@ static int test_upper( unsigned int length ) } GET_TIME( start ); - split_chunk = (length + 1) * sizeof(double); - /* split_chunk = (total_length + 1) * sizeof(double); */ for( i = total_length; i > 0; ) { iov_count = 5; max_data = 0; diff --git a/test/datatype/ddt_test.c b/test/datatype/ddt_test.c index 20635cc38e..9b17487a6a 100644 --- a/test/datatype/ddt_test.c +++ b/test/datatype/ddt_test.c @@ -118,7 +118,7 @@ static int test_upper( unsigned int length ) * is not an easy task. Define a function to centralize the complexity in a * single location. */ -size_t compute_buffer_length(ompi_datatype_t* pdt, int count) +static size_t compute_buffer_length(ompi_datatype_t* pdt, int count) { MPI_Aint extent, lb, true_extent, true_lb; size_t length; @@ -151,7 +151,7 @@ static int local_copy_ddt_count( ompi_datatype_t* pdt, int count ) pdst = malloc(length); psrc = malloc(length); - for( int i = 0; i < length; i++ ) + for( size_t i = 0; i < length; i++ ) ((char*)psrc)[i] = i % 128 + 32; memset(pdst, 0, length); @@ -193,7 +193,7 @@ local_copy_with_convertor_2datatypes( ompi_datatype_t* send_type, int send_count ptemp = malloc( chunk ); /* initialize the buffers to prevent valgrind from complaining */ - for( int i = 0; i < slength; i++ ) + for( size_t i = 0; i < slength; i++ ) ((char*)psrc)[i] = i % 128 + 32; memset(pdst, 0, rlength); diff --git a/test/datatype/opal_datatype_test.c b/test/datatype/opal_datatype_test.c index 09fe218a27..2c18e09bf9 100644 --- a/test/datatype/opal_datatype_test.c +++ b/test/datatype/opal_datatype_test.c @@ -124,7 +124,7 @@ static int test_upper( unsigned int length ) * - and one using 2 convertors created from different data-types. * */ -static int local_copy_ddt_count( const opal_datatype_t const* pdt, int count ) +static int local_copy_ddt_count( opal_datatype_t const * const pdt, int count ) { OPAL_PTRDIFF_TYPE extent; void *pdst, *psrc; @@ -160,8 +160,8 @@ static int local_copy_ddt_count( const opal_datatype_t const* pdt, int count ) } static int -local_copy_with_convertor_2datatypes( const opal_datatype_t const * send_type, int send_count, - const opal_datatype_t const * recv_type, int recv_count, +local_copy_with_convertor_2datatypes( opal_datatype_t const * const send_type, int send_count, + opal_datatype_t const * const recv_type, int recv_count, int chunk ) { OPAL_PTRDIFF_TYPE send_extent, recv_extent; @@ -248,7 +248,7 @@ local_copy_with_convertor_2datatypes( const opal_datatype_t const * send_type, i } -static int local_copy_with_convertor( const opal_datatype_t const* pdt, int count, int chunk ) +static int local_copy_with_convertor( opal_datatype_t const * const pdt, int count, int chunk ) { OPAL_PTRDIFF_TYPE extent; void *pdst = NULL, *psrc = NULL, *ptemp = NULL; @@ -430,7 +430,7 @@ int main( int argc, char* argv[] ) printf( ">>--------------------------------------------<<\n" ); printf( " Contiguous data-type (opal_datatype_float8)\n" ); if( outputFlags & CHECK_PACK_UNPACK ) { - const opal_datatype_t const* ddt = &opal_datatype_float8; + opal_datatype_t const * const ddt = &opal_datatype_float8; local_copy_ddt_count( ddt, 4500); local_copy_with_convertor( ddt, 4500, 12 ); local_copy_with_convertor_2datatypes( ddt, 4500, ddt, 4500, 12 ); diff --git a/test/datatype/opal_ddt_lib.c b/test/datatype/opal_ddt_lib.c index 3f1506d2ef..0d1fa6a358 100644 --- a/test/datatype/opal_ddt_lib.c +++ b/test/datatype/opal_ddt_lib.c @@ -108,7 +108,7 @@ opal_datatype_t* test_create_blacs_type( void ) return pdt; } -opal_datatype_t* test_create_blacs_type1( const opal_datatype_t const* base_type ) +opal_datatype_t* test_create_blacs_type1( opal_datatype_t const * const base_type ) { opal_datatype_t *pdt; @@ -120,7 +120,7 @@ opal_datatype_t* test_create_blacs_type1( const opal_datatype_t const* base_type return pdt; } -opal_datatype_t* test_create_blacs_type2( const opal_datatype_t const* base_type ) +opal_datatype_t* test_create_blacs_type2( opal_datatype_t const * const base_type ) { opal_datatype_t *pdt; diff --git a/test/datatype/opal_ddt_lib.h b/test/datatype/opal_ddt_lib.h index 10eb3a0c71..0fbf9b5da2 100644 --- a/test/datatype/opal_ddt_lib.h +++ b/test/datatype/opal_ddt_lib.h @@ -29,8 +29,8 @@ extern uint32_t outputFlags; extern void cache_trash( void ); -extern opal_datatype_t* create_contiguous_type( const opal_datatype_t const* type, int length ); -extern opal_datatype_t* create_vector_type( const opal_datatype_t const* data, int count, int length, int stride ); +extern opal_datatype_t* create_contiguous_type( opal_datatype_t const * const type, int length ); +extern opal_datatype_t* create_vector_type( opal_datatype_t const* const data, int count, int length, int stride ); extern opal_datatype_t* create_strange_dt( void ); extern opal_datatype_t* upper_matrix( unsigned int mat_size ); extern opal_datatype_t* lower_matrix( unsigned int mat_size ); @@ -42,8 +42,8 @@ extern opal_datatype_t* test_struct_char_double( void ); extern opal_datatype_t* test_create_twice_two_doubles( void ); extern opal_datatype_t* test_struct( void ); extern opal_datatype_t* test_create_blacs_type( void ); -extern opal_datatype_t* test_create_blacs_type1( const opal_datatype_t const* base_type ); -extern opal_datatype_t* test_create_blacs_type2( const opal_datatype_t const* base_type ); +extern opal_datatype_t* test_create_blacs_type1( opal_datatype_t const * const base_type ); +extern opal_datatype_t* test_create_blacs_type2( opal_datatype_t const * const base_type ); extern int mpich_typeub( void ); extern int mpich_typeub2( void ); diff --git a/test/datatype/position.c b/test/datatype/position.c index cd50d3fa1f..7f0c0a4f66 100644 --- a/test/datatype/position.c +++ b/test/datatype/position.c @@ -181,6 +181,8 @@ typedef struct { int i; } ddt_ldi_t; +#if 0 +/* For debugging */ static void dump_ldi( ddt_ldi_t* buffer, int start_pos, int end_pos ) { int i; @@ -190,6 +192,7 @@ static void dump_ldi( ddt_ldi_t* buffer, int start_pos, int end_pos ) } } +#endif #if (OPAL_ENABLE_DEBUG == 1) && (OPAL_C_HAVE_VISIBILITY == 0) extern int opal_unpack_debug; diff --git a/test/datatype/to_self.c b/test/datatype/to_self.c index 3cff9293b0..a7560a3d16 100644 --- a/test/datatype/to_self.c +++ b/test/datatype/to_self.c @@ -158,7 +158,7 @@ static int isend_recv( int cycles, MPI_Datatype sdt, int scount, void* sbuf, MPI_Datatype rdt, int rcount, void* rbuf ) { - int sres, rres, myself, tag = 0, i, slength, rlength; + int myself, tag = 0, i, slength, rlength; MPI_Status status; MPI_Request req; double tstart, tend; @@ -173,13 +173,13 @@ static int isend_recv( int cycles, tstart = MPI_Wtime(); for( i = 0; i < cycles; i++ ) { #ifndef FAST - sres = MPI_Isend( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD, &req ); - rres = MPI_Recv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &status ); + MPI_Isend( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD, &req ); + MPI_Recv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &status ); MPI_Wait( &req, &status ); /*MPI_Request_free( &req );*/ #else - sres = ftmpi_mpi_isend( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD, &req ); - rres = ftmpi_mpi_recv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &status ); + ftmpi_mpi_isend( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD, &req ); + ftmpi_mpi_recv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &status ); ftmpi_request_free( &req ); #endif } @@ -192,7 +192,7 @@ static int irecv_send( int cycles, MPI_Datatype sdt, int scount, void* sbuf, MPI_Datatype rdt, int rcount, void* rbuf ) { - int sres, rres, myself, tag = 0, i, slength, rlength; + int myself, tag = 0, i, slength, rlength; MPI_Request req; MPI_Status status; double tstart, tend; @@ -207,13 +207,13 @@ static int irecv_send( int cycles, tstart = MPI_Wtime(); for( i = 0; i < cycles; i++ ) { #ifndef FAST - rres = MPI_Irecv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &req ); - sres = MPI_Send( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD ); + MPI_Irecv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &req ); + MPI_Send( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD ); MPI_Wait( &req, &status ); /*MPI_Request_free( &req );*/ #else - rres = ftmpi_mpi_irecv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &req ); - sres = ftmpi_mpi_send( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD ); + ftmpi_mpi_irecv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &req ); + ftmpi_mpi_send( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD ); ftmpi_request_free( &req ); #endif } @@ -226,7 +226,7 @@ static int isend_irecv_wait( int cycles, MPI_Datatype sdt, int scount, void* sbuf, MPI_Datatype rdt, int rcount, void* rbuf ) { - int sres, rres, myself, tag = 0, i, slength, rlength; + int myself, tag = 0, i, slength, rlength; MPI_Request sreq, rreq; MPI_Status status; double tstart, tend; @@ -241,15 +241,15 @@ static int isend_irecv_wait( int cycles, tstart = MPI_Wtime(); for( i = 0; i < cycles; i++ ) { #ifndef FAST - sres = MPI_Isend( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD, &sreq ); - rres = MPI_Irecv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &rreq ); + MPI_Isend( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD, &sreq ); + MPI_Irecv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &rreq ); MPI_Wait( &sreq, &status ); MPI_Wait( &rreq, &status ); /*MPI_Request_free( &sreq );*/ /*MPI_Request_free( &rreq );*/ #else - sres = ftmpi_mpi_isend( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD, &sreq ); - rres = ftmpi_mpi_irecv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &rreq ); + ftmpi_mpi_isend( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD, &sreq ); + ftmpi_mpi_irecv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &rreq ); ftmpi_wait( &sreq, &status ); ftmpi_request_free( &sreq ); ftmpi_request_free( &rreq ); @@ -264,7 +264,7 @@ static int irecv_isend_wait( int cycles, MPI_Datatype sdt, int scount, void* sbuf, MPI_Datatype rdt, int rcount, void* rbuf ) { - int sres, rres, myself, tag = 0, i, slength, rlength; + int myself, tag = 0, i, slength, rlength; MPI_Request sreq, rreq; MPI_Status status; double tstart, tend; @@ -279,15 +279,15 @@ static int irecv_isend_wait( int cycles, tstart = MPI_Wtime(); for( i = 0; i < cycles; i++ ) { #ifndef FAST - rres = MPI_Irecv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &rreq ); - sres = MPI_Isend( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD, &sreq ); + MPI_Irecv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &rreq ); + MPI_Isend( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD, &sreq ); MPI_Wait( &sreq, &status ); MPI_Wait( &rreq, &status ); /*MPI_Request_free( &sreq );*/ /*MPI_Request_free( &rreq );*/ #else - rres = ftmpi_mpi_irecv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &rreq ); - sres = ftmpi_mpi_isend( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD, &sreq ); + ftmpi_mpi_irecv( rbuf, rcount, rdt, myself, tag, MPI_COMM_WORLD, &rreq ); + ftmpi_mpi_isend( sbuf, scount, sdt, myself, tag, MPI_COMM_WORLD, &sreq ); ftmpi_wait( &sreq, &status ); ftmpi_request_free( &sreq ); ftmpi_request_free( &rreq ); @@ -335,17 +335,16 @@ static int do_test_for_ddt( MPI_Datatype sddt, MPI_Datatype rddt, int length ) int main( int argc, char* argv[] ) { - int rc; int length = 1024 * 1024; int rank, size; MPI_Datatype ddt; int run_tests = DO_CONTIG | DO_CONSTANT_GAP | DO_INDEXED_GAP | DO_OPTIMIZED_INDEXED_GAP; /*int run_tests = DO_CONSTANT_GAP;*/ - rc = MPI_Init (&argc, &argv); + MPI_Init (&argc, &argv); - rc = MPI_Comm_rank (MPI_COMM_WORLD, &rank); - rc = MPI_Comm_size (MPI_COMM_WORLD, &size); + MPI_Comm_rank (MPI_COMM_WORLD, &rank); + MPI_Comm_size (MPI_COMM_WORLD, &size); if( rank != 0 ) { MPI_Finalize();