From 4fe4a51818747e067919c5d9b043395a2f4d04dc Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 9 Jul 2003 09:34:35 -0500 Subject: [svn-r7186] Purpose: Code cleanup Description: More tweaks to clean up warnings from lint. Platforms tested: FreeBSD 4.8 (sleipnir) not major enough to h5committest --- src/H5.c | 122 +++++++++++++++++++++++++++++-------------------------- src/H5A.c | 12 ++---- src/H5Apkg.h | 4 +- src/H5E.c | 1 + src/H5Epublic.h | 3 +- src/H5FL.c | 14 +++++-- src/H5I.c | 16 ++++---- src/H5Ipkg.h | 2 +- src/H5Oattr.c | 13 ++---- src/H5Oprivate.h | 6 +-- src/H5private.h | 2 +- 11 files changed, 99 insertions(+), 96 deletions(-) diff --git a/src/H5.c b/src/H5.c index 72ea2a8..e72942c 100644 --- a/src/H5.c +++ b/src/H5.c @@ -14,6 +14,10 @@ #define H5I_PACKAGE /*suppress error about including H5Ipkg */ +/* Pablo information */ +/* (Put before include files to avoid problems with inline functions) */ +#define PABLO_MASK H5_mask + #include "H5private.h" /* Generic Functions */ #include "H5Bprivate.h" /* B-link trees */ #include "H5Dprivate.h" /* Datasets */ @@ -36,8 +40,6 @@ # include #endif -#define PABLO_MASK H5_mask - /* statically initialize block for pthread_once call used in initializing */ /* the first global mutex */ #ifdef H5_HAVE_THREADSAFE @@ -78,7 +80,7 @@ H5_init_library(void) { herr_t ret_value=SUCCEED; - FUNC_ENTER_NOAPI(H5_init_library, FAIL); + FUNC_ENTER_NOAPI(H5_init_library, FAIL) /* * Make sure the package information is updated. */ @@ -127,7 +129,7 @@ H5_init_library(void) * adding it again later if the library is cosed and reopened. */ if (!dont_atexit_g) { - HDatexit(H5_term_library); + (void)HDatexit(H5_term_library); dont_atexit_g = TRUE; } @@ -140,22 +142,22 @@ H5_init_library(void) * property classes. */ if (H5P_init()<0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface"); + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface") if (H5F_init()<0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize file interface"); + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize file interface") if (H5T_init()<0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize datatype interface"); + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize datatype interface") if (H5D_init()<0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize dataset interface"); + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize dataset interface") if (H5AC_init()<0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize metadata caching interface"); + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize metadata caching interface") /* Debugging? */ H5_debug_mask("-all"); H5_debug_mask(HDgetenv("HDF5_DEBUG")); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -194,7 +196,7 @@ H5_term_library(void) goto done; /* Check if we should display error output */ - H5Eget_auto(&func,NULL); + (void)H5Eget_auto(&func,NULL); /* * Terminate each interface. The termination functions return a positive @@ -206,8 +208,8 @@ H5_term_library(void) (sprintf(loop+at, "%s%s", at?",":"", #F), \ at += HDstrlen(loop+at), \ n): \ - ((n>0 && at+50 && at+50) { sprintf(format_templ+HDstrlen(format_templ), "%d", fwidth); } + /*lint --e{506} Don't issue warnings about constant value booleans */ + /*lint --e{774} Don't issue warnings boolean within 'if' always evaluates false/true */ if (sizeof(x)==H5_SIZEOF_INT) { HDstrcat(format_templ, "d"); } else if (sizeof(x)==H5_SIZEOF_LONG) { @@ -1062,7 +1070,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) break; case 'c': - if (1) { + { char x = (char)va_arg (ap, int); n = fprintf (stream, format_templ, x); } @@ -1070,17 +1078,15 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 's': case 'p': - if (1) { + { char *x = va_arg (ap, char*); n = fprintf (stream, format_templ, x); } break; case 'n': - if (1) { - format_templ[HDstrlen(format_templ)-1] = 'u'; - n = fprintf (stream, format_templ, nout); - } + format_templ[HDstrlen(format_templ)-1] = 'u'; + n = fprintf (stream, format_templ, nout); break; default: @@ -1166,7 +1172,7 @@ HDstrtoll(const char *s, const char **rest, int base) } else if ('-'==*s) { sign = -1; s++; - } + } /* Zero base prefix */ if (0==base && '0'==*s && ('x'==s[1] || 'X'==s[1])) { @@ -1187,8 +1193,8 @@ HDstrtoll(const char *s, const char **rest, int base) if (!overflow) { int64_t digit = 0; if (*s>='0' && *s<='9') digit = *s - '0'; - else if (*s>='a' && *s<='z') digit = *s-'a'+10; - else digit = *s-'A'+10; + else if (*s>='a' && *s<='z') digit = (*s-'a')+10; + else digit = (*s-'A')+10; if (acc*base+digit < acc) { overflow = TRUE; @@ -1437,7 +1443,7 @@ H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds) *------------------------------------------------------------------------- */ double -H5_trace (double *returning, const char *func, const char *type, ...) +H5_trace (const double *returning, const char *func, const char *type, ...) { va_list ap; char buf[64], *rest; @@ -1448,7 +1454,7 @@ H5_trace (double *returning, const char *func, const char *type, ...) void *vp = NULL; FILE *out = H5_debug_g.trace; H5_timer_t event_time; - static H5_timer_t first_time; + static H5_timer_t first_time = {0.0, 0.0, 0.0}; static int current_depth=0; static int last_call_depth=0; @@ -1528,7 +1534,7 @@ H5_trace (double *returning, const char *func, const char *type, ...) assert(']'==*rest); type = rest+1; } else { - rest = HDstrchr(type, ']'); + rest = (char *)HDstrchr(type, ']'); assert(rest); type = rest+1; asize_idx = -1; @@ -1544,7 +1550,7 @@ H5_trace (double *returning, const char *func, const char *type, ...) */ argname = va_arg (ap, char*); if (argname) { - unsigned n = MAX (0, (int)HDstrlen(argname)-3); + unsigned n = (unsigned)MAX (0, (int)HDstrlen(argname)-3); /*lint !e666 Allow expression with side effects */ if (!HDstrcmp (argname+n, "_id")) { HDstrncpy (buf, argname, MIN ((int)sizeof(buf)-1, n)); buf[MIN((int)sizeof(buf)-1, n)] = '\0'; @@ -2004,7 +2010,7 @@ H5_trace (double *returning, const char *func, const char *type, ...) } else if (obj<0) { fprintf (out, "FAIL"); } else { - switch (H5I_GROUP(obj)) { /* Use internal H5I macro instead of function call */ + switch (H5I_GRP(obj)) { /* Use internal H5I macro instead of function call */ case H5I_BADID: fprintf (out, "%ld (error)", (long)obj); break; @@ -2190,10 +2196,10 @@ H5_trace (double *returning, const char *func, const char *type, ...) if (vp) { fprintf (out, "0x%lx", (unsigned long)vp); if (asize_idx>=0 && asize[asize_idx]>=0) { - int *p = (int*)vp; + unsigned *p = (unsigned*)vp; fprintf(out, " {"); for (i=0; i=0 && asize[asize_idx]>=0) { + if (asize_idx>=0 && asize[asize_idx]>=0) { ssize_t *p = (ssize_t*)vp; fprintf(out, " {"); for (i=0; iname=%s, head->allocated=%d\n", H5FL_arr_gc_head.fi herr_t H5FL_garbage_coll(void) { + herr_t ret_value = SUCCEED; + FUNC_ENTER_NOINIT(H5FL_garbage_coll); /* Garbage collect the free lists for array objects */ - H5FL_arr_gc(); + if(H5FL_arr_gc()<0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect array objects") /* Garbage collect free lists for blocks */ - H5FL_blk_gc(); + if(H5FL_blk_gc()<0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect block objects") /* Garbage collect the free lists for regular objects */ - H5FL_reg_gc(); + if(H5FL_reg_gc()<0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect regular objects") - FUNC_LEAVE_NOAPI(SUCCEED); +done: + FUNC_LEAVE_NOAPI(ret_value); } /* end H5FL_garbage_coll() */ diff --git a/src/H5I.c b/src/H5I.c index 4049843..7f255a3 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -403,7 +403,7 @@ H5I_clear_group(H5I_type_t grp, hbool_t force) * Remove atoms from the global atom cache. */ for (i=0; iid) == grp) + if (H5I_cache_g[i] && H5I_GRP(H5I_cache_g[i]->id) == grp) H5I_cache_g[i] = NULL; } #endif /* IDS_ARE_CACHED */ @@ -740,7 +740,7 @@ H5I_object_verify(hid_t id, H5I_type_t id_type) assert(id_type>=H5I_FILE && id_typeobj_ptr; } /* end if */ @@ -777,7 +777,7 @@ H5I_get_type(hid_t id) FUNC_ENTER_NOAPI(H5I_get_type, H5I_BADID); if (id>0) - ret_value = H5I_GROUP(id); + ret_value = H5I_GRP(id); assert(ret_value>=H5I_BADID && ret_value= H5I_NGROUPS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; @@ -950,7 +950,7 @@ done: int H5I_dec_ref(hid_t id) { - H5I_type_t grp = H5I_GROUP(id); /*group the object is in*/ + H5I_type_t grp = H5I_GRP(id); /*group the object is in*/ H5I_id_group_t *grp_ptr = NULL; /*ptr to the group */ H5I_id_info_t *id_ptr = NULL; /*ptr to the new ID */ int ret_value=FAIL; /*return value */ @@ -1011,7 +1011,7 @@ done: int H5I_inc_ref(hid_t id) { - H5I_type_t grp = H5I_GROUP(id); /*group the object is in*/ + H5I_type_t grp = H5I_GRP(id); /*group the object is in*/ H5I_id_group_t *grp_ptr = NULL; /*ptr to the group */ H5I_id_info_t *id_ptr = NULL; /*ptr to the ID */ int ret_value; /* Return value */ @@ -1126,7 +1126,7 @@ H5I_find_id(hid_t id) FUNC_ENTER_NOINIT(H5I_find_id); /* Check arguments */ - grp = H5I_GROUP(id); + grp = H5I_GRP(id); if (grp <= H5I_BADID || grp >= H5I_NGROUPS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; @@ -1283,7 +1283,7 @@ H5I_debug(H5I_type_t grp) /* Cache */ fprintf(stderr, " Cache:\n"); for (is=0; isid)==grp) { + if (H5I_cache_g[is] && H5I_GRP(H5I_cache_g[is]->id)==grp) { fprintf(stderr, " Entry-%d, ID=%lu\n", is, (unsigned long)(H5I_cache_g[is]->id)); } diff --git a/src/H5Ipkg.h b/src/H5Ipkg.h index dc6d55a..aab865c 100644 --- a/src/H5Ipkg.h +++ b/src/H5Ipkg.h @@ -53,7 +53,7 @@ #define ID_MASK ((1<>ID_BITS) & GROUP_MASK)) +#define H5I_GRP(a) ((H5I_type_t)(((hid_t)(a)>>ID_BITS) & GROUP_MASK)) /****************************/ diff --git a/src/H5Oattr.c b/src/H5Oattr.c index df6e740..f1217a9 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -16,6 +16,10 @@ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #define H5S_PACKAGE /*suppress error about including H5Spkg */ +/* Pablo information */ +/* (Put before include files to avoid problems with inline functions) */ +#define PABLO_MASK H5O_attr_mask + #include "H5private.h" /* Generic Functions */ #include "H5Apkg.h" /* Attributes */ #include "H5Eprivate.h" /* Error handling */ @@ -25,8 +29,6 @@ #include "H5Opkg.h" /* Object headers */ #include "H5Spkg.h" /* Dataspaces */ -#define PABLO_MASK H5O_attr_mask - /* PRIVATE PROTOTYPES */ static herr_t H5O_attr_encode (H5F_t *f, uint8_t *p, const void *mesg); static void *H5O_attr_decode (H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh); @@ -170,13 +172,6 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED * /* Indicate that the fill values aren't to be written out */ attr->initialized=1; -#ifdef LOTSLATER - if (hobj) { - attr->sh_heap = *hobj; - attr->sh_file = f; - } -#endif - /* Set return value */ ret_value=attr; diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index c19550f..d9d4e4f 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -35,9 +35,9 @@ #include "H5Spublic.h" /* Dataspace functions */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic functions */ -#include "H5HGprivate.h" /* Global heap functions */ -#include "H5Tprivate.h" /* Datatype functions */ +#include "H5private.h" /* Generic functions */ +#include "H5HGprivate.h" /* Global heap functions */ +#include "H5Tprivate.h" /* Datatype functions */ #include "H5Zprivate.h" /* I/O pipeline filters */ /* Object header macros */ diff --git a/src/H5private.h b/src/H5private.h index 7a709ef..fc73a6d 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -979,7 +979,7 @@ extern H5_debug_t H5_debug_g; #define H5TRACE_RETURN(V) /*void*/ #endif -H5_DLL double H5_trace(double *calltime, const char *func, const char *type, ...); +H5_DLL double H5_trace(const double *calltime, const char *func, const char *type, ...); /*------------------------------------------------------------------------- -- cgit v0.12