summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5F.c3
-rw-r--r--src/H5Fprivate.h3
-rw-r--r--src/H5HL.c13
-rw-r--r--src/H5Iprivate.h1
-rw-r--r--src/H5Ipublic.h4
-rw-r--r--src/H5MF.c91
-rw-r--r--src/H5MFprivate.h4
-rw-r--r--src/H5O.c109
-rw-r--r--src/H5Oprivate.h26
-rw-r--r--src/H5T.c9
-rw-r--r--test/cache.c4
-rw-r--r--test/dtransform.c2
-rw-r--r--test/dtypes.c32
-rw-r--r--test/lheap.c1
-rw-r--r--test/ohdr.c1
-rwxr-xr-xtest/reserved.c273
-rw-r--r--test/tid.c12
-rw-r--r--test/titerate.c12
-rw-r--r--test/unlink.c2
19 files changed, 326 insertions, 276 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 66d8587..92b87c0 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -4347,7 +4347,6 @@ H5F_get_eoa(const H5F_t *f)
{
haddr_t ret_value;
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
FUNC_ENTER_NOAPI(H5F_get_eoa, HADDR_UNDEF)
assert(f);
@@ -4359,7 +4358,7 @@ H5F_get_eoa(const H5F_t *f)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5F_get_base_addr() */
+} /* end H5F_get_eoa() */
#ifdef H5_HAVE_PARALLEL
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 2e92415..d516dc5 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -212,6 +212,8 @@ typedef struct H5F_t H5F_t;
#define H5F_HAS_FEATURE(F,FL) ((F)->shared->lf->feature_flags&(FL))
/* B-tree node raw page */
#define H5F_GRP_BTREE_SHARED(F) ((F)->shared->grp_btree_shared)
+/* Base address of file */
+#define H5F_BASE_ADDR(F) ((F)->shared->base_addr)
#else /* H5F_PACKAGE */
#define H5F_SIZEOF_ADDR(F) (H5F_sizeof_addr(F))
#define H5F_SIZEOF_SIZE(F) (H5F_sizeof_size(F))
@@ -222,6 +224,7 @@ typedef struct H5F_t H5F_t;
#define H5F_RDCC_W0(F) (H5F_rdcc_w0(F))
#define H5F_HAS_FEATURE(F,FL) (H5F_has_feature(F,FL))
#define H5F_GRP_BTREE_SHARED(F) (H5F_grp_btree_shared(F))
+#define H5F_BASE_ADDR(F) (H5F_base_addr(F))
#endif /* H5F_PACKAGE */
diff --git a/src/H5HL.c b/src/H5HL.c
index bfbb2ac..e0202f2 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -341,7 +341,7 @@ H5HL_minimize_heap_space(H5F_t *f, hid_t dxpl_id, H5HL_t *heap)
* When the heap is being flushed to disk, release the file space reserved
* for it.
*/
- H5MF_free_reserved(f, heap->disk_resrv);
+ H5MF_free_reserved(f, (hsize_t)heap->disk_resrv);
heap->disk_resrv = 0;
/*
@@ -1021,7 +1021,7 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t buf_size, const void *
else
disk_resrv = heap->mem_alloc + need_more - heap->disk_resrv;
- if( H5MF_reserve(f, disk_resrv) < 0 )
+ if( H5MF_reserve(f, (hsize_t)disk_resrv) < 0 )
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1), "unable to reserve space in file");
/* Update heap's record of how much space it has reserved */
@@ -1359,8 +1359,15 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr)
HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap data");
} /* end else */
+ /* Release the local heap metadata from the cache */
+ if (H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, TRUE)<0) {
+ heap = NULL;
+ HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release local heap");
+ }
+ heap = NULL;
+
done:
- if (heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, TRUE)<0)
+ if (heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, FALSE)<0)
HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release local heap");
FUNC_LEAVE_NOAPI(ret_value);
diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h
index 2f0bdb8..667af3d1 100644
--- a/src/H5Iprivate.h
+++ b/src/H5Iprivate.h
@@ -26,7 +26,6 @@
/* Private headers needed by this file */
#include "H5private.h"
-#include "H5Oprivate.h"
/* Macro to determine if a H5I_type_t is a "library type" */
#define H5I_IS_LIB_TYPE( type ) (type > 0 && type < H5I_NTYPES)
diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h
index 9d76d63..d6ed95b 100644
--- a/src/H5Ipublic.h
+++ b/src/H5Ipublic.h
@@ -33,8 +33,8 @@
*
*/
typedef enum {
- H5I_UNINIT = (-2), /*uninitialized type */
- H5I_BADID = (-1), /*invalid Type */
+ H5I_UNINIT = (-2), /*uninitialized type */
+ H5I_BADID = (-1), /*invalid Type */
H5I_FILE = 1, /*type ID for File objects */
H5I_FILE_CLOSING, /*files pending close due to open objhdrs */
H5I_GROUP, /*type ID for Group objects */
diff --git a/src/H5MF.c b/src/H5MF.c
index 7761796..3de5afe 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -78,13 +78,14 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, hsize_t size)
/* Fail if we don't have write access */
if (0==(f->intent & H5F_ACC_RDWR))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "file is read-only");
+
/* Check that the file can address the new space */
- if( H5MF_alloc_overflow(f, size) != 0 )
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "not enough address space in file");
+ if( H5MF_alloc_overflow(f, size) )
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "not enough address space in file");
/* Allocate space from the virtual file layer */
if (HADDR_UNDEF==(ret_value=H5FD_alloc(f->shared->lf, type, dxpl_id, size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed");
/* Convert absolute file address to relative file address */
assert(ret_value>=f->shared->base_addr);
@@ -195,10 +196,10 @@ H5MF_realloc(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, haddr_t old_addr, hsize_t
/* Convert old relative address to absolute address */
old_addr += f->shared->base_addr;
- /* Check that the file can address the new space. */
- /* In the worst case, this means adding new_size bytes to the end of the file. */
- if( H5MF_alloc_overflow(f, new_size) != 0 )
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "not enough address space in file");
+ /* Check that the file can address the new space. */
+ /* In the worst case, this means adding new_size bytes to the end of the file. */
+ if( H5MF_alloc_overflow(f, new_size) )
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "not enough address space in file");
/* Reallocate memory from the virtual file layer */
ret_value = H5FD_realloc(f->shared->lf, type, dxpl_id, old_addr, old_size,
@@ -216,7 +217,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value);
}
-
/*-------------------------------------------------------------------------
* Function: H5MF_reserve
*
@@ -238,22 +238,24 @@ done:
* Modifications:
*-------------------------------------------------------------------------
*/
-herr_t H5MF_reserve(H5F_t *f, hsize_t size)
+herr_t
+H5MF_reserve(H5F_t *f, hsize_t size)
{
- herr_t ret_value = SUCCEED;
+ herr_t ret_value = SUCCEED;
+
FUNC_ENTER_NOAPI(H5MF_reserve, FAIL);
- /* Check arguments */
- assert(f);
+ /* Check arguments */
+ assert(f);
- /* Check that there is room in the file to reserve this space */
- if( H5MF_alloc_overflow( f, size ) != 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "not enough address space in file");
+ /* Check that there is room in the file to reserve this space */
+ if( H5MF_alloc_overflow( f, size ) )
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "not enough address space in file");
- f->shared->lf->reserved_alloc += size;
+ f->shared->lf->reserved_alloc += size;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value);
}
/*-------------------------------------------------------------------------
@@ -272,17 +274,22 @@ done:
* Modifications:
*-------------------------------------------------------------------------
*/
-void H5MF_free_reserved(H5F_t *f, hsize_t size)
+herr_t
+H5MF_free_reserved(H5F_t *f, hsize_t size)
{
- /* Check arguments */
- assert(f);
+ FUNC_ENTER_NOAPI_NOFUNC(H5MF_free_reserved)
+
+ /* Check arguments */
+ assert(f);
+
+ /* If this assert breaks, it means that HDF5 is trying to free file space
+ * that was never reserved.
+ */
+ assert(size <= f->shared->lf->reserved_alloc);
- /* If this assert breaks, it means that HDF5 is trying to free file space
- * that was never reserved.
- */
- assert(size <= f->shared->lf->reserved_alloc);
+ f->shared->lf->reserved_alloc -= size;
- f->shared->lf->reserved_alloc -= size;
+ FUNC_LEAVE_NOAPI(SUCCEED)
}
/*-------------------------------------------------------------------------
@@ -302,20 +309,25 @@ void H5MF_free_reserved(H5F_t *f, hsize_t size)
* Modifications:
*-------------------------------------------------------------------------
*/
-int H5MF_alloc_overflow(H5F_t *f, hsize_t size)
+hbool_t
+H5MF_alloc_overflow(H5F_t *f, hsize_t size)
{
- hsize_t space_needed; /* Accumulator variable */
- size_t c;
+ hsize_t space_needed; /* Accumulator variable */
+ size_t c; /* Local index variable */
+ hbool_t ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOFUNC(H5MF_alloc_overflow)
/* Start with the current end of the file's address. */
- space_needed = f->shared->lf->cls->get_eoa(f->shared->lf);
+ space_needed = (hsize_t)H5F_get_eoa(f);
+ HDassert(H5F_addr_defined(space_needed));
/* Subtract the file's base address to get the actual amount of
* space being used:
* (end of allocated space - beginning of allocated space)
*/
- assert(f->shared->base_addr < space_needed);
- space_needed -= f->shared->base_addr;
+ HDassert(H5F_BASE_ADDR(f) < space_needed);
+ space_needed -= (hsize_t)H5F_BASE_ADDR(f);
/* Add the amount of space requested for this allocation */
space_needed += size;
@@ -338,9 +350,11 @@ int H5MF_alloc_overflow(H5F_t *f, hsize_t size)
space_needed = space_needed >> 16;
if(space_needed != 0)
- return 1;
+ ret_value=TRUE;
else
- return 0;
+ ret_value=FALSE;
+
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -369,10 +383,11 @@ htri_t
H5MF_can_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra_requested)
{
htri_t ret_value; /* Return value */
+
FUNC_ENTER_NOAPI(H5MF_can_extend, FAIL);
/* Convert old relative address to absolute address */
- addr += f->shared->base_addr;
+ addr += H5F_BASE_ADDR(f);
/* Pass the request down to the virtual file layer */
if((ret_value=H5FD_can_extend(f->shared->lf, type, addr, size, extra_requested))<0)
@@ -407,15 +422,16 @@ htri_t
H5MF_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra_requested)
{
htri_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5MF_extend, FAIL);
- /* Convert old relative address to absolute address */
- addr += f->shared->base_addr;
+ FUNC_ENTER_NOAPI(H5MF_extend, FAIL);
/* Make sure there is enough addressable space to satisfy the request */
if ( H5MF_alloc_overflow(f, extra_requested) )
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate new file memory: out of address space");
+ /* Convert old relative address to absolute address */
+ addr += H5F_BASE_ADDR(f);
+
/* Pass the request down to the virtual file layer */
if((ret_value=H5FD_extend(f->shared->lf, type, addr, size, extra_requested))<0)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate new file memory");
@@ -423,4 +439,3 @@ H5MF_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra
done:
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5MF_extend() */
-
diff --git a/src/H5MFprivate.h b/src/H5MFprivate.h
index 2a129ea..ee35c2a 100644
--- a/src/H5MFprivate.h
+++ b/src/H5MFprivate.h
@@ -49,8 +49,8 @@ H5_DLL herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
H5_DLL haddr_t H5MF_realloc(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, haddr_t old_addr,
hsize_t old_size, hsize_t new_size);
H5_DLL herr_t H5MF_reserve(H5F_t *f, hsize_t size);
-H5_DLL void H5MF_free_reserved(H5F_t *f, hsize_t size);
-H5_DLL int H5MF_alloc_overflow(H5F_t *f, hsize_t size);
+H5_DLL herr_t H5MF_free_reserved(H5F_t *f, hsize_t size);
+H5_DLL hbool_t H5MF_alloc_overflow(H5F_t *f, hsize_t size);
H5_DLL htri_t H5MF_can_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr,
hsize_t size, hsize_t extra_requested);
H5_DLL htri_t H5MF_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size,
diff --git a/src/H5O.c b/src/H5O.c
index 609b7c6..1515500 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -716,11 +716,10 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
assert(!H5F_addr_defined(oh->chunk[cont->chunkno].addr));
cont->size = oh->chunk[cont->chunkno].size;
- /* Free the space we'd reserved in the file to hold this chunk */
- H5MF_free_reserved(f, cont->size);
+ /* Free the space we'd reserved in the file to hold this chunk */
+ H5MF_free_reserved(f, (hsize_t)cont->size);
- if (HADDR_UNDEF==(cont->addr=H5MF_alloc(f,
- H5FD_MEM_OHDR, dxpl_id, (hsize_t)cont->size)))
+ if (HADDR_UNDEF==(cont->addr=H5MF_alloc(f, H5FD_MEM_OHDR, dxpl_id, (hsize_t)cont->size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate space for object header data");
oh->chunk[cont->chunkno].addr = cont->addr;
}
@@ -970,7 +969,7 @@ H5O_compute_size(H5F_t *f, H5O_t *oh, size_t *size_ptr)
*-------------------------------------------------------------------------
*/
herr_t
-H5O_reset(hid_t type_id, void *native)
+H5O_reset(unsigned type_id, void *native)
{
const H5O_class_t *type; /* Actual H5O class type for the ID */
herr_t ret_value; /* Return value */
@@ -978,7 +977,7 @@ H5O_reset(hid_t type_id, void *native)
FUNC_ENTER_NOAPI(H5O_reset,FAIL);
/* check args */
- assert(type_id>=0 && type_id<(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])));
+ assert(type_id<NELMTS(message_type_g));
type=message_type_g[type_id]; /* map the type ID to the actual type object */
assert(type);
@@ -1050,7 +1049,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
-H5O_free (hid_t type_id, void *mesg)
+H5O_free (unsigned type_id, void *mesg)
{
const H5O_class_t *type; /* Actual H5O class type for the ID */
void * ret_value; /* Return value */
@@ -1058,7 +1057,7 @@ H5O_free (hid_t type_id, void *mesg)
FUNC_ENTER_NOAPI(H5O_free, NULL);
/* check args */
- assert(type_id>=0 && type_id<(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])));
+ assert(type_id<NELMTS(message_type_g));
type=message_type_g[type_id]; /* map the type ID to the actual type object */
assert(type);
@@ -1131,7 +1130,7 @@ H5O_free_real(const H5O_class_t *type, void *mesg)
*-------------------------------------------------------------------------
*/
void *
-H5O_copy (hid_t type_id, const void *mesg, void *dst)
+H5O_copy (unsigned type_id, const void *mesg, void *dst)
{
const H5O_class_t *type; /* Actual H5O class type for the ID */
void *ret_value; /* Return value */
@@ -1139,7 +1138,7 @@ H5O_copy (hid_t type_id, const void *mesg, void *dst)
FUNC_ENTER_NOAPI(H5O_copy, NULL);
/* check args */
- assert(type_id>=0 && type_id<(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])));
+ assert(type_id<NELMTS(message_type_g));
type=message_type_g[type_id]; /* map the type ID to the actual type object */
assert(type);
@@ -1307,7 +1306,7 @@ done:
*-------------------------------------------------------------------------
*/
int
-H5O_count (H5G_entry_t *ent, hid_t type_id, hid_t dxpl_id)
+H5O_count (H5G_entry_t *ent, unsigned type_id, hid_t dxpl_id)
{
const H5O_class_t *type; /* Actual H5O class type for the ID */
int ret_value; /* Return value */
@@ -1318,7 +1317,7 @@ H5O_count (H5G_entry_t *ent, hid_t type_id, hid_t dxpl_id)
assert (ent);
assert (ent->file);
assert (H5F_addr_defined(ent->header));
- assert(type_id>=0 && type_id<(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])));
+ assert(type_id<NELMTS(message_type_g));
type=message_type_g[type_id]; /* map the type ID to the actual type object */
assert (type);
@@ -1409,7 +1408,7 @@ done:
*-------------------------------------------------------------------------
*/
htri_t
-H5O_exists(H5G_entry_t *ent, hid_t type_id, int sequence, hid_t dxpl_id)
+H5O_exists(H5G_entry_t *ent, unsigned type_id, int sequence, hid_t dxpl_id)
{
const H5O_class_t *type; /* Actual H5O class type for the ID */
htri_t ret_value; /* Return value */
@@ -1418,7 +1417,7 @@ H5O_exists(H5G_entry_t *ent, hid_t type_id, int sequence, hid_t dxpl_id)
assert(ent);
assert(ent->file);
- assert(type_id>=0 && type_id<(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])));
+ assert(type_id<NELMTS(message_type_g));
type=message_type_g[type_id]; /* map the type ID to the actual type object */
assert(type);
assert(sequence>=0);
@@ -1519,7 +1518,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
-H5O_read(H5G_entry_t *ent, hid_t type_id, int sequence, void *mesg, hid_t dxpl_id)
+H5O_read(H5G_entry_t *ent, unsigned type_id, int sequence, void *mesg, hid_t dxpl_id)
{
const H5O_class_t *type; /* Actual H5O class type for the ID */
void *ret_value; /* Return value */
@@ -1530,7 +1529,7 @@ H5O_read(H5G_entry_t *ent, hid_t type_id, int sequence, void *mesg, hid_t dxpl_i
assert(ent);
assert(ent->file);
assert(H5F_addr_defined(ent->header));
- assert(type_id>=0 && type_id<(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])));
+ assert(type_id<NELMTS(message_type_g));
type=message_type_g[type_id]; /* map the type ID to the actual type object */
assert(type);
assert(sequence >= 0);
@@ -1764,7 +1763,7 @@ done:
*-------------------------------------------------------------------------
*/
int
-H5O_modify(H5G_entry_t *ent, hid_t type_id, int overwrite,
+H5O_modify(H5G_entry_t *ent, unsigned type_id, int overwrite,
unsigned flags, unsigned update_time, const void *mesg, hid_t dxpl_id)
{
const H5O_class_t *type; /* Actual H5O class type for the ID */
@@ -1776,7 +1775,7 @@ H5O_modify(H5G_entry_t *ent, hid_t type_id, int overwrite,
assert(ent);
assert(ent->file);
assert(H5F_addr_defined(ent->header));
- assert(type_id>=0 && type_id<(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])));
+ assert(type_id<NELMTS(message_type_g));
type=message_type_g[type_id]; /* map the type ID to the actual type object */
assert(type);
assert(mesg);
@@ -2017,7 +2016,7 @@ done:
*-------------------------------------------------------------------------
*/
int
-H5O_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hid_t type_id, unsigned flags,
+H5O_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned type_id, unsigned flags,
const void *mesg)
{
const H5O_class_t *type; /* Actual H5O class type for the ID */
@@ -2028,7 +2027,7 @@ H5O_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hid_t type_id, unsigned flags,
/* check args */
assert(f);
assert(oh);
- assert(type_id>=0 && type_id<(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])));
+ assert(type_id<NELMTS(message_type_g));
type=message_type_g[type_id]; /* map the type ID to the actual type object */
assert(type);
assert(0==(flags & ~H5O_FLAG_BITS));
@@ -2469,7 +2468,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_remove(H5G_entry_t *ent, hid_t type_id, int sequence, hid_t dxpl_id)
+H5O_remove(H5G_entry_t *ent, unsigned type_id, int sequence, hid_t dxpl_id)
{
const H5O_class_t *type; /* Actual H5O class type for the ID */
herr_t ret_value; /* Return value */
@@ -2480,7 +2479,7 @@ H5O_remove(H5G_entry_t *ent, hid_t type_id, int sequence, hid_t dxpl_id)
assert(ent);
assert(ent->file);
assert(H5F_addr_defined(ent->header));
- assert(type_id>=0 && type_id<(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])));
+ assert(type_id<NELMTS(message_type_g));
type=message_type_g[type_id]; /* map the type ID to the actual type object */
assert(type);
@@ -2641,15 +2640,15 @@ H5O_alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size)
for (idx=0; idx<oh->nmesgs; idx++) {
if (oh->mesg[idx].chunkno==chunkno) {
if (H5O_NULL_ID == oh->mesg[idx].type->id &&
- (oh->mesg[idx].raw + oh->mesg[idx].raw_size ==
- oh->chunk[chunkno].image + oh->chunk[chunkno].size)) {
+ (oh->mesg[idx].raw + oh->mesg[idx].raw_size ==
+ oh->chunk[chunkno].image + oh->chunk[chunkno].size)) {
delta = MAX (H5O_MIN_SIZE, aligned_size - oh->mesg[idx].raw_size);
assert (delta=H5O_ALIGN (delta));
- /* Reserve space in the file to hold the increased chunk size */
- if( H5MF_reserve(f, delta) < 0 )
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "unable to reserve space in file");
+ /* Reserve space in the file to hold the increased chunk size */
+ if( H5MF_reserve(f, (hsize_t)delta) < 0 )
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "unable to reserve space in file");
oh->mesg[idx].dirty = TRUE;
oh->mesg[idx].raw_size += delta;
@@ -2678,12 +2677,12 @@ H5O_alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size)
} /* end if */
}
- /* Reserve space in the file */
+ /* Reserve space in the file */
delta = MAX(H5O_MIN_SIZE, aligned_size+H5O_SIZEOF_MSGHDR(f));
delta = H5O_ALIGN(delta);
- if( H5MF_reserve(f, delta) < 0 )
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "unable to reserve space in file");
+ if( H5MF_reserve(f, (hsize_t)delta) < 0 )
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "unable to reserve space in file");
/* create a new null message */
if (oh->nmesgs >= oh->alloc_nmesgs) {
@@ -2824,7 +2823,7 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
assert (size == H5O_ALIGN (size));
/* Reserve space in the file to hold the new chunk */
- if( H5MF_reserve(f, size) < 0 )
+ if( H5MF_reserve(f, (hsize_t)size) < 0 )
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "unable to reserve space in file for new chunk");
/*
@@ -3128,7 +3127,7 @@ done:
*-------------------------------------------------------------------------
*/
size_t
-H5O_raw_size(hid_t type_id, H5F_t *f, const void *mesg)
+H5O_raw_size(unsigned type_id, H5F_t *f, const void *mesg)
{
const H5O_class_t *type; /* Actual H5O class type for the ID */
size_t ret_value; /* Return value */
@@ -3136,7 +3135,7 @@ H5O_raw_size(hid_t type_id, H5F_t *f, const void *mesg)
FUNC_ENTER_NOAPI(H5O_raw_size,0);
/* Check args */
- assert(type_id>=0 && type_id<(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])));
+ assert(type_id<NELMTS(message_type_g));
type=message_type_g[type_id]; /* map the type ID to the actual type object */
assert (type);
assert (type->raw_size);
@@ -3172,7 +3171,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_get_share(hid_t type_id, H5F_t *f, const void *mesg, H5O_shared_t *share)
+H5O_get_share(unsigned type_id, H5F_t *f, const void *mesg, H5O_shared_t *share)
{
const H5O_class_t *type; /* Actual H5O class type for the ID */
herr_t ret_value; /* Return value */
@@ -3180,7 +3179,7 @@ H5O_get_share(hid_t type_id, H5F_t *f, const void *mesg, H5O_shared_t *share)
FUNC_ENTER_NOAPI(H5O_get_share,FAIL);
/* Check args */
- assert(type_id>=0 && type_id<(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])));
+ assert(type_id<NELMTS(message_type_g));
type=message_type_g[type_id]; /* map the type ID to the actual type object */
assert (type);
assert (type->get_share);
@@ -3445,7 +3444,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_encode(unsigned char *buf, void *obj, size_t *nalloc, hid_t type_id)
+H5O_encode(unsigned char *buf, void *obj, size_t *nalloc, unsigned type_id)
{
const H5O_class_t *type; /* Actual H5O class type for the ID */
size_t size; /* size of the message*/
@@ -3454,26 +3453,22 @@ H5O_encode(unsigned char *buf, void *obj, size_t *nalloc, hid_t type_id)
FUNC_ENTER_NOAPI(H5O_encode,FAIL);
/* check args */
- if(type_id<0 || type_id>=(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])))
- HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object type");
-
- /* map the type ID to the actual type object */
- if((type=message_type_g[type_id])==NULL)
- HGOTO_ERROR (H5E_OHDR, H5E_BADTYPE, FAIL, "unable to find object type");
+ assert(type_id<NELMTS(message_type_g));
+ type=message_type_g[type_id]; /* map the type ID to the actual type object */
+ assert(type);
/* check buffer size */
- if ((size=(type->raw_size)(NULL, obj))<0)
+ if ((size=(type->raw_size)(NULL, obj))<=0)
HGOTO_ERROR (H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode message");
/* Don't encode if buffer size isn't big enough */
- if(!buf || *nalloc<size) {
+ if(!buf || *nalloc<size)
*nalloc = size;
- HGOTO_DONE(ret_value);
- }
-
- /* Encode */
- if ((type->encode)(NULL, buf, obj)<0)
- HGOTO_ERROR (H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode message");
+ else {
+ /* Encode */
+ if ((type->encode)(NULL, buf, obj)<0)
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode message");
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value);
@@ -3499,21 +3494,17 @@ done:
*-------------------------------------------------------------------------
*/
void*
-H5O_decode(unsigned char *buf, hid_t type_id)
+H5O_decode(unsigned char *buf, unsigned type_id)
{
const H5O_class_t *type; /* Actual H5O class type for the ID */
- size_t size; /* size of the message*/
- void *ret_value=NULL; /* Return value */
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_decode,NULL);
/* check args */
- if(type_id<0 || type_id>=(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])))
- HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, NULL, "invalid object type");
-
- /* map the type ID to the actual type object */
- if((type=message_type_g[type_id])==NULL)
- HGOTO_ERROR (H5E_OHDR, H5E_BADTYPE, NULL, "unable to find object type");
+ assert(type_id<NELMTS(message_type_g));
+ type=message_type_g[type_id]; /* map the type ID to the actual type object */
+ assert(type);
/* decode */
ret_value = (type->decode)(NULL, 0, buf, NULL);
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index ab52171..a18820a 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -228,16 +228,16 @@ H5_DLL herr_t H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint,
H5_DLL herr_t H5O_open(H5G_entry_t *ent);
H5_DLL herr_t H5O_close(H5G_entry_t *ent);
H5_DLL int H5O_link(const H5G_entry_t *ent, int adjust, hid_t dxpl_id);
-H5_DLL int H5O_count(H5G_entry_t *ent, hid_t type_id, hid_t dxpl_id);
-H5_DLL htri_t H5O_exists(H5G_entry_t *ent, hid_t type_id, int sequence,
+H5_DLL int H5O_count(H5G_entry_t *ent, unsigned type_id, hid_t dxpl_id);
+H5_DLL htri_t H5O_exists(H5G_entry_t *ent, unsigned type_id, int sequence,
hid_t dxpl_id);
-H5_DLL void *H5O_read(H5G_entry_t *ent, hid_t type_id, int sequence,
+H5_DLL void *H5O_read(H5G_entry_t *ent, unsigned type_id, int sequence,
void *mesg, hid_t dxpl_id);
-H5_DLL int H5O_modify(H5G_entry_t *ent, hid_t type_id,
+H5_DLL int H5O_modify(H5G_entry_t *ent, unsigned type_id,
int overwrite, unsigned flags, unsigned update_time, const void *mesg, hid_t dxpl_id);
H5_DLL struct H5O_t * H5O_protect(H5G_entry_t *ent, hid_t dxpl_id);
H5_DLL herr_t H5O_unprotect(H5G_entry_t *ent, struct H5O_t *oh, hid_t dxpl_id);
-H5_DLL int H5O_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, hid_t type_id,
+H5_DLL int H5O_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, unsigned type_id,
unsigned flags, const void *mesg);
H5_DLL herr_t H5O_touch(H5G_entry_t *ent, hbool_t force, hid_t dxpl_id);
H5_DLL herr_t H5O_touch_oh(H5F_t *f, struct H5O_t *oh, hbool_t force);
@@ -245,15 +245,15 @@ H5_DLL herr_t H5O_touch_oh(H5F_t *f, struct H5O_t *oh, hbool_t force);
H5_DLL herr_t H5O_bogus(H5G_entry_t *ent, hid_t dxpl_id);
H5_DLL herr_t H5O_bogus_oh(H5F_t *f, struct H5O_t *oh);
#endif /* H5O_ENABLE_BOGUS */
-H5_DLL herr_t H5O_remove(H5G_entry_t *ent, hid_t type_id, int sequence,
+H5_DLL herr_t H5O_remove(H5G_entry_t *ent, unsigned type_id, int sequence,
hid_t dxpl_id);
-H5_DLL herr_t H5O_reset(hid_t type_id, void *native);
-H5_DLL void *H5O_free(hid_t type_id, void *mesg);
-H5_DLL herr_t H5O_encode(unsigned char *buf, void *obj, size_t *nalloc, hid_t type_id);
-H5_DLL void* H5O_decode(unsigned char *buf, hid_t type_id);
-H5_DLL void *H5O_copy(hid_t type_id, const void *mesg, void *dst);
-H5_DLL size_t H5O_raw_size(hid_t type_id, H5F_t *f, const void *mesg);
-H5_DLL herr_t H5O_get_share(hid_t type_id, H5F_t *f, const void *mesg, H5O_shared_t *share);
+H5_DLL herr_t H5O_reset(unsigned type_id, void *native);
+H5_DLL void *H5O_free(unsigned type_id, void *mesg);
+H5_DLL herr_t H5O_encode(unsigned char *buf, void *obj, size_t *nalloc, unsigned type_id);
+H5_DLL void* H5O_decode(unsigned char *buf, unsigned type_id);
+H5_DLL void *H5O_copy(unsigned type_id, const void *mesg, void *dst);
+H5_DLL size_t H5O_raw_size(unsigned type_id, H5F_t *f, const void *mesg);
+H5_DLL herr_t H5O_get_share(unsigned type_id, H5F_t *f, const void *mesg, H5O_shared_t *share);
H5_DLL herr_t H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr);
H5_DLL herr_t H5O_get_info(H5G_entry_t *ent, H5O_stat_t *ostat, hid_t dxpl_id);
H5_DLL herr_t H5O_debug_id(hid_t type_id, H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth);
diff --git a/src/H5T.c b/src/H5T.c
index 26cc8c3..4d9b032 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -2573,15 +2573,18 @@ herr_t
H5Tencode(hid_t obj_id, unsigned char* buf, size_t* nalloc)
{
H5T_t *dtype;
- herr_t ret_value;
+ herr_t ret_value=SUCCEED;
FUNC_ENTER_API (H5Tencode, FAIL);
/* Check argument and retrieve object */
if (NULL==(dtype=H5I_object_verify(obj_id, H5I_DATATYPE)))
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if (nalloc==NULL)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "NULL pointer for buffer size")
- ret_value = H5T_encode(dtype, buf, nalloc);
+ if(H5T_encode(dtype, buf, nalloc)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype");
done:
FUNC_LEAVE_API(ret_value);
@@ -2615,7 +2618,7 @@ H5Tdecode(unsigned char* buf)
FUNC_ENTER_API (H5Tdecode, FAIL);
if (buf==NULL)
- HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "empty buffer")
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "NULL pointer for buffer")
if((dt = H5T_decode(buf))==NULL)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "can't decode object");
diff --git a/test/cache.c b/test/cache.c
index ac73fcd..dcc2395 100644
--- a/test/cache.c
+++ b/test/cache.c
@@ -1839,8 +1839,8 @@ rename_entry(H5C_t * cache_ptr,
{
herr_t result;
hbool_t done = TRUE; /* will set to FALSE if we have work to do */
- haddr_t old_addr;
- haddr_t new_addr;
+ haddr_t old_addr = HADDR_UNDEF;
+ haddr_t new_addr = HADDR_UNDEF;
test_entry_t * base_addr;
test_entry_t * entry_ptr;
diff --git a/test/dtransform.c b/test/dtransform.c
index 9d1665b..c12530a 100644
--- a/test/dtransform.c
+++ b/test/dtransform.c
@@ -6,7 +6,7 @@
int compare_int(int* a, int* b, int tol);
int compare_float(float* a, float* b, float tol);
-int main()
+int main(void)
{
hid_t file_id, dxpl_id_f_to_c, dxpl_id_c_to_f, dxpl_id_simple, dset_id_int, dset_id_float, datatype, dataspace;
hsize_t dim[2] = {ROWS, COLS};
diff --git a/test/dtypes.c b/test/dtypes.c
index dcc14bd..e0fc7be 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -1885,13 +1885,13 @@ test_encode(void)
double d;
};
hid_t file=-1, tid1=-1, tid2=-1;
- hid_t decoded_tid1, decoded_tid2;
+ hid_t decoded_tid1=-1, decoded_tid2=-1;
char filename[1024];
char compnd_type[]="Compound_type", enum_type[]="Enum_type";
short enum_val;
size_t cmpd_buf_size = 0;
size_t enum_buf_size = 0;
- unsigned char *cmpd_buf, *enum_buf;
+ unsigned char *cmpd_buf=NULL, *enum_buf=NULL;
TESTING("functions of encoding and decoding data types");
@@ -1990,6 +1990,13 @@ test_encode(void)
goto error;
} /* end if */
+ /* Verify that the datatype was copied exactly */
+ if(H5Tequal(decoded_tid1, tid1)<=0) {
+ H5_FAILED();
+ printf("Datatype wasn't encoded & decoded identically\n");
+ goto error;
+ } /* end if */
+
/* Query member number and member index by name, for compound type. */
if(H5Tget_nmembers(decoded_tid1)!=4) {
H5_FAILED();
@@ -2026,6 +2033,13 @@ test_encode(void)
goto error;
} /* end if */
+ /* Verify that the datatype was copied exactly */
+ if(H5Tequal(decoded_tid2, tid2)<=0) {
+ H5_FAILED();
+ printf("Datatype wasn't encoded & decoded identically\n");
+ goto error;
+ } /* end if */
+
/* Query member number and member index by name, for enumeration type. */
if(H5Tget_nmembers(decoded_tid2)!=5) {
H5_FAILED();
@@ -2116,6 +2130,13 @@ test_encode(void)
goto error;
} /* end if */
+ /* Verify that the datatype was copied exactly */
+ if(H5Tequal(decoded_tid1, tid1)<=0) {
+ H5_FAILED();
+ printf("Datatype wasn't encoded & decoded identically\n");
+ goto error;
+ } /* end if */
+
/* Query member number and member index by name, for compound type. */
if(H5Tget_nmembers(decoded_tid1)!=4) {
H5_FAILED();
@@ -2155,6 +2176,13 @@ test_encode(void)
goto error;
} /* end if */
+ /* Verify that the datatype was copied exactly */
+ if(H5Tequal(decoded_tid2, tid2)<=0) {
+ H5_FAILED();
+ printf("Datatype wasn't encoded & decoded identically\n");
+ goto error;
+ } /* end if */
+
/* Query member number and member index by name, for enumeration type. */
if(H5Tget_nmembers(decoded_tid2)!=5) {
H5_FAILED();
diff --git a/test/lheap.c b/test/lheap.c
index 5fe6c1f..e1694ba 100644
--- a/test/lheap.c
+++ b/test/lheap.c
@@ -29,6 +29,7 @@ const char *FILENAME[] = {
#define NOBJS 40
+
/*-------------------------------------------------------------------------
* Function: main
*
diff --git a/test/ohdr.c b/test/ohdr.c
index aa9259c..a893d08 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -39,6 +39,7 @@ const char *FILENAME[] = {
* the library and simply compile gen_bogus.c with that HDF5 library and run it. */
#define FILE_BOGUS "tbogus.h5"
+
/*-------------------------------------------------------------------------
* Function: main
*
diff --git a/test/reserved.c b/test/reserved.c
index 3fb5827..ff2315b 100755
--- a/test/reserved.c
+++ b/test/reserved.c
@@ -34,88 +34,90 @@
*
*-------------------------------------------------------------------------
*/
-herr_t rsrv_heap()
+static herr_t
+rsrv_heap(void)
{
- hid_t file_id, dataset_id, dataspace_id;
- hid_t pfc_id;
- hsize_t dims[1] = {1};
- herr_t ret_value = 0;
- char dset_name[10];
- int i;
+ hid_t file_id, dataset_id, dataspace_id;
+ hid_t pfc_id;
+ hsize_t dims[1] = {1};
+ herr_t ret_value = 0;
+ char dset_name[10];
+ int i;
TESTING("Reserving file space for heap");
- /* Create a new file. */
- pfc_id = H5Pcreate(H5P_FILE_CREATE);
- H5Pset_userblock(pfc_id, (int)0);
- H5Pset_sym_k(pfc_id, (int)1, (int)1);
- H5Pset_istore_k(pfc_id, (int)1);
- /* Set file address sizes to be very small. */
+ /* Create a new file. */
+ pfc_id = H5Pcreate(H5P_FILE_CREATE);
+ H5Pset_userblock(pfc_id, (hsize_t)0);
+ H5Pset_sym_k(pfc_id, 1, 1);
+ H5Pset_istore_k(pfc_id, 1);
+
+ /* Set file address sizes to be very small. */
H5Pset_sizes(pfc_id, (size_t)2,(size_t)2);
- file_id = H5Fcreate("rsrv_heap", H5F_ACC_TRUNC, pfc_id, H5P_DEFAULT);
+ file_id = H5Fcreate("rsrv_heap", H5F_ACC_TRUNC, pfc_id, H5P_DEFAULT);
- /* Write datasets until the file is full, at which point HDF5
- * should throw an error.
- */
- for (i = 0; i < 200; i++)
- {
- H5E_BEGIN_TRY {
- dataspace_id = H5Screate_simple(1, dims, dims);
- } H5E_END_TRY
+ /* Write datasets until the file is full, at which point HDF5
+ * should throw an error.
+ */
+ for (i = 0; i < 200; i++)
+ {
+ H5E_BEGIN_TRY {
+ dataspace_id = H5Screate_simple(1, dims, dims);
+ } H5E_END_TRY
- sprintf(dset_name, "Dset %d", i);
+ sprintf(dset_name, "Dset %d", i);
- H5E_BEGIN_TRY {
- dataset_id = H5Dcreate(file_id, dset_name, H5T_NATIVE_INT, dataspace_id, H5P_DEFAULT);
- } H5E_END_TRY
+ H5E_BEGIN_TRY {
+ dataset_id = H5Dcreate(file_id, dset_name, H5T_NATIVE_INT, dataspace_id, H5P_DEFAULT);
+ } H5E_END_TRY
- if(dataset_id < 0)
- break;
+ if(dataset_id < 0)
+ break;
- H5E_BEGIN_TRY {
- H5Dwrite(dataset_id, H5T_NATIVE_INT, dataspace_id, dataspace_id, H5P_DEFAULT, &i);
- } H5E_END_TRY
+ H5E_BEGIN_TRY {
+ H5Dwrite(dataset_id, H5T_NATIVE_INT, dataspace_id, dataspace_id, H5P_DEFAULT, &i);
+ } H5E_END_TRY
- H5Dclose(dataset_id);
- H5Sclose(dataspace_id);
- }
+ H5Dclose(dataset_id);
+ H5Sclose(dataspace_id);
+ }
- /* Close the file, property lists, and library */
+ /* Close the file, property lists, and library */
H5Fclose(file_id);
- H5Pclose (pfc_id);
- H5close();
+ H5Pclose(pfc_id);
+ H5close();
- /* The loop should have broken before completing--the file should not have had
- * enough address space to hold 200 datasets (or this test needs to be updated!).
- */
- if(i == 200)
+ /* The loop should have broken before completing--the file should not have had
+ * enough address space to hold 200 datasets (or this test needs to be updated!).
+ */
+ if(i == 200)
{
- ret_value = -1;
- H5_FAILED();
+ ret_value = 1;
+ H5_FAILED();
}
- /* Re-open the library and try to read a dataset from the file we created */
- H5open();
+ /* Re-open the library and try to read a dataset from the file we created */
+ H5open();
- sprintf(dset_name, "Dset %d", i - 2);
+ sprintf(dset_name, "Dset %d", i - 2);
- file_id = H5Fopen("rsrv_heap", H5F_ACC_RDONLY, H5P_DEFAULT);
+ file_id = H5Fopen("rsrv_heap", H5F_ACC_RDONLY, H5P_DEFAULT);
- dataset_id = H5Dopen(file_id, dset_name);
+ dataset_id = H5Dopen(file_id, dset_name);
- /* If we can read a dataset from the file, the file has been flushed to disk
- * (if the heap or object headers weren't flushed, the file would be empty).
- */
- if(dataset_id == H5I_BADID)
- {
- ret_value = -1;
- H5_FAILED();
- }
+ /* If we can read a dataset from the file, the file has been flushed to disk
+ * (if the heap or object headers weren't flushed, the file would be empty).
+ */
+ if(dataset_id == H5I_BADID)
+ {
+ ret_value = 1;
+ H5_FAILED();
+ }
- H5Dclose(dataset_id);
- H5Fclose(file_id);
- remove("rsrv_heap");
+ H5Dclose(dataset_id);
+ H5Fclose(file_id);
+ HDremove("rsrv_heap");
if(ret_value == 0)
{
@@ -145,35 +147,35 @@ herr_t rsrv_heap()
*
*-------------------------------------------------------------------------
*/
-herr_t rsrv_ohdr()
+static herr_t
+rsrv_ohdr(void)
{
- hid_t file_id, dataset_id, dataspace_id;
- hid_t pfc_id, aid, attr_id;
- hsize_t dims[2];
- herr_t status, ret_value = 0;
- int attrval[4][6];
- char *basenm = "attr";
- char attrname[20], nm_suf[10];
- int i;
+ hid_t file_id, dataset_id, dataspace_id;
+ hid_t pfc_id, aid, attr_id;
+ hsize_t dims[2];
+ herr_t status, ret_value = 0;
+ int attrval[4][6];
+ char attrname[20];
+ int i;
TESTING("Reserving file space for object headers");
- /* Create a new file using default properties. */
- pfc_id = H5Pcreate(H5P_FILE_CREATE);
- H5Pset_userblock(pfc_id, (int)0);
- H5Pset_sym_k(pfc_id, (int)1, (int)1);
- H5Pset_istore_k(pfc_id, (int)1);
- H5Pset_sizes(pfc_id, (size_t)2,(size_t)2);
+ /* Create a new file using default properties. */
+ pfc_id = H5Pcreate(H5P_FILE_CREATE);
+ H5Pset_userblock(pfc_id, (hsize_t)0);
+ H5Pset_sym_k(pfc_id, 1, 1);
+ H5Pset_istore_k(pfc_id, 1);
+ H5Pset_sizes(pfc_id, (size_t)2,(size_t)2);
- file_id = H5Fcreate("rsrv_ohdr", H5F_ACC_TRUNC, pfc_id, H5P_DEFAULT);
+ file_id = H5Fcreate("rsrv_ohdr", H5F_ACC_TRUNC, pfc_id, H5P_DEFAULT);
- /* Create the data space for the dataset. */
- dims[0] = 4;
- dims[1] = 6;
- dataspace_id = H5Screate_simple(2, dims, NULL);
+ /* Create the data space for the dataset. */
+ dims[0] = 4;
+ dims[1] = 6;
+ dataspace_id = H5Screate_simple(2, dims, NULL);
- /* Create the dataset. */
- dataset_id = H5Dcreate(file_id, "/dset", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT);
+ /* Create the dataset. */
+ dataset_id = H5Dcreate(file_id, "/dset", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT);
for(i=0; i<6; i++)
{
@@ -183,63 +185,61 @@ herr_t rsrv_ohdr()
attrval[3][i] = 3;
}
- for (i = 0; i< 2000; i++)
- {
- strcpy(attrname, basenm);
- sprintf(nm_suf, "%d", i);
- strcat(attrname, nm_suf);
- H5E_BEGIN_TRY{
- aid = H5Screate_simple(2, dims, NULL);
- attr_id = H5Acreate (dataset_id, attrname, H5T_STD_I32BE, aid, H5P_DEFAULT);
- status = H5Awrite(attr_id, H5T_NATIVE_INT, attrval);
- status = H5Aclose(attr_id);
- }H5E_END_TRY
+ for (i = 0; i< 2000; i++)
+ {
+ sprintf(attrname, "attr %d", i);
+ H5E_BEGIN_TRY{
+ aid = H5Screate_simple(2, dims, NULL);
+ attr_id = H5Acreate (dataset_id, attrname, H5T_STD_I32BE, aid, H5P_DEFAULT);
+ status = H5Awrite(attr_id, H5T_NATIVE_INT, attrval);
+ status = H5Aclose(attr_id);
+ } H5E_END_TRY
if(status < 0)
break;
- }
+ }
- /* End access to the dataset and dataspace and release resources. */
- H5Dclose(dataset_id);
- H5Pclose (pfc_id);
- H5Sclose(dataspace_id);
+ /* End access to the dataset and dataspace and release resources. */
+ H5Dclose(dataset_id);
+ H5Pclose (pfc_id);
+ H5Sclose(dataspace_id);
- /* Close the file and the library. */
- H5Fclose(file_id);
- H5close();
+ /* Close the file and the library. */
+ H5Fclose(file_id);
+ H5close();
- /* The loop should have broken before completing--the file should not have had
- * enough address space to hold 2000 attributes (or this test needs to be updated!).
- */
+ /* The loop should have broken before completing--the file should not have had
+ * enough address space to hold 2000 attributes (or this test needs to be updated!).
+ */
if(i == 2000)
{
- ret_value = -1;
+ ret_value = 1;
H5_FAILED();
}
- /* Re-open the library and try to read a dataset from the file we created */
- H5open();
+ /* Re-open the library and try to read a dataset from the file we created */
+ H5open();
- file_id = H5Fopen("rsrv_ohdr", H5F_ACC_RDONLY, H5P_DEFAULT);
+ file_id = H5Fopen("rsrv_ohdr", H5F_ACC_RDONLY, H5P_DEFAULT);
- dataset_id = H5Dopen(file_id, "/dset");
+ dataset_id = H5Dopen(file_id, "/dset");
- /* If we can read the dataset from the file, the file has been flushed to disk
- * (if the heap or object headers weren't flushed, the file would be empty).
- */
- if(dataset_id == H5I_BADID)
- {
- H5_FAILED();
- ret_value = -1;
- }
+ /* If we can read the dataset from the file, the file has been flushed to disk
+ * (if the heap or object headers weren't flushed, the file would be empty).
+ */
+ if(dataset_id == H5I_BADID)
+ {
+ ret_value = 1;
+ H5_FAILED();
+ }
if(ret_value == 0)
PASSED();
- H5Dclose(dataset_id);
- H5Fclose(file_id);
+ H5Dclose(dataset_id);
+ H5Fclose(file_id);
- remove("rsrv_ohdr");
+ HDremove("rsrv_ohdr");
return ret_value;
}
@@ -266,11 +266,14 @@ herr_t rsrv_ohdr()
*
*-------------------------------------------------------------------------
*/
-herr_t rsrv_vlen()
+static herr_t
+rsrv_vlen(void)
{
hid_t file_id, dataset_id, dataspace_id, type_id;
hid_t pfc_id, mem_space_id;
- hsize_t dims[1], start[1], count[1];
+ hssize_t offset[1];
+ hssize_t start[1];
+ hsize_t dims[1], count[1];
herr_t status, ret_value = 0;
int i;
int write_buf[20];
@@ -280,9 +283,9 @@ herr_t rsrv_vlen()
/* Create a new file using default properties. */
pfc_id = H5Pcreate(H5P_FILE_CREATE);
- H5Pset_userblock(pfc_id, (int)0);
- H5Pset_sym_k(pfc_id, (int)1, (int)1);
- H5Pset_istore_k(pfc_id, (int)1);
+ H5Pset_userblock(pfc_id, (hsize_t)0);
+ H5Pset_sym_k(pfc_id, 1, 1);
+ H5Pset_istore_k(pfc_id, 1);
H5Pset_sizes(pfc_id, (size_t)2,(size_t)2);
file_id = H5Fcreate("rsrv_vlen", H5F_ACC_TRUNC, pfc_id, H5P_DEFAULT);
@@ -315,11 +318,11 @@ herr_t rsrv_vlen()
{
vlen_data.len = (i%20) + 1;
- dims[0] = i;
- H5Soffset_simple(dataspace_id, dims);
+ offset[0] = i;
+ H5Soffset_simple(dataspace_id, offset);
H5E_BEGIN_TRY
- status = H5Dwrite(dataset_id, type_id, mem_space_id, dataspace_id, H5P_DEFAULT, &vlen_data);
+ status = H5Dwrite(dataset_id, type_id, mem_space_id, dataspace_id, H5P_DEFAULT, &vlen_data);
H5E_END_TRY
if(status < 0)
@@ -342,7 +345,7 @@ herr_t rsrv_vlen()
*/
if(i == 2000)
{
- ret_value = -1;
+ ret_value = 1;
H5_FAILED();
}
@@ -358,8 +361,8 @@ herr_t rsrv_vlen()
*/
if(dataset_id == H5I_BADID)
{
+ ret_value = 1;
H5_FAILED();
- ret_value = -1;
}
if(ret_value == 0)
@@ -368,7 +371,7 @@ herr_t rsrv_vlen()
H5Dclose(dataset_id);
H5Fclose(file_id);
- remove("rsrv_vlen");
+ HDremove("rsrv_vlen");
return ret_value;
}
@@ -392,10 +395,12 @@ herr_t rsrv_vlen()
int
main(void)
{
- rsrv_ohdr();
- rsrv_heap();
- rsrv_vlen();
+ int num_errs=0;
+
+ num_errs+=rsrv_ohdr();
+ num_errs+=rsrv_heap();
+ num_errs+=rsrv_vlen();
- return 0;
+ return num_errs;
}
diff --git a/test/tid.c b/test/tid.c
index 15438e8..1e6fe02 100644
--- a/test/tid.c
+++ b/test/tid.c
@@ -7,7 +7,7 @@
#include "H5Ipkg.h"
/* Test basic functionality of registering and deleting types and IDs */
-int id_test()
+static int id_test(void)
{
H5I_type_t myType = H5I_BADID;
hid_t arrayID = H5I_INVALID_HID;
@@ -183,16 +183,14 @@ out:
/* A dummy search function for the next test */
-int test_search_func(void * ptr1, void * ptr2);
-int test_search_func(void * ptr1, void * ptr2) { return 0; }
+static int test_search_func(void UNUSED * ptr1, void UNUSED * ptr2) { return 0; }
/* Ensure that public functions cannot access "predefined" ID types */
-int id_predefined_test()
+static int id_predefined_test(void )
{
void * testObj;
hid_t testID;
hid_t typeID = H5I_INVALID_HID;
- int testInt;
void * testPtr;
herr_t testErr;
@@ -289,7 +287,7 @@ out:
/* destroy it, this test will mysteriously fail (because it will expect there to */
/* be one more "free" type ID than there is). */
/* H5I_NTYPES is defined in h5public.h, MAX_NUM_TYPES is defined in h5pkg.h */
-int test_id_type_list()
+static int test_id_type_list(void)
{
H5I_type_t startType; /* The first type ID we were assigned in this test */
H5I_type_t currentType;
@@ -358,7 +356,7 @@ out:
return -1;
}
-void test_ids()
+void test_ids(void)
{
id_test();
id_predefined_test();
diff --git a/test/titerate.c b/test/titerate.c
index 652771a..b883ba3 100644
--- a/test/titerate.c
+++ b/test/titerate.c
@@ -756,7 +756,7 @@ static void test_grp_memb_funcs(void)
CHECK(ret, FAIL, "H5Fclose");
/* Sort the dataset names */
- qsort(dnames,NDATASETS+2,sizeof(char *),iter_strcmp);
+ HDqsort(dnames,NDATASETS+2,sizeof(char *),iter_strcmp);
/* Iterate through the datasets in the root group in various ways */
file=H5Fopen(DATAFILE, H5F_ACC_RDONLY, H5P_DEFAULT);
@@ -779,7 +779,7 @@ static void test_grp_memb_funcs(void)
name_len = H5Gget_objname_by_idx(root_group, (hsize_t)i, NULL, NAMELEN);
CHECK(name_len, FAIL, "H5Gget_objname_by_idx");
- ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, name_len+1);
+ ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, (size_t)(name_len+1));
CHECK(ret, FAIL, "H5Gget_objname_by_idx");
/* Double-check that the length is the same */
@@ -841,7 +841,7 @@ static void test_links(void)
ssize_t name_len; /* Length of object's name */
herr_t ret; /* Generic return value */
hid_t gid, gid1;
- int i;
+ hsize_t i;
H5G_obj_t obj_type; /* Type of object */
hsize_t nobjs; /* Number of objects */
@@ -873,10 +873,10 @@ static void test_links(void)
/* Test these two functions, H5Gget_num_objs and H5Gget_objname_by_idx */
for(i=0; i<nobjs; i++) {
/* Get object name */
- name_len = H5Gget_objname_by_idx(gid, (hsize_t)i, obj_name, NAMELEN);
+ name_len = H5Gget_objname_by_idx(gid, i, obj_name, NAMELEN);
CHECK(name_len, FAIL, "H5Gget_objname_by_idx");
- obj_type = H5Gget_objtype_by_idx(gid, (hsize_t)i);
+ obj_type = H5Gget_objtype_by_idx(gid, i);
CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx");
if(!HDstrcmp(obj_name, "g1.1"))
@@ -898,7 +898,7 @@ static void test_links(void)
ret=H5Fclose(file);
CHECK(ret, FAIL, "H5Fclose");
} /* test_links() */
-
+
/****************************************************************
**
** test_iterate(): Main iteration testing routine.
diff --git a/test/unlink.c b/test/unlink.c
index 9f8e5b2..59e0633 100644
--- a/test/unlink.c
+++ b/test/unlink.c
@@ -1816,7 +1816,7 @@ error:
static int
test_resurrect_dataset(void)
{
- hid_t f, s, d, fapl;
+ hid_t f=-1, s=-1, d=-1, fapl=-1;
char filename[1024];
TESTING("Resurrecting dataset after deletion");