From 47d88766dbee3c631c842639d44c362c2b7b8e44 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 12 Dec 2001 13:40:09 -0500 Subject: [svn-r4706] Purpose: Code cleanup Description: Tweaked internal error handling macros to reduce the size of the library's object code by about 10-20%. Also cleaned up some compiler warnings... Platforms tested: FreeBSD 4.4 (sleipnir) --- perform/chunk.c | 14 +-- perform/iopipe.c | 4 +- perform/overhead.c | 8 +- release_docs/RELEASE.txt | 2 + src/H5.c | 304 ++++++++++++++++++++++++----------------------- src/H5D.c | 24 ++-- src/H5Eprivate.h | 8 +- src/H5F.c | 16 ++- src/H5G.c | 3 +- src/H5I.c | 51 -------- src/H5Iprivate.h | 50 ++++++++ src/H5Oefl.c | 4 +- src/H5P.c | 2 +- src/H5Sall.c | 58 ++++----- src/H5Shyper.c | 8 +- src/H5Smpio.c | 2 +- src/H5T.c | 2 +- src/H5private.h | 9 +- test/tfile.c | 6 +- test/tgenprop.c | 2 +- 20 files changed, 285 insertions(+), 292 deletions(-) diff --git a/perform/chunk.c b/perform/chunk.c index 0b915c8..9366c98 100644 --- a/perform/chunk.c +++ b/perform/chunk.c @@ -162,7 +162,7 @@ create_dataset (void) *------------------------------------------------------------------------- */ static double -test_rowmaj (int op, size_t cache_size, hsize_t io_size) +test_rowmaj (int op, size_t cache_size, size_t io_size) { hid_t file, dset, mem_space, file_space; signed char *buf = calloc (1, SQUARE(io_size)); @@ -242,7 +242,7 @@ test_rowmaj (int op, size_t cache_size, hsize_t io_size) *------------------------------------------------------------------------- */ static double -test_diag (int op, size_t cache_size, hsize_t io_size, hsize_t offset) +test_diag (int op, size_t cache_size, size_t io_size, size_t offset) { hid_t file, dset, mem_space, file_space; hsize_t i, hs_size[2]; @@ -322,7 +322,7 @@ test_diag (int op, size_t cache_size, hsize_t io_size, hsize_t offset) int main (void) { - hsize_t io_size; + size_t io_size; double effic, io_percent; FILE *f, *d; size_t cache_size; @@ -370,7 +370,7 @@ main (void) cache_size<=RM_CACHE_END; cache_size+=RM_CACHE_DELT) { for (io_percent=RM_START; io_percent<=RM_END; io_percent+=RM_DELTA) { - io_size = MAX (1, (int)(CH_SIZE*io_percent)); + io_size = MAX (1, (size_t)(CH_SIZE*io_percent)); printf ("Rowmaj-rd %8d %8.2f", cache_size, io_percent); fflush (stdout); effic = test_rowmaj (READ, cache_size, io_size); @@ -416,7 +416,7 @@ main (void) cache_size<=RM_CACHE_END; cache_size+=RM_CACHE_DELT) { for (io_percent=RM_START; io_percent<=RM_END; io_percent+=RM_DELTA) { - io_size = MAX (1, (int)(CH_SIZE*io_percent)); + io_size = MAX (1, (size_t)(CH_SIZE*io_percent)); printf ("Rowmaj-wr %8d %8.2f", cache_size, io_percent); fflush (stdout); effic = test_rowmaj (WRITE, cache_size, io_size); @@ -461,7 +461,7 @@ main (void) for (io_percent=DIAG_START; io_percent<=DIAG_END; io_percent+=DIAG_DELTA) { - io_size = MAX (1, (int)(CH_SIZE*io_percent)); + io_size = MAX (1, (size_t)(CH_SIZE*io_percent)); printf ("Diag-rd %8d %8.2f", cache_size, io_percent); fflush (stdout); effic = test_diag (READ, cache_size, io_size, MAX (1, io_size/2)); @@ -506,7 +506,7 @@ main (void) for (io_percent=DIAG_START; io_percent<=DIAG_END; io_percent+=DIAG_DELTA) { - io_size = MAX (1, (int)(CH_SIZE*io_percent)); + io_size = MAX (1, (size_t)(CH_SIZE*io_percent)); printf ("Diag-wr %8d %8.2f", cache_size, io_percent); fflush (stdout); effic = test_diag (WRITE, cache_size, io_size, MAX (1, io_size/2)); diff --git a/perform/iopipe.c b/perform/iopipe.c index 9c3e256..dea98aa 100644 --- a/perform/iopipe.c +++ b/perform/iopipe.c @@ -317,7 +317,7 @@ printf("Before getrusage() call\n"); for (i=0; i=0 && (size_t)n==size[0]*size[1]); @@ -396,7 +396,7 @@ printf("Before getrusage() call\n"); for (i=0; i=0 && (size_t)n==size[0]*size[1]); diff --git a/perform/overhead.c b/perform/overhead.c index cea8dac..0723879 100644 --- a/perform/overhead.c +++ b/perform/overhead.c @@ -174,21 +174,21 @@ static int test(fill_t fill_style, const double splits[], hbool_t verbose, hbool_t use_rdcc) { - hid_t file, fapl, dcpl, xfer, mspace, fspace, dset; + hid_t file = (-1), fapl = (-1), dcpl = (-1), xfer = (-1), mspace = (-1), fspace = (-1), dset = (-1); hsize_t ch_size[1] = {1}; /*chunk size */ hsize_t cur_size[1] = {1000}; /*current dataset size */ hsize_t max_size[1] = {H5S_UNLIMITED}; /*maximum dataset size */ hssize_t hs_start[1]; /*hyperslab start offset*/ hsize_t hs_count[1] = {1}; /*hyperslab nelmts */ - int fd; /*h5 file direct */ + int fd = (-1); /*h5 file direct */ static int *had = NULL; /*for random filling */ - const char *sname; /*fill style nam */ + const char *sname=NULL; /*fill style nam */ int mdc_nelmts; /*num meta objs to cache*/ hsize_t i; int j; struct stat sb; - if (!had) had = calloc(cur_size[0], sizeof(int)); + if (!had) had = calloc((size_t)cur_size[0], sizeof(int)); if ((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) goto error; if (!use_rdcc) { if (H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL)<0) goto error; diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index f848fc3..8027edb 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -192,6 +192,8 @@ New Features several hyperslab selection calls). * Removed H5P(get|set)_hyper_cache API function, since the property is no longer used. + * Changed internal error handling macros to reduce code size of library by + about 10-20%. Platforms Tested ================ diff --git a/src/H5.c b/src/H5.c index d8dbe14..451eb0d 100644 --- a/src/H5.c +++ b/src/H5.c @@ -1725,157 +1725,158 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...) } else if (obj<0) { fprintf (out, "FAIL"); } else { - switch (H5I_get_type (obj)) { - case H5I_BADID: - fprintf (out, "%ld (error)", (long)obj); - break; - case H5I_FILE: - fprintf(out, "%ld", (long)obj); - if (HDstrcmp (argname, "file")) { - fprintf (out, " (file)"); - } - break; - case H5I_GROUP: - fprintf(out, "%ld", (long)obj); - if (HDstrcmp (argname, "group")) { - fprintf (out, " (group)"); - } - break; - case H5I_DATATYPE: - if (obj==H5T_NATIVE_SCHAR_g) { - fprintf(out, "H5T_NATIVE_SCHAR"); - } else if (obj==H5T_NATIVE_UCHAR_g) { - fprintf(out, "H5T_NATIVE_UCHAR"); - } else if (obj==H5T_NATIVE_SHORT_g) { - fprintf(out, "H5T_NATIVE_SHORT"); - } else if (obj==H5T_NATIVE_USHORT_g) { - fprintf(out, "H5T_NATIVE_USHORT"); - } else if (obj==H5T_NATIVE_INT_g) { - fprintf(out, "H5T_NATIVE_INT"); - } else if (obj==H5T_NATIVE_UINT_g) { - fprintf(out, "H5T_NATIVE_UINT"); - } else if (obj==H5T_NATIVE_LONG_g) { - fprintf(out, "H5T_NATIVE_LONG"); - } else if (obj==H5T_NATIVE_ULONG_g) { - fprintf(out, "H5T_NATIVE_ULONG"); - } else if (obj==H5T_NATIVE_LLONG_g) { - fprintf(out, "H5T_NATIVE_LLONG"); - } else if (obj==H5T_NATIVE_ULLONG_g) { - fprintf(out, "H5T_NATIVE_ULLONG"); - } else if (obj==H5T_NATIVE_FLOAT_g) { - fprintf(out, "H5T_NATIVE_FLOAT"); - } else if (obj==H5T_NATIVE_DOUBLE_g) { - fprintf(out, "H5T_NATIVE_DOUBLE"); - } else if (obj==H5T_NATIVE_LDOUBLE_g) { - fprintf(out, "H5T_NATIVE_LDOUBLE"); - } else if (obj==H5T_IEEE_F32BE_g) { - fprintf(out, "H5T_IEEE_F32BE"); - } else if (obj==H5T_IEEE_F32LE_g) { - fprintf(out, "H5T_IEEE_F32LE"); - } else if (obj==H5T_IEEE_F64BE_g) { - fprintf(out, "H5T_IEEE_F64BE"); - } else if (obj==H5T_IEEE_F64LE_g) { - fprintf(out, "H5T_IEEE_F64LE"); - } else if (obj==H5T_STD_I8BE_g) { - fprintf(out, "H5T_STD_I8BE"); - } else if (obj==H5T_STD_I8LE_g) { - fprintf(out, "H5T_STD_I8LE"); - } else if (obj==H5T_STD_I16BE_g) { - fprintf(out, "H5T_STD_I16BE"); - } else if (obj==H5T_STD_I16LE_g) { - fprintf(out, "H5T_STD_I16LE"); - } else if (obj==H5T_STD_I32BE_g) { - fprintf(out, "H5T_STD_I32BE"); - } else if (obj==H5T_STD_I32LE_g) { - fprintf(out, "H5T_STD_I32LE"); - } else if (obj==H5T_STD_I64BE_g) { - fprintf(out, "H5T_STD_I64BE"); - } else if (obj==H5T_STD_I64LE_g) { - fprintf(out, "H5T_STD_I64LE"); - } else if (obj==H5T_STD_U8BE_g) { - fprintf(out, "H5T_STD_U8BE"); - } else if (obj==H5T_STD_U8LE_g) { - fprintf(out, "H5T_STD_U8LE"); - } else if (obj==H5T_STD_U16BE_g) { - fprintf(out, "H5T_STD_U16BE"); - } else if (obj==H5T_STD_U16LE_g) { - fprintf(out, "H5T_STD_U16LE"); - } else if (obj==H5T_STD_U32BE_g) { - fprintf(out, "H5T_STD_U32BE"); - } else if (obj==H5T_STD_U32LE_g) { - fprintf(out, "H5T_STD_U32LE"); - } else if (obj==H5T_STD_U64BE_g) { - fprintf(out, "H5T_STD_U64BE"); - } else if (obj==H5T_STD_U64LE_g) { - fprintf(out, "H5T_STD_U64LE"); - } else if (obj==H5T_STD_B8BE_g) { - fprintf(out, "H5T_STD_B8BE"); - } else if (obj==H5T_STD_B8LE_g) { - fprintf(out, "H5T_STD_B8LE"); - } else if (obj==H5T_STD_B16BE_g) { - fprintf(out, "H5T_STD_B16BE"); - } else if (obj==H5T_STD_B16LE_g) { - fprintf(out, "H5T_STD_B16LE"); - } else if (obj==H5T_STD_B32BE_g) { - fprintf(out, "H5T_STD_B32BE"); - } else if (obj==H5T_STD_B32LE_g) { - fprintf(out, "H5T_STD_B32LE"); - } else if (obj==H5T_STD_B64BE_g) { - fprintf(out, "H5T_STD_B64BE"); - } else if (obj==H5T_STD_B64LE_g) { - fprintf(out, "H5T_STD_B64LE"); - } else if (obj==H5T_C_S1_g) { - fprintf(out, "H5T_C_S1"); - } else if (obj==H5T_FORTRAN_S1_g) { - fprintf(out, "H5T_FORTRAN_S1"); - } else { - fprintf(out, "%ld", (long)obj); - if (HDstrcmp (argname, "type")) { - fprintf (out, " (type)"); - } - } - break; - case H5I_DATASPACE: - fprintf(out, "%ld", (long)obj); - if (HDstrcmp (argname, "space")) { - fprintf (out, " (space)"); - } - /*Save the rank of simple data spaces for arrays*/ - { - H5S_t *space = H5I_object(obj); - if (H5S_SIMPLE==H5S_get_simple_extent_type(space)) { - asize[argno] = H5S_get_simple_extent_ndims(space); - } - } - break; - case H5I_DATASET: - fprintf(out, "%ld", (long)obj); - if (HDstrcmp (argname, "dset")) { - fprintf (out, " (dset)"); - } - break; - case H5I_ATTR: - fprintf(out, "%ld", (long)obj); - if (HDstrcmp (argname, "attr")) { - fprintf (out, " (attr)"); - } - break; - case H5I_TEMPBUF: - fprintf(out, "%ld", (long)obj); - if (HDstrcmp(argname, "tbuf")) { - fprintf(out, " (tbuf"); - } - break; - case H5I_REFERENCE: - fprintf(out, "%ld (reference)", (long)obj); - break; - case H5I_VFL: - fprintf(out, "%ld (file driver)", (long)obj); - break; - default: - fprintf(out, "%ld", (long)obj); - fprintf (out, " (unknown class)"); - break; + switch (H5I_GROUP(obj)) { /* Use internal H5I macro instead of function call */ + case H5I_BADID: + fprintf (out, "%ld (error)", (long)obj); + break; + case H5I_FILE: + fprintf(out, "%ld", (long)obj); + if (HDstrcmp (argname, "file")) { + fprintf (out, " (file)"); + } + break; + case H5I_GROUP: + fprintf(out, "%ld", (long)obj); + if (HDstrcmp (argname, "group")) { + fprintf (out, " (group)"); + } + break; + case H5I_DATATYPE: + if (obj==H5T_NATIVE_SCHAR_g) { + fprintf(out, "H5T_NATIVE_SCHAR"); + } else if (obj==H5T_NATIVE_UCHAR_g) { + fprintf(out, "H5T_NATIVE_UCHAR"); + } else if (obj==H5T_NATIVE_SHORT_g) { + fprintf(out, "H5T_NATIVE_SHORT"); + } else if (obj==H5T_NATIVE_USHORT_g) { + fprintf(out, "H5T_NATIVE_USHORT"); + } else if (obj==H5T_NATIVE_INT_g) { + fprintf(out, "H5T_NATIVE_INT"); + } else if (obj==H5T_NATIVE_UINT_g) { + fprintf(out, "H5T_NATIVE_UINT"); + } else if (obj==H5T_NATIVE_LONG_g) { + fprintf(out, "H5T_NATIVE_LONG"); + } else if (obj==H5T_NATIVE_ULONG_g) { + fprintf(out, "H5T_NATIVE_ULONG"); + } else if (obj==H5T_NATIVE_LLONG_g) { + fprintf(out, "H5T_NATIVE_LLONG"); + } else if (obj==H5T_NATIVE_ULLONG_g) { + fprintf(out, "H5T_NATIVE_ULLONG"); + } else if (obj==H5T_NATIVE_FLOAT_g) { + fprintf(out, "H5T_NATIVE_FLOAT"); + } else if (obj==H5T_NATIVE_DOUBLE_g) { + fprintf(out, "H5T_NATIVE_DOUBLE"); + } else if (obj==H5T_NATIVE_LDOUBLE_g) { + fprintf(out, "H5T_NATIVE_LDOUBLE"); + } else if (obj==H5T_IEEE_F32BE_g) { + fprintf(out, "H5T_IEEE_F32BE"); + } else if (obj==H5T_IEEE_F32LE_g) { + fprintf(out, "H5T_IEEE_F32LE"); + } else if (obj==H5T_IEEE_F64BE_g) { + fprintf(out, "H5T_IEEE_F64BE"); + } else if (obj==H5T_IEEE_F64LE_g) { + fprintf(out, "H5T_IEEE_F64LE"); + } else if (obj==H5T_STD_I8BE_g) { + fprintf(out, "H5T_STD_I8BE"); + } else if (obj==H5T_STD_I8LE_g) { + fprintf(out, "H5T_STD_I8LE"); + } else if (obj==H5T_STD_I16BE_g) { + fprintf(out, "H5T_STD_I16BE"); + } else if (obj==H5T_STD_I16LE_g) { + fprintf(out, "H5T_STD_I16LE"); + } else if (obj==H5T_STD_I32BE_g) { + fprintf(out, "H5T_STD_I32BE"); + } else if (obj==H5T_STD_I32LE_g) { + fprintf(out, "H5T_STD_I32LE"); + } else if (obj==H5T_STD_I64BE_g) { + fprintf(out, "H5T_STD_I64BE"); + } else if (obj==H5T_STD_I64LE_g) { + fprintf(out, "H5T_STD_I64LE"); + } else if (obj==H5T_STD_U8BE_g) { + fprintf(out, "H5T_STD_U8BE"); + } else if (obj==H5T_STD_U8LE_g) { + fprintf(out, "H5T_STD_U8LE"); + } else if (obj==H5T_STD_U16BE_g) { + fprintf(out, "H5T_STD_U16BE"); + } else if (obj==H5T_STD_U16LE_g) { + fprintf(out, "H5T_STD_U16LE"); + } else if (obj==H5T_STD_U32BE_g) { + fprintf(out, "H5T_STD_U32BE"); + } else if (obj==H5T_STD_U32LE_g) { + fprintf(out, "H5T_STD_U32LE"); + } else if (obj==H5T_STD_U64BE_g) { + fprintf(out, "H5T_STD_U64BE"); + } else if (obj==H5T_STD_U64LE_g) { + fprintf(out, "H5T_STD_U64LE"); + } else if (obj==H5T_STD_B8BE_g) { + fprintf(out, "H5T_STD_B8BE"); + } else if (obj==H5T_STD_B8LE_g) { + fprintf(out, "H5T_STD_B8LE"); + } else if (obj==H5T_STD_B16BE_g) { + fprintf(out, "H5T_STD_B16BE"); + } else if (obj==H5T_STD_B16LE_g) { + fprintf(out, "H5T_STD_B16LE"); + } else if (obj==H5T_STD_B32BE_g) { + fprintf(out, "H5T_STD_B32BE"); + } else if (obj==H5T_STD_B32LE_g) { + fprintf(out, "H5T_STD_B32LE"); + } else if (obj==H5T_STD_B64BE_g) { + fprintf(out, "H5T_STD_B64BE"); + } else if (obj==H5T_STD_B64LE_g) { + fprintf(out, "H5T_STD_B64LE"); + } else if (obj==H5T_C_S1_g) { + fprintf(out, "H5T_C_S1"); + } else if (obj==H5T_FORTRAN_S1_g) { + fprintf(out, "H5T_FORTRAN_S1"); + } else { + fprintf(out, "%ld", (long)obj); + if (HDstrcmp (argname, "type")) { + fprintf (out, " (type)"); + } + } + break; + case H5I_DATASPACE: + fprintf(out, "%ld", (long)obj); + if (HDstrcmp (argname, "space")) { + fprintf (out, " (space)"); + } + /* Save the rank of simple data spaces for arrays */ + /* This may generate recursive call to the library... -QAK */ + { + H5S_t *space = H5I_object(obj); + if (H5S_SIMPLE==H5S_get_simple_extent_type(space)) { + asize[argno] = H5S_get_simple_extent_ndims(space); + } + } + break; + case H5I_DATASET: + fprintf(out, "%ld", (long)obj); + if (HDstrcmp (argname, "dset")) { + fprintf (out, " (dset)"); + } + break; + case H5I_ATTR: + fprintf(out, "%ld", (long)obj); + if (HDstrcmp (argname, "attr")) { + fprintf (out, " (attr)"); + } + break; + case H5I_TEMPBUF: + fprintf(out, "%ld", (long)obj); + if (HDstrcmp(argname, "tbuf")) { + fprintf(out, " (tbuf"); + } + break; + case H5I_REFERENCE: + fprintf(out, "%ld (reference)", (long)obj); + break; + case H5I_VFL: + fprintf(out, "%ld (file driver)", (long)obj); + break; + default: + fprintf(out, "%ld", (long)obj); + fprintf (out, " (unknown class)"); + break; } } } @@ -2091,6 +2092,7 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...) H5P_genclass_t *pclass; /* Get the class name and print it */ + /* This may generate recursive call to the library... -QAK */ if(NULL != (pclass = H5I_object(pclass_id)) && (class_name=H5P_get_class_name(pclass))!=NULL) { fprintf (out, class_name); diff --git a/src/H5D.c b/src/H5D.c index 865a732..c4bd450 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -1977,7 +1977,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, H5S_sel_iter_t mem_iter; /*mem selection iteration info*/ H5S_sel_iter_t bkg_iter; /*background iteration info*/ H5S_sel_iter_t file_iter; /*file selection iter info*/ - herr_t ret_value = FAIL; /*return value */ + herr_t ret_value = SUCCEED; /*return value */ herr_t status; /*function return status*/ size_t src_type_size; /*size of source type */ size_t dst_type_size; /*size of destination type*/ @@ -1998,7 +1998,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, H5O_pline_t pline; H5O_efl_t efl; H5O_fill_t fill; - H5P_genplist_t *dx_plist; /* Property list */ + H5P_genplist_t *dx_plist=NULL; /* Property list */ H5P_genplist_t *dc_plist; /* Property list */ @@ -2136,7 +2136,7 @@ printf("%s: check 1.1, \n",FUNC); H5T_get_size(dataset->type); sconv->stats[1].read_ncalls++; #endif - goto succeed; + HGOTO_DONE(SUCCEED); } #ifdef H5D_DEBUG if (H5DEBUG(D)) { @@ -2382,10 +2382,7 @@ printf("%s: check 2.0, src_type_size=%d, dst_type_size=%d, target_size=%d, min_e #endif /* QAK */ } - succeed: - ret_value = SUCCEED; - - done: +done: #ifdef H5_HAVE_PARALLEL /* restore xfer_mode due to the kludge */ if (doing_mpio && xfer_mode_changed){ @@ -2408,6 +2405,7 @@ printf("%s: check 2.0, src_type_size=%d, dst_type_size=%d, target_size=%d, min_e H5I_dec_ref(src_id); if (dst_id >= 0) H5I_dec_ref(dst_id); + assert(dx_plist); if (tconv_buf && NULL==H5P_peek_voidp(dx_plist,H5D_XFER_TCONV_BUF_NAME)) H5FL_BLK_FREE(type_conv,tconv_buf); if (bkg_buf && NULL==H5P_peek_voidp(dx_plist,H5D_XFER_BKGR_BUF_NAME)) @@ -2468,7 +2466,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, H5S_sel_iter_t mem_iter; /*memory selection iteration info*/ H5S_sel_iter_t bkg_iter; /*background iteration info*/ H5S_sel_iter_t file_iter; /*file selection iteration info*/ - herr_t ret_value = FAIL; /*return value */ + herr_t ret_value = SUCCEED; /*return value */ herr_t status; /*function return status*/ size_t src_type_size; /*size of source type */ size_t dst_type_size; /*size of destination type*/ @@ -2489,7 +2487,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, H5O_pline_t pline; H5O_efl_t efl; H5O_fill_t fill; - H5P_genplist_t *dx_plist; /* Property list */ + H5P_genplist_t *dx_plist=NULL; /* Property list */ H5P_genplist_t *dc_plist; /* Property list */ FUNC_ENTER(H5D_write, FAIL); @@ -2647,7 +2645,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, sconv->stats[0].write_nbytes += nelmts * H5T_get_size(mem_type); sconv->stats[0].write_ncalls++; #endif - goto succeed; + HGOTO_DONE(SUCCEED); } #ifdef H5D_DEBUG if (H5DEBUG(D)) { @@ -2874,10 +2872,7 @@ printf("%s: check 2.0, src_type_size=%d, dst_type_size=%d, target_size=%d\n",FUN "unable to update modification time"); } - succeed: - ret_value = SUCCEED; - - done: +done: #ifdef H5_HAVE_PARALLEL /* restore xfer_mode due to the kludge */ if (doing_mpio && xfer_mode_changed){ @@ -2900,6 +2895,7 @@ printf("%s: check 2.0, src_type_size=%d, dst_type_size=%d, target_size=%d\n",FUN H5I_dec_ref(src_id); if (dst_id >= 0) H5I_dec_ref(dst_id); + assert(dx_plist); if (tconv_buf && NULL==H5P_peek_voidp(dx_plist,H5D_XFER_TCONV_BUF_NAME)) H5FL_BLK_FREE(type_conv,tconv_buf); if (bkg_buf && NULL==H5P_peek_voidp(dx_plist,H5D_XFER_BKGR_BUF_NAME)) diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 8003730..a201111 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -38,15 +38,10 @@ */ #define HRETURN_ERROR(maj, min, ret_val, str) { \ HERROR (maj, min, str); \ - PABLO_TRACE_OFF (PABLO_MASK, pablo_func_id); \ - H5TRACE_RETURN(ret_val); \ if (H5_IS_API(FUNC) && H5E_auto_g) { \ (H5E_auto_g)(H5E_auto_data_g); \ } \ - H5_API_UNLOCK_BEGIN \ - H5_API_UNLOCK_END \ - H5_API_SET_CANCEL \ - return (ret_val); \ + HRETURN(ret_val); \ } /* @@ -72,7 +67,6 @@ */ #define HGOTO_ERROR(maj, min, ret_val, str) { \ HERROR (maj, min, str); \ - H5TRACE_RETURN(ret_val); \ if (H5_IS_API(FUNC) && H5E_auto_g) { \ (H5E_auto_g)(H5E_auto_data_g); \ } \ diff --git a/src/H5F.c b/src/H5F.c index b98eae8..4e1e262 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -632,7 +632,7 @@ done: *------------------------------------------------------------------------- */ static int -H5F_flush_all_cb(H5F_t *f, hid_t fid, const void *_invalidate) +H5F_flush_all_cb(H5F_t *f, hid_t UNUSED fid, const void *_invalidate) { hbool_t invalidate = *((const hbool_t*)_invalidate); H5F_flush(f, H5F_SCOPE_LOCAL, invalidate, FALSE); @@ -1064,7 +1064,9 @@ H5F_get_objects(H5F_t *f, unsigned types, hid_t *obj_id_list, H5I_search(H5I_DATATYPE, (H5I_search_func_t)H5F_get_objects_cb, olist); } +#ifdef LATER done: +#endif /* LATER */ if(olist!=NULL) H5MM_xfree(olist); FUNC_LEAVE(ret_value); @@ -1118,12 +1120,14 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_DATATYPE: ent = H5T_entof((H5T_t*)obj_ptr); break; + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "unknown data object"); } - if( (!olist->shared && olist->obj_type==H5I_DATATYPE && - H5T_is_immutable((H5T_t*)obj_ptr)==FALSE) - || (!olist->shared && olist->obj_type!=H5I_DATATYPE) - || (ent && ent->file->shared == olist->shared) ) { + if( (!olist->shared && olist->obj_type==H5I_DATATYPE && H5T_is_immutable((H5T_t*)obj_ptr)==FALSE) + || (!olist->shared && olist->obj_type!=H5I_DATATYPE) + || (ent && ent->file->shared == olist->shared) ) { if(olist->obj_id_list) { olist->obj_id_list[olist->list_index] = obj_id; olist->list_index++; @@ -1156,7 +1160,7 @@ done: *------------------------------------------------------------------------- */ static int -H5F_equal(void *_haystack, UNUSED hid_t id, const void *_needle) +H5F_equal(void *_haystack, hid_t UNUSED id, const void *_needle) { H5F_t *haystack = (H5F_t*)_haystack; const H5FD_t *needle = (const H5FD_t*)_needle; diff --git a/src/H5G.c b/src/H5G.c index 80e17f0..16476e8 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -807,8 +807,7 @@ H5G_register_type(int type, htri_t(*isa)(H5G_entry_t*), const char *_desc) H5G_type_g[i].isa = isa; H5MM_xfree(H5G_type_g[i].desc); H5G_type_g[i].desc = desc; - ret_value = SUCCEED; - goto done; + HGOTO_DONE(SUCCEED); } } diff --git a/src/H5I.c b/src/H5I.c index 65815a4..1f47030 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -43,60 +43,9 @@ static int interface_initialize_g = 0; #define INTERFACE_INIT H5I_init_interface static herr_t H5I_init_interface(void); -/* - * Define the following macro for fast hash calculations (but limited - * hash sizes) - */ -#define HASH_SIZE_POWER_2 - -/* Define the following macro for atom caching over all the atoms */ -#define IDS_ARE_CACHED - /*-------------------- Locally scoped variables -----------------------------*/ #ifdef IDS_ARE_CACHED -# define ID_CACHE_SIZE 4 /*# of previous atoms cached */ -#endif - -/* - * Number of bits to use for Group ID in each atom. Increase if H5I_NGROUPS - * becomes too large (an assertion would fail in H5I_init_interface). This is - * the only number that must be changed since all other bit field sizes and - * masks are calculated from GROUP_BITS. - */ -#define GROUP_BITS 5 -#define GROUP_MASK ((1<>ID_BITS) & GROUP_MASK)) - - -#ifdef HASH_SIZE_POWER_2 -/* - * Map an ID to a hash location (assumes s is a power of 2 and smaller - * than the ID_MASK constant). - */ -# define H5I_LOC(a,s) ((hid_t)((size_t)(a)&((s)-1))) -# define POWER_OF_TWO(n) ((((n) - 1) & (n)) == 0 && (n) > 0) -#else -/* - * Map an ID to a hash location. - */ -# define H5I_LOC(a,s) (((hid_t)(a)&ID_MASK)%(s)) -#endif - -/* Combine a Group number and an atom index into an atom */ -#define H5I_MAKE(g,i) ((((hid_t)(g)&GROUP_MASK)<>ID_BITS) & GROUP_MASK)) + +#ifdef HASH_SIZE_POWER_2 +/* + * Map an ID to a hash location (assumes s is a power of 2 and smaller + * than the ID_MASK constant). + */ +# define H5I_LOC(a,s) ((hid_t)((size_t)(a)&((s)-1))) +# define POWER_OF_TWO(n) ((((n) - 1) & (n)) == 0 && (n) > 0) +#else +/* + * Map an ID to a hash location. + */ +# define H5I_LOC(a,s) (((hid_t)(a)&ID_MASK)%(s)) +#endif + +/* Combine a Group number and an atom index into an atom */ +#define H5I_MAKE(g,i) ((((hid_t)(g)&GROUP_MASK)<extent.type) - goto fall_through; + HGOTO_DONE(SUCCEED); if (H5S_SIMPLE!=file_space->extent.type) - goto fall_through; + HGOTO_DONE(SUCCEED); if (mem_space->extent.u.simple.rank!=file_space->extent.u.simple.rank) - goto fall_through; + HGOTO_DONE(SUCCEED); /* Check for a single hyperslab block defined in memory dataspace */ if (mem_space->select.type==H5S_SEL_HYPERSLABS) { @@ -435,7 +436,7 @@ printf("%s: check 1.0\n",FUNC); count*=mem_space->select.sel_info.hslab.diminfo[u].count; /* If the regular hyperslab definition creates more than one hyperslab, fall through */ if(count>1) - goto fall_through; + HGOTO_DONE(SUCCEED); } /* end if */ else { /* Get the pointer to the hyperslab spans to check */ @@ -445,7 +446,7 @@ printf("%s: check 1.0\n",FUNC); while(mem_span!=NULL) { /* If there are more than one span in the dimension, we can't use this routine */ if(mem_span->next!=NULL) - goto fall_through; + HGOTO_DONE(SUCCEED); /* Advance to the next span, if it's available */ if(mem_span->down==NULL) @@ -460,7 +461,7 @@ printf("%s: check 1.0\n",FUNC); } /* end if */ else if(mem_space->select.type!=H5S_SEL_ALL) - goto fall_through; + HGOTO_DONE(SUCCEED); /* Check for a single hyperslab block defined in file dataspace */ if (file_space->select.type==H5S_SEL_HYPERSLABS) { @@ -471,7 +472,7 @@ printf("%s: check 1.0\n",FUNC); count*=file_space->select.sel_info.hslab.diminfo[u].count; /* If the regular hyperslab definition creates more than one hyperslab, fall through */ if(count>1) - goto fall_through; + HGOTO_DONE(SUCCEED); } /* end if */ else { /* Get the pointer to the hyperslab spans to check */ @@ -481,7 +482,7 @@ printf("%s: check 1.0\n",FUNC); while(file_span!=NULL) { /* If there are more than one span in the dimension, we can't use this routine */ if(file_span->next!=NULL) - goto fall_through; + HGOTO_DONE(SUCCEED); /* Advance to the next span, if it's available */ if(file_span->down==NULL) @@ -496,7 +497,7 @@ printf("%s: check 1.0\n",FUNC); } /* end if */ else if(file_space->select.type!=H5S_SEL_ALL) - goto fall_through; + HGOTO_DONE(SUCCEED); /* Get information about memory and file */ for (u=0; uextent.u.simple.rank; u++) { @@ -535,7 +536,7 @@ printf("%s: check 1.0\n",FUNC); } /* end else */ if (mem_size!=file_size) - goto fall_through; + HGOTO_DONE(SUCCEED); size[u] = file_size; file_offset[u] = file_off; @@ -608,7 +609,7 @@ printf("%s: check 1.0\n",FUNC); } /* end if */ else { /* Non-contiguous hyperslab block */ - goto fall_through; + HGOTO_DONE(SUCCEED); } /* end else */ } /* end if */ @@ -624,12 +625,12 @@ for (u=0; u<=mem_space->extent.u.simple.rank; u++) /* Read data from the file */ if (H5F_arr_read(f, dxpl_id, layout, pline, NULL, efl, size, size, mem_offset, file_offset, buf/*out*/)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read data from the file"); } *must_convert = FALSE; -fall_through: +done: FUNC_LEAVE(SUCCEED); } @@ -679,17 +680,18 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout, int i; size_t down_size[H5O_LAYOUT_NDIMS]; hsize_t acc; + herr_t ret_value=SUCCEED; FUNC_ENTER(H5S_all_write, FAIL); *must_convert = TRUE; /* Check whether we can handle this */ if (H5S_SIMPLE!=mem_space->extent.type) - goto fall_through; + HGOTO_DONE(SUCCEED); if (H5S_SIMPLE!=file_space->extent.type) - goto fall_through; + HGOTO_DONE(SUCCEED); if (mem_space->extent.u.simple.rank!=file_space->extent.u.simple.rank) - goto fall_through; + HGOTO_DONE(SUCCEED); /* Check for a single hyperslab block defined in memory dataspace */ if (mem_space->select.type==H5S_SEL_HYPERSLABS) { @@ -700,7 +702,7 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout, count*=mem_space->select.sel_info.hslab.diminfo[u].count; /* If the regular hyperslab definition creates more than one hyperslab, fall through */ if(count>1) - goto fall_through; + HGOTO_DONE(SUCCEED); } /* end if */ else { /* Get the pointer to the hyperslab spans to check */ @@ -710,7 +712,7 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout, while(mem_span!=NULL) { /* If there are more than one span in the dimension, we can't use this routine */ if(mem_span->next!=NULL) - goto fall_through; + HGOTO_DONE(SUCCEED); /* Advance to the next span, if it's available */ if(mem_span->down==NULL) @@ -725,7 +727,7 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout, } /* end if */ else if(mem_space->select.type!=H5S_SEL_ALL) - goto fall_through; + HGOTO_DONE(SUCCEED); /* Check for a single hyperslab block defined in file dataspace */ if (file_space->select.type==H5S_SEL_HYPERSLABS) { @@ -736,7 +738,7 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout, count*=file_space->select.sel_info.hslab.diminfo[u].count; /* If the regular hyperslab definition creates more than one hyperslab, fall through */ if(count>1) - goto fall_through; + HGOTO_DONE(SUCCEED); } /* end if */ else { /* Get the pointer to the hyperslab spans to check */ @@ -746,7 +748,7 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout, while(file_span!=NULL) { /* If there are more than one span in the dimension, we can't use this routine */ if(file_span->next!=NULL) - goto fall_through; + HGOTO_DONE(SUCCEED); /* Advance to the next span, if it's available */ if(file_span->down==NULL) @@ -761,7 +763,7 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout, } /* end if */ else if(file_space->select.type!=H5S_SEL_ALL) - goto fall_through; + HGOTO_DONE(SUCCEED); /* Get information about memory and file */ for (u=0; uextent.u.simple.rank; u++) { @@ -800,7 +802,7 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout, } /* end else */ if (mem_size!=file_size) - goto fall_through; + HGOTO_DONE(SUCCEED); size[u] = file_size; file_offset[u] = file_off; @@ -873,20 +875,20 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout, } /* end if */ else { /* Non-contiguous hyperslab block */ - goto fall_through; + HGOTO_DONE(SUCCEED); } /* end else */ } /* end if */ /* Write data to the file */ if (H5F_arr_write(f, dxpl_id, layout, pline, NULL, efl, size, size, mem_offset, file_offset, buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write data to the file"); } *must_convert = FALSE; -fall_through: +done: FUNC_LEAVE(SUCCEED); } diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 8be16e9..7e11f7e 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -410,7 +410,7 @@ H5S_hyper_fread (H5F_t *f, const struct H5O_layout_t *layout, int curr_dim; /* Current dimension being operated on */ int ndims; /* Number of dimensions of dataset */ hsize_t loc_off; /* Element offset in the dataspace */ - size_t span_size; /* Number of bytes in current span to actually process */ + size_t span_size=0; /* Number of bytes in current span to actually process */ size_t io_bytes_left; /* Number of bytes left to process */ int i; /* Index variable */ size_t *seq_len_arr=NULL; /* Array of sequence lengths */ @@ -1509,7 +1509,7 @@ H5S_hyper_fwrite (H5F_t *f, const struct H5O_layout_t *layout, int curr_dim; /* Current dimension being operated on */ int ndims; /* Number of dimensions of dataset */ hsize_t loc_off; /* Element offset in the dataspace */ - size_t span_size; /* Number of bytes in current span to actually process */ + size_t span_size=0; /* Number of bytes in current span to actually process */ size_t io_bytes_left; /* Number of bytes left to process */ int i; /* Index variable */ size_t *seq_len_arr=NULL; /* Array of sequence lengths */ @@ -2599,7 +2599,7 @@ H5S_hyper_mread (const void *_buf, size_t elmt_size, const H5S_t *space, int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ int curr_dim; /* Current dimension being operated on */ int ndims; /* Number of dimensions of dataset */ - size_t span_size; /* Number of bytes in current span to actually process */ + size_t span_size=0; /* Number of bytes in current span to actually process */ size_t io_bytes_left; /* Number of bytes left to process */ int i; /* Index variable */ hssize_t ret_value=FAIL; @@ -3472,7 +3472,7 @@ H5S_hyper_mwrite (const void *_tconv_buf, size_t elmt_size, const H5S_t *space, int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ int curr_dim; /* Current dimension being operated on */ int ndims; /* Number of dimensions of dataset */ - size_t span_size; /* Number of bytes in current span to actually process */ + size_t span_size=0; /* Number of bytes in current span to actually process */ size_t io_bytes_left; /* Number of bytes left to process */ int i; /* Index variable */ hssize_t ret_value=FAIL; diff --git a/src/H5Smpio.c b/src/H5Smpio.c index 89eadd6..a473c8c 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -424,7 +424,7 @@ H5S_mpio_hyper_type( const H5S_t *space, const size_t elmt_size, /* fill in the remaining return values */ *count = 1; /* only have to move one of these suckers! */ *is_derived_type = 1; - goto done; + HGOTO_DONE(SUCCEED); empty: /* special case: empty hyperslab */ diff --git a/src/H5T.c b/src/H5T.c index f0d11eb..c778f26 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -1924,7 +1924,7 @@ done: *------------------------------------------------------------------------- */ static int -H5T_unlock_cb (void *_dt, hid_t id, const void * UNUSED key) +H5T_unlock_cb (void *_dt, hid_t UNUSED id, const void * UNUSED key) { H5T_t *dt = (H5T_t *)_dt; diff --git a/src/H5private.h b/src/H5private.h index 672098a..9888bd9 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1024,7 +1024,6 @@ extern hbool_t H5_libinit_g; /* Has the library been initialized? */ #define FUNC_ENTER_INIT(func_name,interface_init_func,err) { \ CONSTR (FUNC, #func_name); \ PABLO_SAVE (ID_ ## func_name) \ - static unsigned know_api=0, is_api=0; \ H5TRACE_DECL; \ \ PABLO_TRACE_ON (PABLO_MASK, pablo_func_id); \ @@ -1055,14 +1054,8 @@ extern hbool_t H5_libinit_g; /* Has the library been initialized? */ } \ } \ \ - /* Check if we know this is an API function yet or not */ \ - if(!know_api) { \ - know_api=1; \ - is_api=H5_IS_API(FUNC); \ - } \ - \ /* Clear thread error stack entering public functions */ \ - if (is_api && H5E_clearable_g) { \ + if (H5_IS_API(FUNC) && H5E_clearable_g) { \ H5E_clear (); \ } \ { diff --git a/test/tfile.c b/test/tfile.c index 98da5e7..2b1eb28 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -363,13 +363,12 @@ test_file_open(void) ** *****************************************************************/ static void -test_file_close() +test_file_close(void) { hid_t fid1, fid2; hid_t fapl_id, access_id; hid_t dataset_id, group_id1, group_id2, group_id3; H5F_close_degree_t fc_degree; - unsigned fid_count, oid_count; herr_t ret; /* Test behavior while opening file multiple times with different @@ -620,6 +619,9 @@ test_file_close() ret = H5Gclose(group_id3); CHECK(ret, FAIL, "H5Gclose"); break; + default: + CHECK(fc_degree, H5F_CLOSE_DEFAULT, "H5Pget_fclose_degree"); + break; } /* Close file access property list */ diff --git a/test/tgenprop.c b/test/tgenprop.c index c302e81..163ccf7 100644 --- a/test/tgenprop.c +++ b/test/tgenprop.c @@ -381,7 +381,7 @@ test_genprop_cls_cb1(hid_t list_id, void *create_data) } static herr_t -test_genprop_cls_cb2(hid_t new_list_id, hid_t old_list_id, void *create_data) +test_genprop_cls_cb2(hid_t new_list_id, hid_t UNUSED old_list_id, void *create_data) { struct { /* Struct for iterations */ int count; -- cgit v0.12