From 68fa66bf8130d6a6e607e233da8cc61a154bf172 Mon Sep 17 00:00:00 2001 From: Robb Matzke Date: Tue, 7 Apr 1998 10:34:16 -0500 Subject: [svn-r337] Changes since 19980403 ---------------------- ./configure.in Moved setting of compiler warning switches earlier in the file. Turned on more warning switches to gcc. ./config/linux Prints a warning if the gcc version is less than 2.8.1 since that version has problems with register allocation for `long long'. ./html/Datatypes.html Documented sharing of data types between datasets. ./src/H5G.c ./src/H5Gpublic.h Implemented H5Gmove(), H5Glink() and H5Gunlink() for hard links. Still have soft links to do. ./src/H5AC.c ./src/H5ACprivate.h ./src/H5D.c ./src/H5E.c ./src/H5Eprivate.h ./src/H5F.c ./src/H5Farray.c ./src/H5Fcore.c ./src/H5Ffamily.c ./src/H5Fistore.c ./src/H5Flow.c ./src/H5Fprivate.h ./src/H5Fpublic.h ./src/H5Fsec2.c ./src/H5Fstdio.c ./src/H5G.c ./src/H5Gent.c ./src/H5Gnode.c ./src/H5Gpkg.h ./src/H5Gprivate.h ./src/H5HG.c ./src/H5HL.c ./src/H5HLprivate.h ./src/H5I.c ./src/H5Iprivate.h ./src/H5MM.c ./src/H5MMprivate.h ./src/H5O.c ./src/H5Oefl.c ./src/H5Oprivate.h ./src/H5Osdspace.c ./src/H5Oshared.c ./src/H5Ostab.c ./src/H5P.c ./src/H5S.c ./src/H5Ssimp.c ./src/H5T.c ./src/H5Tconv.c ./src/H5Tprivate.h ./src/H5Tpublic.h ./src/H5V.c ./src/H5Vprivate.h ./src/H5detect.c ./src/h5ls.c ./test/cmpd_dset.c ./test/dsets.c ./test/external.c ./test/hyperslab.c ./test/iopipe.c ./test/istore.c ./test/shtype.c ./test/tstab.c Fixed comparisons between signed and unsigned values. Fixed warnings about unused function arguments. --- config/linux | 10 +++ configure | 10 +-- configure.in | 14 ++--- src/H5AC.c | 8 +-- src/H5ACprivate.h | 2 +- src/H5D.c | 2 +- src/H5Distore.c | 10 +-- src/H5E.c | 4 +- src/H5Eprivate.h | 2 +- src/H5F.c | 10 +-- src/H5Farray.c | 4 +- src/H5Fcore.c | 15 +++-- src/H5Ffamily.c | 4 +- src/H5Fistore.c | 10 +-- src/H5Flow.c | 54 ++++++++++++---- src/H5Fprivate.h | 9 +-- src/H5Fpublic.h | 10 +-- src/H5Fsec2.c | 20 +++--- src/H5Fstdio.c | 38 +++++++----- src/H5G.c | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/H5Gent.c | 7 +-- src/H5Gnode.c | 31 ++++++---- src/H5Gpkg.h | 2 +- src/H5Gprivate.h | 9 ++- src/H5Gpublic.h | 10 +++ src/H5HG.c | 7 ++- src/H5HL.c | 10 +-- src/H5HLprivate.h | 2 +- src/H5I.c | 9 +-- src/H5Iprivate.h | 6 +- src/H5MM.c | 15 +++-- src/H5MMprivate.h | 2 +- src/H5O.c | 2 +- src/H5Odtype.c | 2 +- src/H5Oefl.c | 12 ++-- src/H5Oprivate.h | 12 ++-- src/H5Osdspace.c | 8 +-- src/H5Oshared.c | 2 +- src/H5Ostab.c | 2 +- src/H5P.c | 11 ++-- src/H5S.c | 8 +-- src/H5Ssimp.c | 2 +- src/H5T.c | 4 +- src/H5Tconv.c | 13 ++-- src/H5Tprivate.h | 2 +- src/H5Tpublic.h | 6 +- src/H5V.c | 43 +++++++------ src/H5Vprivate.h | 39 +++++------- src/H5detect.c | 10 ++- src/h5ls.c | 7 ++- test/cmpd_dset.c | 125 ++++++++++++++++++++----------------- test/dsets.c | 13 +++- test/external.c | 27 +++++--- test/hyperslab.c | 52 ++++++++-------- test/iopipe.c | 4 +- test/istore.c | 53 ++++++++-------- test/shtype.c | 8 ++- test/tstab.c | 2 +- 58 files changed, 657 insertions(+), 338 deletions(-) diff --git a/config/linux b/config/linux index d17b5de..870aa3b 100644 --- a/config/linux +++ b/config/linux @@ -9,6 +9,7 @@ # Compiler flags. The CPPFLAGS values should not include package debug # flags like `-DH5G_DEBUG' since these are added with the # `--enable-debug' switch of configure. +CC=${CC:-gcc} # What must *always* be present for things to compile correctly? CFLAGS="$CFLAGS -ansi" @@ -18,6 +19,15 @@ CFLAGS="$CFLAGS -ansi" DEBUG_CFLAGS="-g -fverbose-asm" DEBUG_CPPFLAGS="-DH5F_OPT_SEEK=0 -DH5F_LOW_DFLT=H5F_LOW_SEC2" +case `$CC -v 2>&1 |tail -1 |sed 's/gcc version //'` in + 2.7.*) + echo "You have an old version of gcc, please upgrade to 2.8.1 or better" + ;; + 2.8.*) + CFLAGS="$CFLAGS -Wundef -Wsign-compare" + ;; +esac + # What compiler flags should be used for building a production # library? PROD_CFLAGS="-O3 -finline-functions -malign-double -fomit-frame-pointer" diff --git a/configure b/configure index 371b3e2..90400c8 100755 --- a/configure +++ b/configure @@ -952,8 +952,12 @@ else echo "$ac_t""no" 1>&6 fi +if test Xyes = "X$GCC"; then + CFLAGS="$CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline" +fi + echo $ac_n "checking for production mode""... $ac_c" 1>&6 -echo "configure:957: checking for production mode" >&5 +echo "configure:961: checking for production mode" >&5 # Check whether --enable-production or --disable-production was given. if test "${enable_production+set}" = set; then enableval="$enable_production" @@ -983,10 +987,6 @@ case "X-$enableval" in esac -if test Xyes = "X$GCC"; then - CFLAGS="$CFLAGS -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs" -fi - echo $ac_n "checking for main in -lcoug""... $ac_c" 1>&6 echo "configure:992: checking for main in -lcoug" >&5 ac_lib_var=`echo coug'_'main | sed 'y%./+-%__p_%'` diff --git a/configure.in b/configure.in index 53fff9d..fcb350c 100644 --- a/configure.in +++ b/configure.in @@ -87,6 +87,13 @@ else fi dnl ---------------------------------------------------------------------- +dnl Turn on warning flags for gcc. +dnl +if test Xyes = "X$GCC"; then + CFLAGS="$CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline" +fi + +dnl ---------------------------------------------------------------------- dnl Production flags? dnl AC_MSG_CHECKING(for production mode) @@ -116,13 +123,6 @@ esac dnl ---------------------------------------------------------------------- -dnl Turn on warning flags for gcc. -dnl -if test Xyes = "X$GCC"; then - CFLAGS="$CFLAGS -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs" -fi - -dnl ---------------------------------------------------------------------- dnl Check for libraries. (none required yet) dnl AC_CHECK_LIB(coug, main) dnl ...for ASCI/Red diff --git a/src/H5AC.c b/src/H5AC.c index 41e9a28..0b76288 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -75,7 +75,7 @@ H5AC_create(H5F_t *f, intn size_hint) f->shared->cache = cache = H5MM_xcalloc(1, sizeof(H5AC_t)); cache->nslots = size_hint; - cache->slot = H5MM_xcalloc(cache->nslots, sizeof(H5AC_slot_t)); + cache->slot = H5MM_xcalloc((intn)(cache->nslots), sizeof(H5AC_slot_t)); FUNC_LEAVE(SUCCEED); } @@ -115,8 +115,8 @@ H5AC_dest(H5F_t *f) } #ifdef H5AC_DEBUG { - intn i; - for (i = 0; i < cache->nslots; i++) { + uintn i; + for (i=0; inslots; i++) { cache->slot[i].prot = H5MM_xfree(cache->slot[i].prot); cache->slot[i].aprots = 0; cache->slot[i].nprots = 0; @@ -345,7 +345,7 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr, void *) = NULL; H5AC_slot_t *slot; intn *map = NULL; - intn nslots; + uintn nslots; H5AC_t *cache = NULL; FUNC_ENTER(H5AC_flush, FAIL); diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index b17bf33..ec17bd4e 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -92,7 +92,7 @@ typedef struct H5AC_slot_t { } H5AC_slot_t; typedef struct H5AC_t { - intn nslots; /*number of cache slots */ + uintn nslots; /*number of cache slots */ H5AC_slot_t *slot; /*the cache slots */ intn nprots; /*number of protected objects */ struct { diff --git a/src/H5D.c b/src/H5D.c index 8df99c0..8d29685 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -749,7 +749,7 @@ H5D_create(H5G_t *loc, const char *name, const H5T_t *type, const H5S_t *space, /* Total raw data size */ new_dset->layout.type = new_dset->create_parms->layout; new_dset->layout.ndims = H5S_get_ndims(space) + 1; - assert(new_dset->layout.ndims <= NELMTS(new_dset->layout.dim)); + assert((unsigned)(new_dset->layout.ndims) <= NELMTS(new_dset->layout.dim)); new_dset->layout.dim[new_dset->layout.ndims - 1] = H5T_get_size(type); switch (new_dset->create_parms->layout) { diff --git a/src/H5Distore.c b/src/H5Distore.c index c75a3b7..c737d9d 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -119,7 +119,7 @@ H5B_class_t H5B_ISTORE[1] = {{ *------------------------------------------------------------------------- */ static size_t -H5F_istore_sizeof_rkey(H5F_t *f, const void *_udata) +H5F_istore_sizeof_rkey(H5F_t *f __attribute__((unused)), const void *_udata) { const H5F_istore_ud1_t *udata = (const H5F_istore_ud1_t *) _udata; size_t nbytes; @@ -245,7 +245,8 @@ H5F_istore_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key) *------------------------------------------------------------------------- */ static intn -H5F_istore_cmp2(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key) +H5F_istore_cmp2(H5F_t *f __attribute__((unused)), void *_lt_key, + void *_udata, void *_rt_key) { H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key; H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key; @@ -296,7 +297,8 @@ H5F_istore_cmp2(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key) *------------------------------------------------------------------------- */ static intn -H5F_istore_cmp3(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key) +H5F_istore_cmp3(H5F_t *f __attribute__((unused)), + void *_lt_key, void *_udata, void *_rt_key) { H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key; H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key; @@ -422,7 +424,7 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op, */ static herr_t H5F_istore_found(H5F_t *f, const haddr_t *addr, const void *_lt_key, - void *_udata, const void *_rt_key) + void *_udata, const void *_rt_key __attribute__((unused))) { H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata; const H5F_istore_key_t *lt_key = (const H5F_istore_key_t *) _lt_key; diff --git a/src/H5E.c b/src/H5E.c index d8952fd..afe031a 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -374,7 +374,7 @@ H5Ewalk_cb(int n, H5E_error_t *err_desc, void *client_data) const char * H5Eget_major (H5E_major_t n) { - int i; + uintn i; /* * WARNING: Do not call the FUNC_ENTER() or FUNC_LEAVE() macros since @@ -413,7 +413,7 @@ H5Eget_major (H5E_major_t n) const char * H5Eget_minor (H5E_minor_t n) { - int i; + uintn i; /* * WARNING: Do not call the FUNC_ENTER() or FUNC_LEAVE() macros since diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 885ad44..819a401 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -96,7 +96,7 @@ typedef struct H5E_minor_mesg_t { /* An error stack */ typedef struct H5E_t { - uintn nused; /*num slots currently used in stack */ + intn nused; /*num slots currently used in stack */ H5E_error_t slot[H5E_NSLOTS]; /*array of error records */ } H5E_t; diff --git a/src/H5F.c b/src/H5F.c index ae9254c..e6d649a 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -213,10 +213,10 @@ H5F_encode_length_unusual(const H5F_t *f, uint8 **p, uint8 *l) /* * For non-little-endian platforms, encode each byte in memory backwards. */ - for (; i >= 0; i--, (*p)++) *(*p) = *(l + i); + for (/*void*/; i>=0; i--, (*p)++)*(*p) = *(l+i); #else /* platform has little-endian integers */ - HDmemcpy(*p,l,i+1); + HDmemcpy(*p,l,(size_t)(i+1)); *p+=(i+1); #endif @@ -914,7 +914,7 @@ H5F_open(const char *name, uintn flags, /* nothing to check for consistency flags */ - assert(p - buf == fixed_size); + assert((size_t)(p-buf) == fixed_size); /* Read the variable length part of the boot block... */ variable_size = H5F_SIZEOF_ADDR(f) + /*base address */ @@ -1275,13 +1275,13 @@ H5F_flush(H5F_t *f, hbool_t invalidate) /* update file length if necessary */ if (!H5F_addr_defined(&(f->shared->hdf5_eof))) { H5F_addr_reset(&(f->shared->hdf5_eof)); - H5F_addr_inc(&(f->shared->hdf5_eof), p - buf); + H5F_addr_inc(&(f->shared->hdf5_eof), (size_t)(p-buf)); H5F_low_seteof(f->shared->lf, &(f->shared->hdf5_eof)); } /* write the boot block to disk */ if (H5F_low_write(f->shared->lf, &(f->shared->access_parms), - &(f->shared->boot_addr), p-buf, buf)<0) { + &(f->shared->boot_addr), (size_t)(p-buf), buf)<0) { HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "can't write header"); } diff --git a/src/H5Farray.c b/src/H5Farray.c index eb7d7b1..08aeac4 100644 --- a/src/H5Farray.c +++ b/src/H5Farray.c @@ -195,7 +195,7 @@ H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout, /* Decrement indices and advance pointers */ for (j=ndims-1, carray=TRUE; j>=0 && carray; --j) { - H5F_addr_inc (&addr, file_stride[j]); + H5F_addr_adj (&addr, file_stride[j]); buf += mem_stride[j]; if (--idx[j]) carray = FALSE; @@ -346,7 +346,7 @@ H5F_arr_write (H5F_t *f, const struct H5O_layout_t *layout, /* Decrement indices and advance pointers */ for (j=ndims-1, carray=TRUE; j>=0 && carray; --j) { - H5F_addr_inc (&addr, file_stride[j]); + H5F_addr_adj (&addr, file_stride[j]); buf += mem_stride[j]; if (--idx[j]) carray = FALSE; diff --git a/src/H5Fcore.c b/src/H5Fcore.c index d274422..9ff3c44 100644 --- a/src/H5Fcore.c +++ b/src/H5Fcore.c @@ -69,8 +69,10 @@ const H5F_low_class_t H5F_LOW_CORE_g[1] = {{ *------------------------------------------------------------------------- */ static hbool_t -H5F_core_access(const char *name, const H5F_access_t *access_parms, - int mode, H5F_search_t *key/*out*/) +H5F_core_access(const char *name __attribute__((unused)), + const H5F_access_t *access_parms __attribute__((unused)), + int mode __attribute__((unused)), + H5F_search_t *key/*out*/ __attribute__((unused))) { FUNC_ENTER(H5F_core_access, FAIL); FUNC_LEAVE(FALSE); @@ -99,7 +101,8 @@ H5F_core_access(const char *name, const H5F_access_t *access_parms, *------------------------------------------------------------------------- */ static H5F_low_t * -H5F_core_open(const char *name, const H5F_access_t *access_parms, +H5F_core_open(const char *name __attribute__((unused)), + const H5F_access_t *access_parms __attribute__((unused)), uintn flags, H5F_search_t *key/*out*/) { H5F_low_t *lf = NULL; @@ -146,7 +149,8 @@ H5F_core_open(const char *name, const H5F_access_t *access_parms, *------------------------------------------------------------------------- */ static herr_t -H5F_core_close(H5F_low_t *lf, const H5F_access_t *access_parms) +H5F_core_close(H5F_low_t *lf, + const H5F_access_t *access_parms __attribute__((unused))) { FUNC_ENTER(H5F_core_close, FAIL); @@ -179,7 +183,8 @@ H5F_core_close(H5F_low_t *lf, const H5F_access_t *access_parms) *------------------------------------------------------------------------- */ static herr_t -H5F_core_read(H5F_low_t *lf, const H5F_access_t *access_parms, +H5F_core_read(H5F_low_t *lf, + const H5F_access_t *access_parms __attribute__((unused)), const haddr_t *addr, size_t size, uint8 *buf) { size_t n; diff --git a/src/H5Ffamily.c b/src/H5Ffamily.c index e9596b8..0458d38 100644 --- a/src/H5Ffamily.c +++ b/src/H5Ffamily.c @@ -298,7 +298,7 @@ H5F_fam_read(H5F_low_t *lf, const H5F_access_t *access_parms, { size_t nbytes; haddr_t cur_addr; - uintn membno; + intn membno; off_t offset; size_t member_size; @@ -361,7 +361,7 @@ H5F_fam_write(H5F_low_t *lf, const H5F_access_t *access_parms, { size_t nbytes; haddr_t cur_addr, max_addr; - uintn membno; + intn membno; off_t offset; H5F_low_t *member = NULL; char member_name[4096]; diff --git a/src/H5Fistore.c b/src/H5Fistore.c index c75a3b7..c737d9d 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -119,7 +119,7 @@ H5B_class_t H5B_ISTORE[1] = {{ *------------------------------------------------------------------------- */ static size_t -H5F_istore_sizeof_rkey(H5F_t *f, const void *_udata) +H5F_istore_sizeof_rkey(H5F_t *f __attribute__((unused)), const void *_udata) { const H5F_istore_ud1_t *udata = (const H5F_istore_ud1_t *) _udata; size_t nbytes; @@ -245,7 +245,8 @@ H5F_istore_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key) *------------------------------------------------------------------------- */ static intn -H5F_istore_cmp2(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key) +H5F_istore_cmp2(H5F_t *f __attribute__((unused)), void *_lt_key, + void *_udata, void *_rt_key) { H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key; H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key; @@ -296,7 +297,8 @@ H5F_istore_cmp2(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key) *------------------------------------------------------------------------- */ static intn -H5F_istore_cmp3(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key) +H5F_istore_cmp3(H5F_t *f __attribute__((unused)), + void *_lt_key, void *_udata, void *_rt_key) { H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key; H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key; @@ -422,7 +424,7 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op, */ static herr_t H5F_istore_found(H5F_t *f, const haddr_t *addr, const void *_lt_key, - void *_udata, const void *_rt_key) + void *_udata, const void *_rt_key __attribute__((unused))) { H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata; const H5F_istore_key_t *lt_key = (const H5F_istore_key_t *) _lt_key; diff --git a/src/H5Flow.c b/src/H5Flow.c index 545659a..f29b7d3 100644 --- a/src/H5Flow.c +++ b/src/H5Flow.c @@ -587,7 +587,7 @@ H5F_addr_undef(haddr_t *addr /*out */ ) { assert(addr); - addr->offset = -1; + addr->offset = (uint64)(-1); } /*------------------------------------------------------------------------- @@ -676,7 +676,7 @@ H5F_addr_zerop(const haddr_t *addr) void H5F_addr_encode(H5F_t *f, uint8 **pp, const haddr_t *addr) { - int i; + uint i; haddr_t tmp; assert(f); @@ -685,14 +685,14 @@ H5F_addr_encode(H5F_t *f, uint8 **pp, const haddr_t *addr) if (addr_defined(addr)) { tmp = *addr; - for (i = 0; i < H5F_SIZEOF_ADDR(f); i++) { + for (i=0; i>= 8; } assert("overflow" && 0 == tmp.offset); } else { - for (i = 0; i < H5F_SIZEOF_ADDR(f); i++) { + for (i=0; ioffset = 0; - for (i = 0; i < H5F_SIZEOF_ADDR(f); i++) { + for (i=0; ioffset)) { + if (ioffset)) { tmp.offset = c; tmp.offset <<= i * 8; /*use tmp to get casting right */ addr->offset |= tmp.offset; @@ -744,8 +743,7 @@ H5F_addr_decode(H5F_t *f, const uint8 **pp, haddr_t *addr/*out*/) assert(0 == **pp); /*overflow */ } } - if (all_zero) - H5F_addr_undef(addr); + if (all_zero) H5F_addr_undef(addr); } /*------------------------------------------------------------------------- @@ -830,12 +828,44 @@ H5F_addr_pow2(uintn n, haddr_t *addr /*out */ ) *------------------------------------------------------------------------- */ void -H5F_addr_inc(haddr_t *addr /*in,out */ , size_t inc) +H5F_addr_inc(haddr_t *addr/*in,out */, size_t inc) { assert(addr && addr_defined(addr)); assert(addr->offset <= addr->offset + inc); + addr->offset += inc; } + + +/*------------------------------------------------------------------------- + * Function: H5F_addr_adj + * + * Purpose: Adjusts an address by adding or subtracting some amount. + * + * Return: void + * + * Programmer: Robb Matzke + * Monday, April 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +void +H5F_addr_adj(haddr_t *addr/*in,out */, ssize_t adj) +{ +#ifndef NDEBUG + assert(addr && addr_defined(addr)); + if (adj>=0) { + assert(addr->offset <= addr->offset + adj); + } else { + assert (addr->offset > addr->offset + adj); + } +#endif + + addr->offset += adj; +} + /*------------------------------------------------------------------------- * Function: H5F_addr_add diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index c4e1fc0..23046b0 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -55,9 +55,9 @@ /* * Private file open flags. */ -#define H5F_ACC_PUBLIC_FLAGS 0x00ff +#define H5F_ACC_PUBLIC_FLAGS 0x00ffu -#define H5F_ACC_CREAT 0x0100 /* Create non-existing files */ +#define H5F_ACC_CREAT 0x0100u /* Create non-existing files */ /* * Encode and decode macros for file meta-data. @@ -351,7 +351,7 @@ typedef struct H5F_low_t { #ifdef HAVE_FSEEK64 int64 cur; /* Current file position */ #else - off_t cur; /* Current file position */ + long cur; /* Current file position */ #endif } stdio; @@ -537,7 +537,8 @@ void H5F_addr_encode(H5F_t *, uint8 **, const haddr_t *); void H5F_addr_decode(H5F_t *, const uint8 **, haddr_t *); void H5F_addr_print(FILE *, const haddr_t *); void H5F_addr_pow2(uintn, haddr_t *); -void H5F_addr_inc(haddr_t *, size_t); +void H5F_addr_inc(haddr_t *addr/*in,out*/, size_t inc); +void H5F_addr_adj(haddr_t *addr/*in,out*/, ssize_t adj); void H5F_addr_add(haddr_t *, const haddr_t *); uintn H5F_addr_hash(const haddr_t *, uintn mod); diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 1fb72af..f0fb3f2 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -25,11 +25,11 @@ * H5Fcreate() and H5Fopen(). Use the bit-wise OR operator (|) to combine * them as needed. */ -#define H5F_ACC_RDONLY 0x0000 /*absence of write implies read only */ -#define H5F_ACC_RDWR 0x0001 /*open file for reading and writing */ -#define H5F_ACC_TRUNC 0x0002 /*overwrite existing files during create*/ -#define H5F_ACC_EXCL 0x0004 /*create fails if file already exists */ -#define H5F_ACC_DEBUG 0x0008 /*print debug info */ +#define H5F_ACC_RDONLY 0x0000u /*absence of write implies read only */ +#define H5F_ACC_RDWR 0x0001u /*open file for reading and writing */ +#define H5F_ACC_TRUNC 0x0002u /*overwrite existing files during create*/ +#define H5F_ACC_EXCL 0x0004u /*create fails if file already exists */ +#define H5F_ACC_DEBUG 0x0008u /*print debug info */ #ifdef LATER diff --git a/src/H5Fsec2.c b/src/H5Fsec2.c index 57dd7a6..16395dd 100644 --- a/src/H5Fsec2.c +++ b/src/H5Fsec2.c @@ -69,10 +69,11 @@ const H5F_low_class_t H5F_LOW_SEC2_g[1] = {{ *------------------------------------------------------------------------- */ static H5F_low_t * -H5F_sec2_open(const char *name, const H5F_access_t *access_parms, uintn flags, - H5F_search_t *key/*out*/) +H5F_sec2_open(const char *name, + const H5F_access_t *access_parms __attribute__((unused)), + uintn flags, H5F_search_t *key/*out*/) { - uintn oflags; + intn oflags; H5F_low_t *lf = NULL; int fd; struct stat sb; @@ -121,7 +122,8 @@ H5F_sec2_open(const char *name, const H5F_access_t *access_parms, uintn flags, *------------------------------------------------------------------------- */ static herr_t -H5F_sec2_close(H5F_low_t *lf, const H5F_access_t *access_parms) +H5F_sec2_close(H5F_low_t *lf, + const H5F_access_t *access_parms __attribute__((unused))) { FUNC_ENTER(H5F_sec2_close, FAIL); @@ -156,7 +158,8 @@ H5F_sec2_close(H5F_low_t *lf, const H5F_access_t *access_parms) *------------------------------------------------------------------------- */ static herr_t -H5F_sec2_read(H5F_low_t *lf, const H5F_access_t *access_parms, +H5F_sec2_read(H5F_low_t *lf, + const H5F_access_t *access_parms __attribute__((unused)), const haddr_t *addr, size_t size, uint8 *buf) { ssize_t n; @@ -184,7 +187,7 @@ H5F_sec2_read(H5F_low_t *lf, const H5F_access_t *access_parms, /* Check easy cases */ if (0 == size) HRETURN(SUCCEED); - if (offset >= lf->eof.offset) { + if ((uint64)offset >= lf->eof.offset) { HDmemset(buf, 0, size); HRETURN(SUCCEED); } @@ -224,7 +227,7 @@ H5F_sec2_read(H5F_low_t *lf, const H5F_access_t *access_parms, if ((n = read(lf->u.sec2.fd, buf, size)) < 0) { lf->u.sec2.op = H5F_OP_UNKNOWN; HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "read failed"); - } else if (n < size) { + } else if ((size_t)n < size) { HDmemset(buf + n, 0, size - n); } @@ -260,7 +263,8 @@ H5F_sec2_read(H5F_low_t *lf, const H5F_access_t *access_parms, *------------------------------------------------------------------------- */ static herr_t -H5F_sec2_write(H5F_low_t *lf, const H5F_access_t *access_parms, +H5F_sec2_write(H5F_low_t *lf, + const H5F_access_t *access_parms __attribute__((unused)), const haddr_t *addr, size_t size, const uint8 *buf) { uint64 mask; diff --git a/src/H5Fstdio.c b/src/H5Fstdio.c index 6224dd6..7e45878 100644 --- a/src/H5Fstdio.c +++ b/src/H5Fstdio.c @@ -70,7 +70,8 @@ const H5F_low_class_t H5F_LOW_STDIO_g[1] = {{ *------------------------------------------------------------------------- */ static H5F_low_t * -H5F_stdio_open(const char *name, const H5F_access_t *access_parms, +H5F_stdio_open(const char *name, + const H5F_access_t *access_parms __attribute__((unused)), uintn flags, H5F_search_t *key/*out*/) { H5F_low_t *lf = NULL; @@ -112,7 +113,9 @@ H5F_stdio_open(const char *name, const H5F_access_t *access_parms, if (fseek(lf->u.stdio.f, 0, SEEK_END) < 0) { lf->u.stdio.op = H5F_OP_UNKNOWN; } else { - H5F_addr_inc(&(lf->eof), ftell(lf->u.stdio.f)); + ssize_t x = ftell (lf->u.stdio.f); + assert (x>=0); + H5F_addr_inc(&(lf->eof), (size_t)x); } /* The unique key */ @@ -144,7 +147,8 @@ H5F_stdio_open(const char *name, const H5F_access_t *access_parms, *------------------------------------------------------------------------- */ static herr_t -H5F_stdio_close(H5F_low_t *lf, const H5F_access_t *access_parms) +H5F_stdio_close(H5F_low_t *lf, + const H5F_access_t *access_parms __attribute__((unused))) { FUNC_ENTER(H5F_stdio_close, FAIL); @@ -179,7 +183,8 @@ H5F_stdio_close(H5F_low_t *lf, const H5F_access_t *access_parms) *------------------------------------------------------------------------- */ static herr_t -H5F_stdio_read(H5F_low_t *lf, const H5F_access_t *access_parms, +H5F_stdio_read(H5F_low_t *lf, + const H5F_access_t *access_parms __attribute__((unused)), const haddr_t *addr, size_t size, uint8 *buf/*out*/) { size_t n; @@ -187,7 +192,7 @@ H5F_stdio_read(H5F_low_t *lf, const H5F_access_t *access_parms, #ifdef HAVE_FSEEK64 int64 offset; #else - off_t offset; + long offset; #endif FUNC_ENTER(H5F_stdio_read, FAIL); @@ -202,12 +207,12 @@ H5F_stdio_read(H5F_low_t *lf, const H5F_access_t *access_parms, #ifdef HAVE_FSEEK64 offset = (int64)(addr->offset); /*checked for overflow*/ #else - offset = (off_t)(addr->offset); /*checked for overflow*/ + offset = (long)(addr->offset); /*checked for overflow*/ #endif /* Check easy cases */ if (0 == size) HRETURN(SUCCEED); - if (offset >= lf->eof.offset) { + if ((uint64)offset >= lf->eof.offset) { HDmemset(buf, 0, size); HRETURN(SUCCEED); } @@ -287,16 +292,18 @@ H5F_stdio_read(H5F_low_t *lf, const H5F_access_t *access_parms, *------------------------------------------------------------------------- */ static herr_t -H5F_stdio_write(H5F_low_t *lf, const H5F_access_t *access_parms, +H5F_stdio_write(H5F_low_t *lf, + const H5F_access_t *access_parms __attribute__((unused)), const haddr_t *addr, size_t size, const uint8 *buf) { - ssize_t n; uint64 mask; #ifdef HAVE_FSEEK64 int64 offset; + uint64 n; #else - off_t offset; + long offset; + size_t n; #endif FUNC_ENTER(H5F_stdio_write, FAIL); @@ -310,10 +317,10 @@ H5F_stdio_write(H5F_low_t *lf, const H5F_access_t *access_parms, } #ifdef HAVE_FSEEK64 offset = (int64)(addr->offset); /*checked for overflow*/ - n = (int64)size; /*checked for overflow*/ + n = size; /*checked for overflow*/ #else offset = (long)(addr->offset); /*checked for overflow*/ - n = (off_t)size; /*checked for overflow*/ + n = size; /*checked for overflow*/ #endif /* @@ -333,6 +340,7 @@ H5F_stdio_write(H5F_low_t *lf, const H5F_access_t *access_parms, #endif lf->u.stdio.cur = offset; } + /* * Write the buffer. On successful return, the file position will be * advanced by the number of bytes read. Otherwise nobody knows where it @@ -342,11 +350,12 @@ H5F_stdio_write(H5F_low_t *lf, const H5F_access_t *access_parms, lf->u.stdio.op = H5F_OP_UNKNOWN; HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "fwrite failed"); } + /* * Update seek optimizing data. */ lf->u.stdio.op = H5F_OP_WRITE; - lf->u.stdio.cur = offset + n; + lf->u.stdio.cur = offset + (int64)n; FUNC_LEAVE(SUCCEED); } @@ -371,7 +380,8 @@ H5F_stdio_write(H5F_low_t *lf, const H5F_access_t *access_parms, *------------------------------------------------------------------------- */ static herr_t -H5F_stdio_flush(H5F_low_t *lf, const H5F_access_t *access_parms) +H5F_stdio_flush(H5F_low_t *lf, + const H5F_access_t *access_parms __attribute__((unused))) { FUNC_ENTER(H5F_stdio_flush, FAIL); diff --git a/src/H5G.c b/src/H5G.c index 293e3ab..d93cb8e 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -492,6 +492,131 @@ H5Giterate (hid_t loc_id, const char *name, int *idx, FUNC_LEAVE (ret_value); } + +/*------------------------------------------------------------------------- + * Function: H5Gmove + * + * Purpose: Renames an object within an HDF5 file. The original name SRC + * is unlinked from the group graph and the new name DST is + * inserted as an atomic operation. Both names are interpreted + * relative to LOC_ID which is either a file ID or a group ID. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Monday, April 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Gmove (hid_t loc_id __attribute__((unused)), + const char *src __attribute__((unused)), + const char *dst __attribute__((unused))) +{ + FUNC_ENTER (H5Gmove, FAIL); + + HRETURN_ERROR (H5E_SYM, H5E_UNSUPPORTED, FAIL, + "unable to rename object (not implemented yet)"); + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Glink + * + * Purpose: Creates a link of the specified type from NEW_NAME to + * CUR_NAME. + * + * If TYPE is H5G_LINK_HARD then CUR_NAME must name an existing + * object and both names are interpreted relative to LOC_ID + * which is either a file ID or a group ID. + * + * If TYPE is H5G_LINK_SOFT then CUR_NAME can be anything and is + * interpreted at lookup time relative to the group which + * contains the final component of NEW_NAME. For instance, if + * CUR_NAME is `./foo' and NEW_NAME is `./x/y/bar' and a request + * is made for `./x/y/bar' then the actual object looked up is + * `./x/y/./foo'. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Monday, April 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Glink (hid_t loc_id, H5G_link_t type, const char *cur_name, + const char *new_name) +{ + H5G_t *loc = NULL; + + FUNC_ENTER (H5Glink, FAIL); + + if (NULL==(loc=H5G_loc (loc_id))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); + } + if (type!=H5G_LINK_HARD && type!=H5G_LINK_SOFT) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unrecognized link type"); + } + if (!cur_name || !*cur_name) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "no current name specified"); + } + if (!new_name || !*new_name) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "no new name specified"); + } + if (H5G_link (loc, type, cur_name, new_name)<0) { + HRETURN_ERROR (H5E_SYM, H5E_LINK, FAIL, "unable to create link"); + } + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Gunlink + * + * Purpose: Removes the specified NAME from the group graph and + * decrements the link count for the object to which NAME + * points. If the link count reaches zero then all file-space + * associated with the object will be reclaimed (but if the + * object is open, then the reclamation of the file space is + * delayed until all handles to the object are closed). + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Monday, April 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Gunlink (hid_t loc_id __attribute__((unused)), + const char *name __attribute__((unused))) +{ + FUNC_ENTER (H5Gunlink, FAIL); + + HRETURN_ERROR (H5E_SYM, H5E_UNSUPPORTED, FAIL, + "unable to unlink name (not implemented yet)"); + + FUNC_LEAVE (SUCCEED); +} + /* *------------------------------------------------------------------------- *------------------------------------------------------------------------- @@ -1385,3 +1510,58 @@ H5G_loc (hid_t loc_id) FUNC_LEAVE (ret_value); } + + +/*------------------------------------------------------------------------- + * Function: H5G_link + * + * Purpose: Creates a link from NEW_NAME to CUR_NAME. See H5Glink() for + * full documentation. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Monday, April 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_link (H5G_t *loc, H5G_type_t type, const char *cur_name, + const char *new_name) +{ + H5G_entry_t cur_obj; + + FUNC_ENTER (H5G_link, FAIL); + + /* Check args */ + assert (loc); + assert (cur_name && *cur_name); + assert (new_name && *new_name); + + switch (type) { + case H5G_LINK_SOFT: + HRETURN_ERROR (H5E_SYM, H5E_UNSUPPORTED, FAIL, + "unable to create soft link (not implemented yet)"); + + case H5G_LINK_HARD: + if (H5G_find (loc, cur_name, NULL, &cur_obj)<0) { + HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, + "source object not found"); + } + if (H5G_insert (loc, new_name, &cur_obj)<0) { + HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, + "unable to create new name/link for object"); + } + break; + + default: + HRETURN_ERROR (H5E_SYM, H5E_BADVALUE, FAIL, + "unrecognized link type"); + } + + FUNC_LEAVE (SUCCEED); +} diff --git a/src/H5Gent.c b/src/H5Gent.c index 8c67810..2a95778 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -102,8 +102,7 @@ H5G_ent_modified(H5G_entry_t *ent, H5G_type_t cache_type) { FUNC_ENTER(H5G_ent_modified, FAIL); assert(ent); - if (H5G_NO_CHANGE != ent->type) - ent->type = cache_type; + if (H5G_NO_CHANGE != ent->type) ent->type = cache_type; ent->dirty = TRUE; FUNC_LEAVE(SUCCEED); } @@ -350,8 +349,8 @@ H5G_ent_encode(H5F_t *f, uint8 **pp, H5G_entry_t *ent) *------------------------------------------------------------------------- */ herr_t -H5G_ent_debug(H5F_t *f, H5G_entry_t *ent, FILE * stream, intn indent, - intn fwidth) +H5G_ent_debug(H5F_t *f __attribute__((unused)), H5G_entry_t *ent, + FILE * stream, intn indent, intn fwidth) { FUNC_ENTER(H5G_ent_debug, FAIL); diff --git a/src/H5Gnode.c b/src/H5Gnode.c index e447742..5292607 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -132,7 +132,8 @@ H5G_node_sizeof_rkey(H5F_t *f, const void *udata __attribute__((unused))) *------------------------------------------------------------------------- */ static herr_t -H5G_node_decode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key) +H5G_node_decode_key(H5F_t *f, H5B_t *bt __attribute__((unused)), uint8 *raw, + void *_key) { H5G_node_key_t *key = (H5G_node_key_t *) _key; @@ -166,7 +167,8 @@ H5G_node_decode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key) *------------------------------------------------------------------------- */ static herr_t -H5G_node_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key) +H5G_node_encode_key(H5F_t *f, H5B_t *bt __attribute__((unused)), + uint8 *raw, void *_key) { H5G_node_key_t *key = (H5G_node_key_t *) _key; @@ -230,7 +232,8 @@ H5G_node_size(H5F_t *f) */ static herr_t H5G_node_create(H5F_t *f, H5B_ins_t op, - void *_lt_key, void *_udata, void *_rt_key, + void *_lt_key, void *_udata __attribute__((unused)), + void *_rt_key, haddr_t *addr/*out*/) { H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key; @@ -254,7 +257,7 @@ H5G_node_create(H5F_t *f, H5B_ins_t op, "unable to allocate file space"); } sym->dirty = TRUE; - sym->entry = H5MM_xcalloc(2 * H5G_NODE_K(f), sizeof(H5G_entry_t)); + sym->entry = H5MM_xcalloc((intn)(2*H5G_NODE_K(f)), sizeof(H5G_entry_t)); if (H5AC_set(f, H5AC_SNODE, addr, sym) < 0) { H5MM_xfree(sym->entry); H5MM_xfree(sym); @@ -403,7 +406,7 @@ H5G_node_load(H5F_t *f, const haddr_t *addr, const void *_udata1, size = H5G_node_size(f); p = buf = H5MM_xmalloc(size); sym = H5MM_xcalloc(1, sizeof(H5G_node_t)); - sym->entry = H5MM_xcalloc(2 * H5G_NODE_K(f), sizeof(H5G_entry_t)); + sym->entry = H5MM_xcalloc((intn)(2*H5G_NODE_K(f)), sizeof(H5G_entry_t)); if (H5F_block_read(f, addr, size, buf) < 0) { HGOTO_ERROR(H5E_SYM, H5E_READERROR, NULL, @@ -586,8 +589,9 @@ H5G_node_cmp3(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key) *------------------------------------------------------------------------- */ static herr_t -H5G_node_found(H5F_t *f, const haddr_t *addr, const void *_lt_key, - void *_udata, const void *_rt_key) +H5G_node_found(H5F_t *f, const haddr_t *addr, + const void *_lt_key __attribute__((unused)), + void *_udata, const void *_rt_key __attribute__((unused))) { H5G_bt_ud1_t *bt_udata = (H5G_bt_ud1_t *) _udata; H5G_node_t *sn = NULL; @@ -696,9 +700,10 @@ H5G_node_found(H5F_t *f, const haddr_t *addr, const void *_lt_key, */ static H5B_ins_t H5G_node_insert(H5F_t *f, const haddr_t *addr, - void *_lt_key, hbool_t *lt_key_changed, + void *_lt_key __attribute__((unused)), + hbool_t *lt_key_changed __attribute__((unused)), void *_md_key, void *_udata, - void *_rt_key, hbool_t *rt_key_changed, + void *_rt_key, hbool_t *rt_key_changed __attribute__((unused)), haddr_t *new_node) { H5G_node_key_t *md_key = (H5G_node_key_t *) _md_key; @@ -767,7 +772,7 @@ H5G_node_insert(H5F_t *f, const haddr_t *addr, HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert symbol name into heap"); } - if (sn->nsyms >= 2 * H5G_NODE_K(f)) { + if ((size_t)(sn->nsyms) >= 2*H5G_NODE_K(f)) { /* * The node is full. Split it into a left and right * node and return the address of the new right node (the @@ -800,14 +805,14 @@ H5G_node_insert(H5F_t *f, const haddr_t *addr, md_key->offset = sn->entry[sn->nsyms - 1].name_off; /* Where to insert the new entry? */ - if (idx <= H5G_NODE_K(f)) { + if (idx <= (intn)H5G_NODE_K(f)) { insert_into = sn; - if (idx == H5G_NODE_K(f)) + if (idx == (intn)H5G_NODE_K(f)) md_key->offset = offset; } else { idx -= H5G_NODE_K(f); insert_into = snrt; - if (idx == H5G_NODE_K (f)) { + if (idx == (intn)H5G_NODE_K (f)) { rt_key->offset = offset; *rt_key_changed = TRUE; } diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index f78071a..3b449fd 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -21,7 +21,7 @@ #define H5G_NODE_VERS 1 /*symbol table node version number */ #define H5G_SIZE_HINT 1024 /*default root grp size hint */ -#define H5G_NODE_K(F) ((F)->shared->create_parms.sym_leaf_k) +#define H5G_NODE_K(F) ((unsigned)((F)->shared->create_parms.sym_leaf_k)) #define H5G_NODE_SIZEOF_HDR(F) (H5G_NODE_SIZEOF_MAGIC + 4) #define H5G_DEFAULT_ROOT_SIZE 32 diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index b79d1e2..2d49e99 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -51,10 +51,11 @@ * symbol table entry. */ typedef enum H5G_type_t { - H5G_NOTHING_CACHED = 0, /*nothing is cached, must be 0 */ - H5G_CACHED_STAB = 1, /*symbol table, `stab' */ + H5G_CACHED_ERROR = -1, /*force enum to be signed */ + H5G_NOTHING_CACHED = 0, /*nothing is cached, must be 0 */ + H5G_CACHED_STAB = 1, /*symbol table, `stab' */ - H5G_NCACHED = 2 /*THIS MUST BE LAST */ + H5G_NCACHED = 2 /*THIS MUST BE LAST */ } H5G_type_t; /* @@ -103,6 +104,8 @@ herr_t H5G_set (H5G_t *grp); herr_t H5G_push (H5G_t *grp); herr_t H5G_pop (H5F_t *f); H5G_t *H5G_getcwg(H5F_t *f); +herr_t H5G_link (H5G_t *loc, H5G_type_t type, const char *cur_name, + const char *new_name); herr_t H5G_insert (H5G_t *cwg, const char *name, H5G_entry_t *ent); herr_t H5G_find (H5G_t *cwg, const char *name, H5G_entry_t *grp_ent/*out*/, H5G_entry_t *ent/*out*/); diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 435d384..8c6e7c6 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -27,6 +27,12 @@ extern "C" { #endif +typedef enum H5G_link_t { + H5G_LINK_ERROR = -1, + H5G_LINK_HARD = 0, + H5G_LINK_SOFT = 1 +} H5G_link_t; + typedef herr_t (*H5G_iterate_t)(hid_t group, const char *group_name, void *op_data); @@ -38,6 +44,10 @@ herr_t H5Gpush (hid_t file, const char *name); herr_t H5Gpop (hid_t file); herr_t H5Giterate (hid_t file, const char *name, int *idx, H5G_iterate_t op, void *op_data); +herr_t H5Gmove (hid_t loc_id, const char *src, const char *dst); +herr_t H5Glink (hid_t loc_id, H5G_link_t type, const char *cur_name, + const char *new_name); +herr_t H5Gunlink (hid_t loc_id, const char *name); #ifdef __cplusplus } diff --git a/src/H5HG.c b/src/H5HG.c index 176c687..f457839 100644 --- a/src/H5HG.c +++ b/src/H5HG.c @@ -131,7 +131,7 @@ H5HG_create (H5F_t *f, size_t size) UINT16ENCODE (p, 0); /*object ID*/ UINT16ENCODE (p, 0); /*reference count*/ H5F_encode_length (f, p, heap->obj[0].size); - HDmemset (p, 0, (heap->chunk+heap->nalloc) - p); + HDmemset (p, 0, (size_t)((heap->chunk+heap->nalloc) - p)); /* Add the heap to the cache */ if (H5AC_set (f, H5AC_GHEAP, &addr, heap)<0) { @@ -845,7 +845,8 @@ herr_t H5HG_debug(H5F_t *f, const haddr_t *addr, FILE *stream, intn indent, intn fwidth) { - int i, j, k, nused, maxobj; + int i, nused, maxobj; + uintn j, k; H5HG_heap_t *h = NULL; char buf[64]; size_t size; @@ -855,7 +856,7 @@ H5HG_debug(H5F_t *f, const haddr_t *addr, FILE *stream, intn indent, /* check arguments */ assert(f); - if (addr && H5F_addr_defined (addr)); + assert(addr && H5F_addr_defined (addr)); assert(stream); assert(indent >= 0); assert(fwidth >= 0); diff --git a/src/H5HL.c b/src/H5HL.c index d7f83c0..82cfd31 100644 --- a/src/H5HL.c +++ b/src/H5HL.c @@ -889,7 +889,7 @@ H5HL_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent, * the heap and that no two free blocks point to the same region of * the heap. */ - marker = H5MM_xcalloc(h->mem_alloc, 1); + marker = H5MM_xcalloc(1, h->mem_alloc); for (freelist = h->freelist; freelist; freelist = freelist->next) { fprintf(stream, "%*s%-*s %8lu, %8lu\n", indent, "", fwidth, "Free Block (offset,size):", @@ -898,7 +898,7 @@ H5HL_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent, if (freelist->offset + freelist->size > h->mem_alloc) { fprintf(stream, "***THAT FREE BLOCK IS OUT OF BOUNDS!\n"); } else { - for (i = overlap = 0; i < freelist->size; i++) { + for (i=overlap=0; i<(intn)(freelist->size); i++) { if (marker[freelist->offset + i]) overlap++; marker[freelist->offset + i] = 1; @@ -923,10 +923,10 @@ H5HL_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent, */ fprintf(stream, "%*sData follows (`__' indicates free region)...\n", indent, ""); - for (i = 0; i < h->disk_alloc; i += 16) { + for (i=0; i<(intn)(h->disk_alloc); i+=16) { fprintf(stream, "%*s %8d: ", indent, "", i); for (j = 0; j < 16; j++) { - if (i + j < h->disk_alloc) { + if (i+j<(intn)(h->disk_alloc)) { if (marker[i + j]) { fprintf(stream, "__ "); } else { @@ -941,7 +941,7 @@ H5HL_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent, } for (j = 0; j < 16; j++) { - if (i + j < h->disk_alloc) { + if (i+j < (intn)(h->disk_alloc)) { if (marker[i + j]) { HDfputc(' ', stream); } else { diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h index b1af51a..da8c257 100644 --- a/src/H5HLprivate.h +++ b/src/H5HLprivate.h @@ -34,7 +34,7 @@ #define H5HL_MAGIC "HEAP" /*heap magic number */ #define H5HL_SIZEOF_MAGIC 4 -#define H5HL_ALIGN(X) (((X)+7)&~0x07) /*align on 8-byte boundary */ +#define H5HL_ALIGN(X) (((X)+7)&(unsigned)(~0x07)) /*align on 8-byte boundary */ #define H5HL_SIZEOF_HDR(F) \ H5HL_ALIGN(H5HL_SIZEOF_MAGIC + /*heap signature */ \ diff --git a/src/H5I.c b/src/H5I.c index b958a3e..6b9383c 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -133,7 +133,7 @@ H5I_init_interface(void) ******************************************************************************/ intn H5I_init_group(H5I_group_t grp, /* IN: Group to initialize */ - intn hash_size, /* IN: Minimum hash table size to use for group */ + size_t hash_size, /* IN: Minimum hash table size to use for group */ uintn reserved, /* IN: Number of hash table entries to reserve */ herr_t (*free_func) (void *) /* IN: Function to call when releasing ref counted objects */ ) @@ -183,7 +183,8 @@ H5I_init_group(H5I_group_t grp, /* IN: Group to initialize */ grp_ptr->ids = 0; grp_ptr->nextid = reserved; grp_ptr->free_func = free_func; - grp_ptr->id_list = H5MM_xcalloc(hash_size, sizeof(H5I_id_info_t *)); + grp_ptr->id_list = H5MM_xcalloc((intn)hash_size, + sizeof(H5I_id_info_t *)); } /* Increment the count of the times this group has been initialized */ @@ -232,7 +233,7 @@ H5I_destroy_group(H5I_group_t grp) H5I_id_group_t *grp_ptr = NULL; /* ptr to the atomic group */ H5I_id_info_t *cur=NULL, *next=NULL; intn ret_value = SUCCEED; - intn i; + uintn i; FUNC_ENTER(H5I_destroy_group, FAIL); @@ -674,7 +675,7 @@ H5I_search(H5I_group_t grp, /* IN: Group to search for the object in */ { H5I_id_group_t *grp_ptr = NULL; /* ptr to the group */ H5I_id_info_t *id_ptr = NULL; /* ptr to the new ID */ - intn i; /* local counting variable */ + uintn i; /* local counting variable */ void * ret_value = NULL; FUNC_ENTER(H5I_search, NULL); diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 45f9e85..25fe0c7 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -49,7 +49,7 @@ * Map an ID to a hash location (assumes s is a power of 2 and smaller * than the ID_MASK constant). */ -# define ID_TO_LOC(a,s) ((hid_t)(a)&((s)-1)) +# define ID_TO_LOC(a,s) ((hid_t)((size_t)(a)&((s)-1))) #else /* @@ -81,7 +81,7 @@ typedef struct { uintn count; /*# of times this group has been initialized */ uintn reserved; /*# of IDs to reserve for constant IDs */ uintn wrapped; /*whether the id count has wrapped around */ - intn hash_size; /*sizeof the hash table to store the IDs in*/ + size_t hash_size; /*sizeof the hash table to store the IDs in*/ uintn ids; /*current number of IDs held */ uintn nextid; /*ID to use for the next atom */ herr_t (*free_func)(void*);/*func to call to release object */ @@ -92,7 +92,7 @@ typedef struct { typedef intn (*H5I_search_func_t) (void * obj, const void * key); /* Private Functions in H5I.c */ -intn H5I_init_group (H5I_group_t grp, intn hash_size, uintn reserved, +intn H5I_init_group (H5I_group_t grp, size_t hash_size, uintn reserved, herr_t (*free_func)(void *)); herr_t H5I_destroy_group (H5I_group_t grp); hid_t H5I_register (H5I_group_t grp, void *object); diff --git a/src/H5MM.c b/src/H5MM.c index 3a1d392..2182a2d 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -59,11 +59,18 @@ H5MM_xmalloc(size_t size) * *------------------------------------------------------------------------- */ -void * -H5MM_xcalloc(size_t n, size_t size) +void * +H5MM_xcalloc(intn n, size_t size) { - void *mem = HDcalloc(n, size); - assert(mem); + void *mem = NULL; + + assert (n>=0); + + if (n>0) { + mem = HDcalloc((size_t)n, size); + assert(mem); + } + return mem; } diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h index 1b9975c..3fef16b 100644 --- a/src/H5MMprivate.h +++ b/src/H5MMprivate.h @@ -26,7 +26,7 @@ * Library prototypes... */ void *H5MM_xmalloc (size_t size); -void *H5MM_xcalloc (size_t n, size_t size); +void *H5MM_xcalloc (intn n, size_t size); void *H5MM_xrealloc (void *mem, size_t size); char *H5MM_xstrdup (const char *s); void *H5MM_xfree (const void *mem); diff --git a/src/H5O.c b/src/H5O.c index e7a51fa..7049288 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1714,7 +1714,7 @@ H5O_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent, /* check for bad message id */ if (oh->mesg[i].type->id < 0 || - oh->mesg[i].type->id >= NELMTS(message_type_g)) { + oh->mesg[i].type->id >= (intn)NELMTS(message_type_g)) { fprintf(stream, "*** BAD MESSAGE ID 0x%04x\n", oh->mesg[i].type->id); continue; diff --git a/src/H5Odtype.c b/src/H5Odtype.c index c3b46cd..31c1c4e 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -157,7 +157,7 @@ H5O_dtype_decode_helper(const uint8 **pp, H5T_t *dt) assert(dt->u.compnd.nmembs > 0); dt->u.compnd.nalloc = dt->u.compnd.nmembs; dt->u.compnd.memb = H5MM_xcalloc(dt->u.compnd.nalloc, - sizeof(H5T_member_t)); + sizeof(H5T_member_t)); for (i = 0; i < dt->u.compnd.nmembs; i++) { dt->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp); *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8; /*multiple of 8 w/ null terminator */ diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 18dd40d..948435a 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -369,8 +369,8 @@ H5O_efl_total_size (H5O_efl_t *efl) *------------------------------------------------------------------------- */ herr_t -H5O_efl_read (H5F_t *f, const H5O_efl_t *efl, haddr_t *addr, size_t size, - uint8 *buf) +H5O_efl_read (H5F_t *f __attribute__((unused)), const H5O_efl_t *efl, + haddr_t *addr, size_t size, uint8 *buf) { int i, fd=-1; size_t to_read, cur, skip=0; @@ -416,7 +416,7 @@ H5O_efl_read (H5F_t *f, const H5O_efl_t *efl, haddr_t *addr, size_t size, if ((n=read (fd, buf, to_read))<0) { HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "read error in external raw data file"); - } else if (nslot[i].size-skip, size); - if (write (fd, buf, to_write)!=to_write) { + if ((size_t)write (fd, buf, to_write)!=to_write) { HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "write error in external raw data file"); } diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 90317fc..de86366 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -42,9 +42,9 @@ #define H5O_ALL (-1) /*delete all messages of type */ /* Flags which are part of a message */ -#define H5O_FLAG_CONSTANT 0x01 -#define H5O_FLAG_SHARED 0x02 -#define H5O_FLAG_BITS 0x03 +#define H5O_FLAG_CONSTANT 0x01u +#define H5O_FLAG_SHARED 0x02u +#define H5O_FLAG_BITS 0x03u #define H5O_VERSION 1 /* @@ -146,8 +146,8 @@ typedef struct H5O_efl_entry_t { typedef struct H5O_efl_t { haddr_t heap_addr; /*address of name heap */ - uintn nalloc; /*number of slots allocated */ - uintn nused; /*number of slots used */ + intn nalloc; /*number of slots allocated */ + intn nused; /*number of slots used */ H5O_efl_entry_t *slot; /*array of external file entries */ } H5O_efl_t; @@ -161,7 +161,7 @@ extern const H5O_class_t H5O_LAYOUT[1]; typedef struct H5O_layout_t { int type; /*type of layout, H5D_layout_t */ haddr_t addr; /*file address of data or B-tree */ - uintn ndims; /*num dimensions in stored data */ + intn ndims; /*num dimensions in stored data */ size_t dim[H5O_LAYOUT_NDIMS]; /*size of data or chunk */ } H5O_layout_t; diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 21d8f3c..16c1c71 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -72,7 +72,7 @@ static void * H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj) { H5S_simple_t *sdim = NULL;/* New simple dimensionality structure */ - uintn u; /* local counting variable */ + intn u; /* local counting variable */ uintn flags; FUNC_ENTER(H5O_sdspace_decode, NULL); @@ -134,7 +134,7 @@ static herr_t H5O_sdspace_encode(H5F_t *f, uint8 *p, const void *mesg) { const H5S_simple_t *sdim = (const H5S_simple_t *) mesg; - uintn u; /* Local counting variable */ + intn u; /* Local counting variable */ uintn flags = 0; FUNC_ENTER(H5O_sdspace_encode, FAIL); @@ -230,7 +230,7 @@ H5O_sdspace_copy(const void *mesg, void *dest) portion of the message). It doesn't take into account alignment. --------------------------------------------------------------------------*/ static size_t -H5O_sdspace_size(H5F_t *f, const void *mesg) +H5O_sdspace_size(H5F_t *f __attribute__((unused)), const void *mesg) { const H5S_simple_t *sdim = (const H5S_simple_t *) mesg; size_t ret_value = 8; /* all dimensionality messages are at least 8 bytes long (rank and flags) */ @@ -267,7 +267,7 @@ H5O_sdspace_debug(H5F_t *f, const void *mesg, FILE * stream, intn indent, intn fwidth) { const H5S_simple_t *sdim = (const H5S_simple_t *) mesg; - uintn u; /* local counting variable */ + intn u; /* local counting variable */ FUNC_ENTER(H5O_sdspace_debug, FAIL); diff --git a/src/H5Oshared.c b/src/H5Oshared.c index a62a562..0616425 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -133,7 +133,7 @@ H5O_shared_encode (H5F_t *f, uint8 *buf/*out*/, const void *_mesg) *------------------------------------------------------------------------- */ static size_t -H5O_shared_size (H5F_t *f, const void *_mesg) +H5O_shared_size (H5F_t *f, const void *_mesg __attribute__((unused))) { FUNC_ENTER (H5O_shared_size, 0); FUNC_LEAVE (H5F_SIZEOF_ADDR(f)+4); diff --git a/src/H5Ostab.c b/src/H5Ostab.c index a5b0dc7..5c29942 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -218,7 +218,7 @@ H5O_stab_copy(const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_stab_size(H5F_t *f, const void *_mesg) +H5O_stab_size(H5F_t *f, const void *_mesg __attribute__((unused))) { FUNC_ENTER(H5O_stab_size, 0); FUNC_LEAVE(2 * H5F_SIZEOF_ADDR(f)); diff --git a/src/H5P.c b/src/H5P.c index 04020a5..0d30037 100644 --- a/src/H5P.c +++ b/src/H5P.c @@ -460,12 +460,11 @@ H5Pset_userblock(hid_t tid, size_t size) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file creation template"); } - for (i = 8; i < 8 * sizeof(int); i++) { - uintn p2 = 8 == i ? 0 : 1 << i; - if (size == p2) - break; + for (i=8; i<8*(intn)sizeof(int); i++) { + uintn p2 = 8 == i ? 0 : 1 << i; + if (size == p2) break; } - if (i >= 8 * sizeof(int)) { + if (i>=8*(intn)sizeof(int)) { HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is not valid"); } @@ -888,7 +887,7 @@ H5Pset_chunk(hid_t tid, int ndims, const size_t dim[]) HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk dimensionality must be positive"); } - if (ndims > NELMTS(tmpl->chunk_size)) { + if (ndims > (intn)NELMTS(tmpl->chunk_size)) { HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk dimensionality is too large"); } diff --git a/src/H5S.c b/src/H5S.c index 91c8b83..8d854ea 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -1122,7 +1122,7 @@ H5Sset_hyperslab(hid_t sid, const int *start, const size_t *count, const size_t /* Range check arguments */ for (u=0; uu.simple.rank; u++) { - if (start[u]<0 || start[u]>=space->u.simple.size[u]) { + if (start[u]<0 || (size_t)(start[u])>=space->u.simple.size[u]) { HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "hyperslab bounds out of range"); } @@ -1135,9 +1135,9 @@ H5Sset_hyperslab(hid_t sid, const int *start, const size_t *count, const size_t /* Allocate space for the hyperslab information */ if (NULL==space->h.start) { - space->h.start= H5MM_xcalloc(space->u.simple.rank,sizeof(intn)); - space->h.count= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t)); - space->h.stride= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t)); + space->h.start= H5MM_xcalloc(space->u.simple.rank, sizeof(intn)); + space->h.count= H5MM_xcalloc(space->u.simple.rank, sizeof(size_t)); + space->h.stride= H5MM_xcalloc(space->u.simple.rank, sizeof(size_t)); } /* Build hyperslab */ diff --git a/src/H5Ssimp.c b/src/H5Ssimp.c index a785b35..a7580c3 100644 --- a/src/H5Ssimp.c +++ b/src/H5Ssimp.c @@ -383,7 +383,7 @@ H5S_simp_mgath (const void *buf, size_t elmt_size, /* Argument type problems to be fixed later..... -RPM */ if ((space_ndims=H5S_get_hyperslab (mem_space, mem_offset_signed, hsize, sample))<0) { - HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, + HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0, "unable to retrieve hyperslab parameters"); } for (i=0; ipriv); FUNC_ENTER (H5T_conv_struct, FAIL); diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index ea80fcb..388c20a 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -38,7 +38,7 @@ intn H5T_invalidate_cb (void *obj, const void *call_data); size_t H5T_get_size (const H5T_t *dt); intn H5T_cmp (const H5T_t *dt1, const H5T_t *dt2); hbool_t H5T_is_atomic (const H5T_t *dt); -herr_t H5T_insert (H5T_t *parent, const char *name, off_t offset, +herr_t H5T_insert (H5T_t *parent, const char *name, size_t offset, const H5T_t *member); herr_t H5T_sort_by_offset (H5T_t *dt); herr_t H5T_pack (H5T_t *dt); diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 60a0311..c17ac3a 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -20,8 +20,8 @@ #include #include -#define HOFFSET(S,M) ((const char*)&S.M-(const char*)&S) -#define HPOFFSET(P,M) ((const char*)&(P->M)-(const char*)P) +#define HOFFSET(S,M) ((size_t)((const char*)&S.M-(const char*)&S)) +#define HPOFFSET(P,M) ((size_t)((const char*)&(P->M)-(const char*)P)) /* These are the various classes of data types */ typedef enum H5T_class_t { @@ -188,7 +188,7 @@ herr_t H5Tshare (hid_t location_id, hid_t type_id); hbool_t H5Tis_shared (hid_t location_id, hid_t type_id); /* Operations defined on compound data types */ -herr_t H5Tinsert (hid_t parent_id, const char *name, off_t offset, +herr_t H5Tinsert (hid_t parent_id, const char *name, size_t offset, hid_t member_id); herr_t H5Tpack (hid_t type_id); diff --git a/src/H5V.c b/src/H5V.c index c9f3de2..bd686c2f 100644 --- a/src/H5V.c +++ b/src/H5V.c @@ -40,9 +40,11 @@ static hbool_t interface_initialize_g = TRUE; *------------------------------------------------------------------------- */ herr_t -H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size, - ssize_t *stride1) +H5V_stride_optimize1(intn *np/*in,out*/, size_t *_elmt_size/*in,out*/, + size_t *size, ssize_t *stride1) { + ssize_t *elmt_size = (ssize_t *)_elmt_size; + FUNC_ENTER(H5V_stride_optimize1, FAIL); /* @@ -50,6 +52,7 @@ H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size, * zero we still must make one reference. */ assert(1 == H5V_vector_reduce_product(0, NULL)); + assert (*elmt_size>0); /* * Combine adjacent memory accesses @@ -87,9 +90,11 @@ H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size, *------------------------------------------------------------------------- */ herr_t -H5V_stride_optimize2(intn *np, size_t *elmt_size, size_t *size, - ssize_t *stride1, ssize_t *stride2) +H5V_stride_optimize2(intn *np/*in,out*/, size_t *_elmt_size/*in,out*/, + size_t *size, ssize_t *stride1, ssize_t *stride2) { + ssize_t *elmt_size = (ssize_t *)_elmt_size; + FUNC_ENTER(H5V_stride_optimize2, FAIL); /* @@ -97,6 +102,7 @@ H5V_stride_optimize2(intn *np, size_t *elmt_size, size_t *size, * zero we still must make one reference. */ assert(1 == H5V_vector_reduce_product(0, NULL)); + assert (*elmt_size>0); /* * Combine adjacent memory accesses @@ -286,7 +292,7 @@ H5V_hyper_disjointp(intn n, herr_t H5V_hyper_fill(intn n, const size_t *_size, const size_t *total_size, const size_t *offset, void *_dst, - uint8 fill_value) + uintn fill_value) { uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */ size_t size[H5V_HYPER_NDIMS]; /*a modifiable copy of _size */ @@ -436,25 +442,26 @@ H5V_hyper_copy(intn n, const size_t *_size, */ herr_t H5V_stride_fill(intn n, size_t elmt_size, const size_t *size, - const ssize_t *stride, void *_dst, uint8 fill_value) + const ssize_t *stride, void *_dst, uintn fill_value) { uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */ size_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */ size_t nelmts; /*number of elements to fill */ - intn i, j; /*counters */ + uintn i; /*counter */ + intn j; /*counter */ hbool_t carry; /*subtraction carray value */ FUNC_ENTER(H5V_stride_fill, FAIL); H5V_vector_cpy(n, idx, size); nelmts = H5V_vector_reduce_product(n, size); - for (i = 0; i < nelmts; i++) { + for (i=0; i= 0 && carry; --j) { + for (j=n-1, carry=TRUE; j>=0 && carry; --j) { dst += stride[j]; if (--idx[j]) carry = FALSE; @@ -497,7 +504,8 @@ H5V_stride_copy(intn n, size_t elmt_size, const size_t *size, const uint8 *src = (const uint8 *) _src; /*cast for ptr arithmetic*/ size_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */ size_t nelmts; /*num elements to copy */ - intn i, j; /*counters */ + uintn i; /*counter */ + intn j; /*counters */ hbool_t carry; /*carray for subtraction*/ FUNC_ENTER(H5V_stride_copy, FAIL); @@ -506,13 +514,13 @@ H5V_stride_copy(intn n, size_t elmt_size, const size_t *size, if (n) { H5V_vector_cpy(n, idx, size); nelmts = H5V_vector_reduce_product(n, size); - for (i = 0; i < nelmts; i++) { + for (i=0; i= 0 && carry; --j) { + for (j=n-1, carry=TRUE; j>=0 && carry; --j) { src += src_stride[j]; dst += dst_stride[j]; @@ -563,7 +571,8 @@ H5V_stride_copy2(size_t nelmts, size_t elmt_size, const uint8 *src = (const uint8 *) _src; size_t dst_idx[H5V_HYPER_NDIMS]; size_t src_idx[H5V_HYPER_NDIMS]; - intn i, j; + uintn i; + intn j; hbool_t carry; FUNC_ENTER(H5V_stride_copy2, FAIL); @@ -571,18 +580,18 @@ H5V_stride_copy2(size_t nelmts, size_t elmt_size, H5V_vector_cpy(dst_n, dst_idx, dst_size); H5V_vector_cpy(src_n, src_idx, src_size); - for (i = 0; i < nelmts; i++) { + for (i=0; i= 0 && carry; --j) { + for (j=dst_n-1, carry=TRUE; j>=0 && carry; --j) { dst += dst_stride[j]; if (--dst_idx[j]) carry = FALSE; else dst_idx[j] = dst_size[j]; } - for (j = src_n - 1, carry = TRUE; j >= 0 && carry; --j) { + for (j=src_n-1, carry=TRUE; j>=0 && carry; --j) { src += src_stride[j]; if (--src_idx[j]) carry = FALSE; else src_idx[j] = src_size[j]; diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h index 863fd2e..76c638f 100644 --- a/src/H5Vprivate.h +++ b/src/H5Vprivate.h @@ -36,13 +36,13 @@ hbool_t H5V_hyper_disjointp(intn n, const size_t *offset1, hbool_t H5V_hyper_eq(intn n, const size_t *offset1, const size_t *size1, const size_t *offset2, const size_t *size2); herr_t H5V_hyper_fill(intn n, const size_t *total_size, const size_t *offset, - const size_t *size, void *buf, uint8 val); + const size_t *size, void *buf, uintn val); herr_t H5V_hyper_copy(intn n, const size_t *size, const size_t *dst_total_size, const size_t *dst_offset, void *_dst, const size_t *src_total_size, const size_t *src_offset, const void *_src); herr_t H5V_stride_fill(intn n, size_t elmt_size, const size_t *size, - const ssize_t *stride, void *_dst, uint8 fill_value); + const ssize_t *stride, void *_dst, uintn fill_value); herr_t H5V_stride_copy(intn n, size_t elmt_size, const size_t *_size, const ssize_t *dst_stride, void *_dst, const ssize_t *src_stride, const void *_src); @@ -77,7 +77,7 @@ herr_t H5V_stride_optimize2(intn *np, size_t *elmt_size, size_t *size, */ static inline size_t __attribute__((unused)) -H5V_vector_reduce_product(size_t n, const size_t *v) +H5V_vector_reduce_product(intn n, const size_t *v) { size_t ans = 1; @@ -105,13 +105,12 @@ H5V_vector_reduce_product(size_t n, const size_t *v) */ static inline hbool_t __attribute__((unused)) -H5V_vector_zerop(size_t n, const size_t *v) +H5V_vector_zerop(intn n, const size_t *v) { - if (!v) - return TRUE; - while (n--) - if (*v++) - return FALSE; + if (!v) return TRUE; + while (n--) { + if (*v++) return FALSE; + } return TRUE; } @@ -136,19 +135,14 @@ H5V_vector_zerop(size_t n, const size_t *v) */ static inline intn __attribute__((unused)) -H5V_vector_cmp(size_t n, const size_t *v1, const size_t *v2) +H5V_vector_cmp(intn n, const size_t *v1, const size_t *v2) { - if (v1 == v2) - return 0; + if (v1 == v2) return 0; while (n--) { - if ((v1 ? *v1 : 0) < (v2 ? *v2 : 0)) - return -1; - if ((v1 ? *v1 : 0) > (v2 ? *v2 : 0)) - return 1; - if (v1) - v1++; - if (v2) - v2++; + if ((v1 ? *v1 : 0) < (v2 ? *v2 : 0)) return -1; + if ((v1 ? *v1 : 0) > (v2 ? *v2 : 0)) return 1; + if (v1) v1++; + if (v2) v2++; } return 0; } @@ -169,10 +163,9 @@ H5V_vector_cmp(size_t n, const size_t *v1, const size_t *v2) */ static inline void __attribute__((unused)) -H5V_vector_inc(size_t n, size_t *v1, const size_t *v2) +H5V_vector_inc(intn n, size_t *v1, const size_t *v2) { - while (n--) - *v1++ += *v2++; + while (n--) *v1++ += *v2++; } #endif diff --git a/src/H5detect.c b/src/H5detect.c index 93343fd..3f7c251 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -29,7 +29,6 @@ static const char *FileHeader = "\n\ * *------------------------------------------------------------------------- */ - #include #include #include @@ -163,7 +162,7 @@ static detected_t Known[] = INFO.varname = #VAR; \ INFO.size = sizeof(TYPE); \ for (_i=sizeof(TYPE),_v=0; _i>0; --_i) _v = (_v<<8) + _i; \ - for (_i=0,_x=(unsigned char *)&_v; _i=0) { \ if (0==_i || INFO.perm[_i-1]!=_j) { \ @@ -870,7 +869,7 @@ bit.\n"; char *comma; if ((pwd = getpwuid(getuid()))) { if ((comma = strchr(pwd->pw_gecos, ','))) { - n = MIN(sizeof(real_name) - 1, comma - pwd->pw_gecos); + n = MIN(sizeof(real_name)-1, (unsigned)(comma-pwd->pw_gecos)); strncpy(real_name, pwd->pw_gecos, n); real_name[n] = '\0'; } else { @@ -953,9 +952,8 @@ bit.\n"; *------------------------------------------------------------------------- */ int -main(int argc, char *argv[]) +main(void) { - detected_t d[MAXDETECT]; int nd = 0; diff --git a/src/h5ls.c b/src/h5ls.c index e8ac70c..07bdd74 100644 --- a/src/h5ls.c +++ b/src/h5ls.c @@ -10,6 +10,11 @@ #include #include +#include +#ifndef HAVE_ATTRIBUTE +# undef __attribute__ +# define __attribute__(X) /*void*/ +#endif /*------------------------------------------------------------------------- @@ -29,7 +34,7 @@ *------------------------------------------------------------------------- */ static herr_t -list (hid_t group, const char *name, void *op_data) +list (hid_t group, const char *name, void *op_data __attribute__((unused))) { hid_t obj; hid_t (*func)(void*); diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index cd36ca1..eae78d9 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -14,11 +14,11 @@ /* The first dataset */ typedef struct s1_t { - int a; - int b; - int c; - int d; - int e; + unsigned int a; + unsigned int b; + unsigned int c; + unsigned int d; + unsigned int e; } s1_t; /* The second dataset (same as first) */ @@ -26,39 +26,39 @@ typedef s1_t s2_t; /* The third dataset (reversed fields of s1) */ typedef struct s3_t { - int e; - int d; - int c; - int b; - int a; + unsigned int e; + unsigned int d; + unsigned int c; + unsigned int b; + unsigned int a; } s3_t; /* The fourth dataset (a subset of s1) */ typedef struct s4_t { - int b; - int d; + unsigned int b; + unsigned int d; } s4_t; /* The fifth dataset (a superset of s1) */ typedef struct s5_t { - int pre; - int a; - int b; - int mid1; - int c; - int mid2; - int d; - int e; - int post; + unsigned int pre; + unsigned int a; + unsigned int b; + unsigned int mid1; + unsigned int c; + unsigned int mid2; + unsigned int d; + unsigned int e; + unsigned int post; } s5_t; #if 1 -# define NX 100 -# define NY 2000 +# define NX 100u +# define NY 2000u #else -# define NX 12 -# define NY 9 +# define NX 12u +# define NY 9u #endif @@ -118,14 +118,16 @@ main (void) /* Tenth dataset */ /* Eleventh dataset */ - s5_t *s11 = NULL; + s4_t *s11 = NULL; /* Other variables */ - int i, j, ndims; + unsigned int i, j; + int ndims; hid_t file, dataset, space, PRESERVE; herr_t status; static size_t dim[] = {NX, NY}; - int f_offset[2]; /*offset of hyperslab in file */ + size_t f_offset[2]; /*offset of hyperslab in file */ + int f_temp_offset[2]; size_t h_size[2]; /*size of hyperslab */ size_t h_sample[2]; /*hyperslab sampling */ @@ -396,7 +398,9 @@ STEP 8: Read middle third hyperslab into memory array.\n"); h_size[1] = 2*NY/3 - f_offset[1]; h_sample[0] = 1; h_sample[1] = 1; - status = H5Sset_hyperslab (s8_f_sid, f_offset, h_size, h_sample); + f_temp_offset[0] = (int)(f_offset[0]); + f_temp_offset[1] = (int)(f_offset[1]); + status = H5Sset_hyperslab (s8_f_sid, f_temp_offset, h_size, h_sample); assert (status>=0); /* Create memory data space */ @@ -436,8 +440,10 @@ STEP 8: Read middle third hyperslab into memory array.\n"); STEP 9: Read middle third of hyperslab into middle third of memory array.\n"); fflush (stdout); - /* Initialize with some bit pattern */ - memset (s2, 0xFF, NX*NY*sizeof(s2_t)); + /* Initialize */ + for (i=0; id == ps1->d); assert (ps2->e == ps1->e); } else { - assert (ps2->a == -1); - assert (ps2->b == -1); - assert (ps2->c == -1); - assert (ps2->d == -1); - assert (ps2->e == -1); + assert (ps2->a == (unsigned)(-1)); + assert (ps2->b == (unsigned)(-1)); + assert (ps2->c == (unsigned)(-1)); + assert (ps2->d == (unsigned)(-1)); + assert (ps2->e == (unsigned)(-1)); } } } @@ -475,8 +481,11 @@ STEP 10: Read middle third of hyperslab into middle third of memory array\n\ where some of the struct members are already initialized.\n"); fflush (stdout); - /* Initialize with some bit pattern */ - memset (s5, 0xFF, NX*NY*sizeof(s5_t)); + /* Initialize */ + for (i=0; i=f_offset[0] && i=f_offset[1] && jpre == -1); + assert (ps5->pre == (unsigned)(-1)); assert (ps5->a == ps1->a); assert (ps5->b == ps1->b); - assert (ps5->mid1 == -1); + assert (ps5->mid1 == (unsigned)(-1)); assert (ps5->c == ps1->c); - assert (ps5->mid2 == -1); + assert (ps5->mid2 == (unsigned)(-1)); assert (ps5->d == ps1->d); assert (ps5->e == ps1->e); - assert (ps5->post == -1); + assert (ps5->post == (unsigned)(-1)); } else { - assert (ps5->pre == -1); - assert (ps5->a == -1); - assert (ps5->b == -1); - assert (ps5->mid1 == -1); - assert (ps5->c == -1); - assert (ps5->mid2 == -1); - assert (ps5->d == -1); - assert (ps5->e == -1); - assert (ps5->post == -1); + assert (ps5->pre == (unsigned)(-1)); + assert (ps5->a == (unsigned)(-1)); + assert (ps5->b == (unsigned)(-1)); + assert (ps5->mid1 == (unsigned)(-1)); + assert (ps5->c == (unsigned)(-1)); + assert (ps5->mid2 == (unsigned)(-1)); + assert (ps5->d == (unsigned)(-1)); + assert (ps5->e == (unsigned)(-1)); + assert (ps5->post == (unsigned)(-1)); } } } @@ -523,11 +532,17 @@ STEP 11: Write an array back to the middle third of the dataset to\n\ fflush (stdout); /* Create the memory array and initialize all fields to zero */ - ndims = H5Sget_hyperslab (s8_f_sid, f_offset, h_size, h_sample); + f_temp_offset[0] = (int)(f_offset[0]); + f_temp_offset[1] = (int)(f_offset[1]); + ndims = H5Sget_hyperslab (s8_f_sid, f_temp_offset, h_size, h_sample); assert (ndims==2); s11 = malloc (h_size[0]*h_size[1]*sizeof(s4_t)); assert (s11); - memset (s11, 0xff, h_size[0]*h_size[1]*sizeof(s4_t)); + + /* Initialize */ + for (i=0; ie == 5*(i*NY+j)+4); if (i>=f_offset[0] && i=f_offset[1] && jb == -1); - assert (ps1->d == -1); + assert (ps1->b == (unsigned)(-1)); + assert (ps1->d == (unsigned)(-1)); } else { assert (ps1->b == 5*(i*NY+j)+1); assert (ps1->d == 5*(i*NY+j)+3); diff --git a/test/dsets.c b/test/dsets.c index eaca4a8..6f294f2 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -14,10 +14,17 @@ #include #include +#include +#ifndef HAVE_ATTRIBUTE +# undef __attribute__ +# define __attribute__(X) /*void*/ +#endif + #ifndef HAVE_FUNCTION -#undef __FUNCTION__ -#define __FUNCTION__ "" +# undef __FUNCTION__ +# define __FUNCTION__ "" #endif + #define AT() printf (" at %s:%d in %s()...\n", \ __FILE__, __LINE__, __FUNCTION__); @@ -44,7 +51,7 @@ *------------------------------------------------------------------------- */ static herr_t -display_error_cb (void *client_data) +display_error_cb (void *client_data __attribute__((unused))) { puts ("*FAILED*"); H5Eprint (stdout); diff --git a/test/external.c b/test/external.c index 1e0df7e..7f0ff23 100644 --- a/test/external.c +++ b/test/external.c @@ -15,6 +15,12 @@ #include #include +#include +#ifndef HAVE_ATTRIBUTE +# undef __attribute__ +# define __attribute__(X) /*void*/ +#endif + static int nerrors_g = 0; @@ -35,7 +41,7 @@ static int nerrors_g = 0; *------------------------------------------------------------------------- */ static herr_t -display_error_cb (void *client_data) +display_error_cb (void *client_data __attribute__((unused))) { puts ("*FAILED*"); H5Eprint (stdout); @@ -74,9 +80,12 @@ same_contents (const char *name1, const char *name2) while (1) { n1 = read (fd1, buf1, sizeof(buf1)); n2 = read (fd2, buf2, sizeof(buf2)); + assert (n1>=0 && (size_t)n1<=sizeof(buf1)); + assert (n2>=0 && (size_t)n2<=sizeof(buf2)); assert (n1==n2); + if (n1<=0 && n2<=0) break; - if (memcmp (buf1, buf2, n1)) { + if (memcmp (buf1, buf2, (size_t)n1)) { close (fd1); close (fd2); return 0; @@ -480,7 +489,8 @@ test_2 (void) { hid_t file, plist, space, dset, grp; herr_t status; - int fd,i, j; + int fd; + unsigned i, j; ssize_t n; char fname[64]; int part[25], whole[100]; @@ -495,8 +505,8 @@ test_2 (void) sprintf (fname, "extern_%d.raw", i+1); fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 0666); assert (fd>=0); - n = lseek (fd, i*10, SEEK_SET); - assert (n==i*10); + n = lseek (fd, (ssize_t)(i*10), SEEK_SET); + assert (n>=0 && (size_t)n==i*10); n = write (fd, part, sizeof(part)); assert (n==sizeof(part)); close (fd); @@ -550,7 +560,7 @@ test_2 (void) } for (i=0; i<100; i++) { - if (whole[i]!=i) { + if (whole[i]!=(signed)i) { puts ("*FAILED*"); puts (" Incorrect value(s) read."); nerrors_g++; @@ -596,7 +606,7 @@ test_2 (void) #endif for (i=hs_start; i 1) { + for (i=0; i1) { printf("i=%d:\n", i); } else { printf("%03d:", i); } - for (j = 0; j < ny; j++) { - if (nz > 1) + for (j=0; j1) printf("%03d:", j); - for (k = 0; k < nz; k++) { + for (k=0; k 1) + if (nz>1) printf("\n"); } printf("\n"); @@ -120,7 +120,7 @@ print_ref(size_t nx, size_t ny, size_t nz) { uint8 *array; - array = H5MM_xcalloc(nx * ny * nz, sizeof(uint8)); + array = H5MM_xcalloc((intn)(nx*ny*nz), sizeof(uint8)); printf("Reference array:\n"); init_full(array, nx, ny, nz); @@ -154,7 +154,7 @@ test_fill(size_t nx, size_t ny, size_t nz, size_t dst_offset[3]; /*offset of hyperslab in dest */ uintn ref_value; /*reference value */ uintn acc; /*accumulator */ - int i, j, k, dx, dy, dz; /*counters */ + size_t i, j, k, dx, dy, dz; /*counters */ size_t u, v, w; int ndims; /*hyperslab dimensionality */ char dim[64], s[256]; /*temp string */ @@ -183,7 +183,7 @@ test_fill(size_t nx, size_t ny, size_t nz, fflush(stdout); /* Allocate array */ - dst = H5MM_xcalloc(nx * ny * nz, 1); + dst = H5MM_xcalloc(1, nx*ny*nz); init_full(dst, nx, ny, nz); for (i = 0; i < nx; i += di) { @@ -321,7 +321,7 @@ test_copy(int mode, size_t src_offset[3]; /*offset of hyperslab in source */ uintn ref_value; /*reference value */ uintn acc; /*accumulator */ - int i, j, k, dx, dy, dz; /*counters */ + size_t i, j, k, dx, dy, dz; /*counters */ size_t u, v, w; int ndims; /*hyperslab dimensionality */ char dim[64], s[256]; /*temp string */ @@ -380,8 +380,8 @@ test_copy(int mode, /* * Allocate arrays */ - src = H5MM_xcalloc(nx * ny * nz, 1); - dst = H5MM_xcalloc(nx * ny * nz, 1); + src = H5MM_xcalloc(1, nx*ny*nz); + dst = H5MM_xcalloc(1, nx*ny*nz); init_full(src, nx, ny, nz); for (i = 0; i < nx; i += di) { @@ -571,9 +571,9 @@ test_copy(int mode, *------------------------------------------------------------------------- */ static herr_t -test_multifill(int nx) +test_multifill(size_t nx) { - int i, j; + size_t i, j; size_t size; ssize_t src_stride; ssize_t dst_stride; @@ -690,7 +690,7 @@ test_endian(size_t nx) ssize_t src_stride[2]; /*source strides */ ssize_t dst_stride[2]; /*destination strides */ size_t size[2]; /*size vector */ - int i, j; + size_t i, j; printf("%-70s", "Testing endian conversion by stride"); fflush(stdout); @@ -698,7 +698,7 @@ test_endian(size_t nx) /* Initialize arrays */ src = H5MM_xmalloc(nx * 4); init_full(src, nx, 4, 1); - dst = H5MM_xcalloc(nx, 4); + dst = H5MM_xcalloc(4, nx); /* Initialize strides */ src_stride[0] = 0; @@ -766,7 +766,7 @@ test_transpose(size_t nx, size_t ny) { intn *src = NULL; intn *dst = NULL; - int i, j; + size_t i, j; ssize_t src_stride[2], dst_stride[2]; size_t size[2]; char s[256]; @@ -783,7 +783,7 @@ test_transpose(size_t nx, size_t ny) src[i * ny + j] = (intn)(i * ny + j); } } - dst = H5MM_xcalloc(nx * ny, sizeof(*dst)); + dst = H5MM_xcalloc((intn)(nx*ny), sizeof(*dst)); /* Build stride info */ size[0] = nx; @@ -873,7 +873,7 @@ test_sub_super(size_t nx, size_t ny) ssize_t src_stride[4]; /*source stride info */ ssize_t dst_stride[4]; /*destination stride info */ size_t size[4]; /*number of sample points */ - int i, j; + size_t i, j; char s[256]; sprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ", @@ -885,8 +885,8 @@ test_sub_super(size_t nx, size_t ny) /* Initialize */ full = H5MM_xmalloc(4 * nx * ny); init_full(full, 2 * nx, 2 * ny, 1); - half = H5MM_xcalloc(nx * ny, 1); - twice = H5MM_xcalloc(4 * nx * ny, 1); + half = H5MM_xcalloc(1, nx*ny); + twice = H5MM_xcalloc(1, 4*nx*ny); /* Setup */ size[0] = nx; diff --git a/test/iopipe.c b/test/iopipe.c index 4d856b9..640b2d3 100644 --- a/test/iopipe.c +++ b/test/iopipe.c @@ -213,7 +213,7 @@ main (void) offset = lseek (fd, 0, SEEK_SET); assert (0==offset); n = write (fd, the_data, size[0]*size[1]); - assert (n==size[0]*size[1]); + assert (n>=0 && (size_t)n==size[0]*size[1]); } getrusage (RUSAGE_SELF, &r_stop); gettimeofday (&t_stop, NULL); @@ -252,7 +252,7 @@ main (void) offset = lseek (fd, 0, SEEK_SET); assert (0==offset); n = read (fd, the_data, size[0]*size[1]); - assert (n==size[0]*size[1]); + assert (n>=0 && (size_t)n==size[0]*size[1]); } getrusage (RUSAGE_SELF, &r_stop); gettimeofday (&t_stop, NULL); diff --git a/test/istore.c b/test/istore.c index f95c3fd..9a906cc 100644 --- a/test/istore.c +++ b/test/istore.c @@ -60,7 +60,7 @@ size_t zero[H5O_LAYOUT_NDIMS]; static void print_array(uint8 *array, size_t nx, size_t ny, size_t nz) { - int i, j, k; + size_t i, j, k; for (i = 0; i < nx; i++) { if (nz > 1) { @@ -118,7 +118,7 @@ new_object(H5F_t *f, const char *name, intn ndims, H5G_entry_t *ent/*out*/) layout.type = H5D_CHUNKED; layout.ndims = ndims; for (i = 0; i < ndims; i++) { - if (i < NELMTS(align_g)) { + if (i < (int)NELMTS(align_g)) { layout.dim[i] = align_g[i]; } else { layout.dim[i] = 2; @@ -206,16 +206,17 @@ static herr_t test_extend(H5F_t *f, const char *prefix, size_t nx, size_t ny, size_t nz) { - H5G_entry_t handle; - int i, j, k, ndims, ctr; - uint8 *buf = NULL, *check = NULL, *whole = NULL; - char dims[64], s[256], name[256]; - size_t offset[3]; - size_t max_corner[3]; - size_t size[3]; - size_t whole_size[3]; - size_t nelmts; - H5O_layout_t layout; + H5G_entry_t handle; + size_t i, j, k, ctr; + int ndims; + uint8 *buf = NULL, *check = NULL, *whole = NULL; + char dims[64], s[256], name[256]; + size_t offset[3]; + size_t max_corner[3]; + size_t size[3]; + size_t whole_size[3]; + size_t nelmts; + H5O_layout_t layout; if (!nz) { if (!ny) { @@ -237,7 +238,7 @@ test_extend(H5F_t *f, const char *prefix, printf("%-70s", s); buf = H5MM_xmalloc(nx * ny * nz); check = H5MM_xmalloc(nx * ny * nz); - whole = H5MM_xcalloc(nx * ny * nz, 1); + whole = H5MM_xcalloc(1, nx*ny*nz); /* Build the new empty object */ sprintf(name, "%s_%s", prefix, dims); @@ -279,7 +280,7 @@ test_extend(H5F_t *f, const char *prefix, size[0] = size[1] = size[2] = 1; nelmts = 1; } else { - for (i = 0, nelmts = 1; i < ndims; i++) { + for (i=0, nelmts=1; i<(size_t)ndims; i++) { if (ctr % ndims == i) { offset[i] = max_corner[i]; size[i] = MIN(1, whole_size[i] - offset[i]); @@ -311,9 +312,8 @@ test_extend(H5F_t *f, const char *prefix, #endif /* Fill the source array */ - if (0 == nelmts) - continue; - memset(buf, 128 + ctr, nelmts); + if (0 == nelmts) continue; + memset(buf, (signed)(128+ctr), nelmts); /* Write to disk */ if (H5F_arr_write(f, &layout, NULL, size, size, zero, offset, buf)<0) { @@ -353,7 +353,7 @@ test_extend(H5F_t *f, const char *prefix, size, H5V_ZERO, buf); /*src */ /* Update max corner */ - for (i = 0; i < ndims; i++) { + for (i=0; i<(size_t)ndims; i++) { max_corner[i] = MAX(max_corner[i], offset[i] + size[i]); } } @@ -426,12 +426,13 @@ static herr_t test_sparse(H5F_t *f, const char *prefix, size_t nblocks, size_t nx, size_t ny, size_t nz) { - intn ndims, ctr; - char dims[64], s[256], name[256]; - size_t offset[3], size[3], total = 0; - H5G_entry_t handle; - H5O_layout_t layout; - uint8 *buf = NULL; + intn ndims; + size_t ctr; + char dims[64], s[256], name[256]; + size_t offset[3], size[3], total = 0; + H5G_entry_t handle; + H5O_layout_t layout; + uint8 *buf = NULL; if (!nz) { if (!ny) { @@ -470,14 +471,14 @@ test_sparse(H5F_t *f, const char *prefix, size_t nblocks, } goto error; } - for (ctr = 0; ctr < nblocks; ctr++) { + for (ctr=0; ctr #include +#include +#ifndef HAVE_ATTRIBUTE +# undef __attribute__ +# define __attribute__(X) /*void*/ +#endif + /*------------------------------------------------------------------------- * Function: display_error_cb @@ -28,7 +34,7 @@ *------------------------------------------------------------------------- */ static herr_t -display_error_cb (void *client_data) +display_error_cb (void *client_data __attribute__((unused))) { puts ("*FAILED*"); H5Eprint (stdout); diff --git a/test/tstab.c b/test/tstab.c index 94641aa..291dbd4 100644 --- a/test/tstab.c +++ b/test/tstab.c @@ -102,7 +102,7 @@ test_2(void) * Create a directory that has so many entries that the root * of the B-tree ends up splitting. */ - dir = H5Gcreate(fid, "/big", nsyms * 16 + 2); + dir = H5Gcreate(fid, "/big", (size_t)nsyms*16+2); CHECK_I(dir, "H5Gcreate"); status = H5Gclose(dir); CHECK_I(status, "H5Gclose"); -- cgit v0.12