diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-07-09 14:34:35 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-07-09 14:34:35 (GMT) |
commit | 4fe4a51818747e067919c5d9b043395a2f4d04dc (patch) | |
tree | c300d737bfb6e5f1d2c09f90f60d87ea104018d7 /src/H5.c | |
parent | 5fbe02e72106b53e7dcad898984255b92190b476 (diff) | |
download | hdf5-4fe4a51818747e067919c5d9b043395a2f4d04dc.zip hdf5-4fe4a51818747e067919c5d9b043395a2f4d04dc.tar.gz hdf5-4fe4a51818747e067919c5d9b043395a2f4d04dc.tar.bz2 |
[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
Diffstat (limited to 'src/H5.c')
-rw-r--r-- | src/H5.c | 122 |
1 files changed, 64 insertions, 58 deletions
@@ -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 <sys/resource.h> #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+5<sizeof loop)? \ - (sprintf(loop+at, "..."), \ + ((n>0 && at+5<sizeof loop)? \ + (sprintf(loop+at, "..."), \ at += HDstrlen(loop+at), \ n):n)) @@ -311,16 +313,16 @@ H5dont_atexit(void) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT(H5dont_atexit); + FUNC_ENTER_API_NOINIT(H5dont_atexit) H5TRACE0("e",""); if (dont_atexit_g) - HGOTO_DONE(FAIL); + HGOTO_DONE(FAIL) dont_atexit_g = TRUE; done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -351,14 +353,15 @@ H5garbage_collect(void) { herr_t ret_value = SUCCEED; - FUNC_ENTER_API(H5garbage_collect, FAIL); + FUNC_ENTER_API(H5garbage_collect, FAIL) H5TRACE0("e",""); /* Call the garbage collection routines in the library */ - H5FL_garbage_coll(); + if(H5FL_garbage_coll()<0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect objects") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5garbage_collect() */ @@ -397,15 +400,16 @@ H5set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, { herr_t ret_value = SUCCEED; - FUNC_ENTER_API(H5set_free_list_limits, FAIL); + FUNC_ENTER_API(H5set_free_list_limits, FAIL) H5TRACE6("e","IsIsIsIsIsIs",reg_global_lim,reg_list_lim,arr_global_lim, arr_list_lim,blk_global_lim,blk_list_lim); /* Call the free list function to actually set the limits */ - H5FL_set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, blk_global_lim, blk_list_lim); + if(H5FL_set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, blk_global_lim, blk_list_lim)<0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "can't set garbage collection limits") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5set_free_list_limits() */ @@ -491,7 +495,7 @@ H5_debug_mask(const char *s) } else if (HDisdigit(*s)) { int fd = (int)HDstrtol (s, &rest, 0); if ((stream=HDfdopen(fd, "w"))) { - HDsetvbuf (stream, NULL, _IOLBF, 0); + (void)HDsetvbuf (stream, NULL, _IOLBF, 0); } s = rest; } else { @@ -529,7 +533,7 @@ H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum) { herr_t ret_value = SUCCEED; - FUNC_ENTER_API(H5get_libversion, FAIL); + FUNC_ENTER_API(H5get_libversion, FAIL) H5TRACE3("e","*Iu*Iu*Iu",majnum,minnum,relnum); /* Set the version information */ @@ -538,7 +542,7 @@ H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum) if (relnum) *relnum = H5_VERS_RELEASE; done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -573,12 +577,12 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) static int disable_version_check = 0; /* Set if the version check should be disabled */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT(H5check_version); + FUNC_ENTER_API_NOINIT(H5check_version) H5TRACE3("e","IuIuIu",majnum,minnum,relnum); /* Don't check again, if we already have */ if (checked) - HGOTO_DONE(SUCCEED); + HGOTO_DONE(SUCCEED) if (H5_VERS_MAJOR!=majnum || H5_VERS_MINOR!=minnum || H5_VERS_RELEASE!=relnum) { @@ -633,7 +637,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE); if (*substr){ HDstrcat(lib_str, "-"); - HDstrncat(lib_str, substr, sizeof(lib_str) - HDstrlen(lib_str) - 1); + HDstrncat(lib_str, substr, (sizeof(lib_str) - HDstrlen(lib_str)) - 1); } /* end if */ if (HDstrcmp(lib_str, H5_lib_vers_info_g)){ HDfputs ("Warning! Library version information error.\n" @@ -648,7 +652,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) } /* end if */ done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -674,11 +678,11 @@ H5open(void) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5open, FAIL); + FUNC_ENTER_API(H5open, FAIL) H5TRACE0("e",""); /* all work is done by FUNC_ENTER() */ done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -704,12 +708,12 @@ H5close(void) * thing just to release it all right away. It is safe to call this * function for an uninitialized library. */ - FUNC_ENTER_API_NOINIT(H5close); + FUNC_ENTER_API_NOINIT(H5close) H5TRACE0("e",""); H5_term_library(); - FUNC_LEAVE_API(SUCCEED); + FUNC_LEAVE_API(SUCCEED) } @@ -752,7 +756,7 @@ HDsnprintf(char *buf, size_t UNUSED size, const char *fmt, ...) n = HDvsprintf(buf, fmt, ap); va_end(ap); return n; -} +} /*lint !e715 */ #endif /* H5_HAVE_SNPRINTF */ @@ -782,10 +786,10 @@ HDsnprintf(char *buf, size_t UNUSED size, const char *fmt, ...) *------------------------------------------------------------------------- */ int -HDvsnprintf(char *buf, size_t size, const char *fmt, va_list ap) +HDvsnprintf(char *buf, size_t UNUSED size, const char *fmt, va_list ap) { return HDvsprintf(buf, fmt, ap); -} +} /*lint !e715 */ #endif /* H5_HAVE_VSNPRINTF */ @@ -867,7 +871,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) case '#': prefix = 1; break; - } + } /*lint !e744 Switch statement doesn't _need_ default */ s++; } @@ -901,6 +905,8 @@ HDfprintf(FILE *stream, const char *fmt, ...) /* Type modifier */ if (HDstrchr ("ZHhlqLI", *s)) { switch (*s) { + /*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 */ case 'H': if (sizeof(hsize_t)<sizeof(long)) { modifier[0] = '\0'; @@ -970,7 +976,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'd': case 'i': if (!HDstrcmp(modifier, "h")) { - short x = va_arg (ap, int); + short x = va_arg (ap, short); n = fprintf (stream, format_templ, x); } else if (!*modifier) { int x = va_arg (ap, int); @@ -989,7 +995,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'x': case 'X': if (!HDstrcmp (modifier, "h")) { - unsigned short x = va_arg (ap, unsigned int); + unsigned short x = va_arg (ap, unsigned short); n = fprintf (stream, format_templ, x); } else if (!*modifier) { unsigned int x = va_arg (ap, unsigned int); @@ -1030,7 +1036,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) break; case 'a': - if (1) { + { haddr_t x = va_arg (ap, haddr_t); if (H5F_addr_defined(x)) { sprintf(format_templ, "%%%s%s%s%s%s", @@ -1040,6 +1046,8 @@ HDfprintf(FILE *stream, const char *fmt, ...) if (fwidth>0) { 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<asize[asize_idx]; i++) { - HDfprintf(out, "%s%Hu", i?", ":"", p[i]); + HDfprintf(out, "%s%u", i?", ":"", p[i]); } fprintf(out, "}"); } @@ -2334,7 +2340,7 @@ H5_trace (double *returning, const char *func, const char *type, ...) fprintf(out, "H5FD_MEM_OHDR"); break; default: - fprintf(out, "%lu", (unsigned long)mt); + fprintf(out, "%ld", (long)mt); break; } } @@ -2913,7 +2919,7 @@ H5_trace (double *returning, const char *func, const char *type, ...) if (ptr) { if (vp) { fprintf (out, "0x%lx", (unsigned long)vp); - if (vp && asize_idx>=0 && asize[asize_idx]>=0) { + if (asize_idx>=0 && asize[asize_idx]>=0) { ssize_t *p = (ssize_t*)vp; fprintf(out, " {"); for (i=0; i<asize[asize_idx]; i++) { |