diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-01-08 17:27:15 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-01-08 17:27:15 (GMT) |
commit | 634c7c5a93abb49a56336eec9e842a0bd694f828 (patch) | |
tree | d30f170a49ca3186bc8beddac7bf3523dfdb1ad3 /src | |
parent | 9b1f93283c32f81658cf40d0caeb5333c4db6ae9 (diff) | |
download | hdf5-634c7c5a93abb49a56336eec9e842a0bd694f828.zip hdf5-634c7c5a93abb49a56336eec9e842a0bd694f828.tar.gz hdf5-634c7c5a93abb49a56336eec9e842a0bd694f828.tar.bz2 |
[svn-r16279] Description:
Bring revision 16278 back from revise_chunks branch:
Update layout information in DCPL to unify all information in one
underlying property and switch to using H5O_layout_t for storing it, which
simplifies things considerably.
Also, fix many compiler warnings.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
(Original patch tested on many machines)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5B.c | 2 | ||||
-rw-r--r-- | src/H5Dchunk.c | 54 | ||||
-rw-r--r-- | src/H5Dcontig.c | 1 | ||||
-rw-r--r-- | src/H5Defl.c | 18 | ||||
-rw-r--r-- | src/H5Dfill.c | 9 | ||||
-rw-r--r-- | src/H5Dint.c | 46 | ||||
-rw-r--r-- | src/H5Dio.c | 6 | ||||
-rw-r--r-- | src/H5Dprivate.h | 2 | ||||
-rw-r--r-- | src/H5Dscatgath.c | 20 | ||||
-rw-r--r-- | src/H5Dselect.c | 14 | ||||
-rw-r--r-- | src/H5F.c | 4 | ||||
-rw-r--r-- | src/H5Fmount.c | 8 | ||||
-rw-r--r-- | src/H5Gname.c | 4 | ||||
-rw-r--r-- | src/H5Gtest.c | 4 | ||||
-rw-r--r-- | src/H5L.c | 8 | ||||
-rw-r--r-- | src/H5Ofill.c | 8 | ||||
-rw-r--r-- | src/H5Olayout.c | 10 | ||||
-rw-r--r-- | src/H5Oprivate.h | 16 | ||||
-rw-r--r-- | src/H5Pdcpl.c | 298 | ||||
-rw-r--r-- | src/H5Pfapl.c | 2 | ||||
-rw-r--r-- | src/H5Pgcpl.c | 12 | ||||
-rw-r--r-- | src/H5Pint.c | 4 | ||||
-rw-r--r-- | src/H5Plapl.c | 10 | ||||
-rw-r--r-- | src/H5Plcpl.c | 2 | ||||
-rwxr-xr-x | src/H5Pocpl.c | 12 | ||||
-rw-r--r-- | src/H5S.c | 169 | ||||
-rw-r--r-- | src/H5Shyper.c | 178 | ||||
-rw-r--r-- | src/H5Spoint.c | 52 | ||||
-rw-r--r-- | src/H5Sselect.c | 26 | ||||
-rw-r--r-- | src/H5Stest.c | 2 | ||||
-rw-r--r-- | src/H5Z.c | 75 |
31 files changed, 582 insertions, 494 deletions
@@ -1897,7 +1897,7 @@ done: if(NULL == ret_value) { if(new_node) { (void)H5FL_BLK_FREE(native_block, new_node->native); - H5FL_SEQ_FREE(haddr_t, new_node->child); + new_node->child = H5FL_SEQ_FREE(haddr_t, new_node->child); (void)H5FL_FREE(H5B_t, new_node); } /* end if */ } /* end if */ diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 82168a1..c56ff85 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -263,7 +263,6 @@ H5D_chunk_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, const H5T_t *type = dset->shared->type; /* Convenience pointer to dataset's datatype */ hsize_t max_dim[H5O_LAYOUT_NDIMS]; /* Maximum size of data in elements */ uint64_t chunk_size; /* Size of chunk in bytes */ - unsigned chunk_ndims = 0; /* Dimensionality of chunk */ int ndims; /* Rank of dataspace */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -275,40 +274,34 @@ H5D_chunk_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, HDassert(dset); HDassert(dc_plist); - /* Retrieve rank of chunks from property list */ - if(H5P_get(dc_plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve chunk dimensions") - /* Set up layout information */ if((ndims = H5S_GET_EXTENT_NDIMS(dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get rank") - dset->shared->layout.u.chunk.ndims = (unsigned)ndims + 1; - HDassert((unsigned)(dset->shared->layout.u.chunk.ndims) <= NELMTS(dset->shared->layout.u.chunk.dim)); + if(dset->shared->layout.u.chunk.ndims != (unsigned)ndims) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "dimensionality of chunks doesn't match the dataspace") - /* Initialize to no address */ - dset->shared->layout.u.chunk.addr = HADDR_UNDEF; + /* Increment # of chunk dimensions, to account for datatype size as last element */ + dset->shared->layout.u.chunk.ndims++; + HDassert((unsigned)(dset->shared->layout.u.chunk.ndims) <= NELMTS(dset->shared->layout.u.chunk.dim)); + HDassert(!H5F_addr_defined(dset->shared->layout.u.chunk.addr)); - /* - * Chunked storage allows any type of data space extension, so we - * don't even bother checking. - */ - if(chunk_ndims != (unsigned)ndims) - HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "dimensionality of chunks doesn't match the data space") + /* Chunked storage is not compatible with external storage (currently) */ if(dset->shared->dcpl_cache.efl.nused > 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "external storage not supported with chunked layout") - /* - * The chunk size of a dimension with a fixed size cannot exceed - * the maximum dimension size - */ - if(H5P_get(dc_plist, H5D_CRT_CHUNK_SIZE_NAME, dset->shared->layout.u.chunk.dim) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve chunk size") + /* Set the last dimension of the chunk size to the size of the datatype */ dset->shared->layout.u.chunk.dim[dset->shared->layout.u.chunk.ndims - 1] = H5T_GET_SIZE(type); - /* Sanity check dimensions */ + /* Get local copy of dataset dimensions (for sanity checking) */ if(H5S_get_simple_extent_dims(dset->shared->space, NULL, max_dim) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to query maximum dimensions") + + /* Sanity check dimensions */ for(u = 0; u < dset->shared->layout.u.chunk.ndims - 1; u++) + /* + * The chunk size of a dimension with a fixed size cannot exceed + * the maximum dimension size + */ if(max_dim[u] != H5S_UNLIMITED && max_dim[u] < dset->shared->layout.u.chunk.dim[u]) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "chunk size must be <= maximum dimension size for fixed-sized dimensions") @@ -973,19 +966,19 @@ H5D_create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t end[curr_dim]+=fm->chunk_dim[curr_dim]; /* Bring chunk location back into bounds, if necessary */ - if(coords[curr_dim]>sel_end[curr_dim]) { + if(coords[curr_dim] > sel_end[curr_dim]) { do { /* Reset current dimension's location to 0 */ - coords[curr_dim]=start_coords[curr_dim]; /*lint !e771 The start_coords will always be initialized */ - end[curr_dim]=(coords[curr_dim]+(hssize_t)fm->chunk_dim[curr_dim])-1; + coords[curr_dim] = start_coords[curr_dim]; /*lint !e771 The start_coords will always be initialized */ + end[curr_dim] = (coords[curr_dim] + fm->chunk_dim[curr_dim]) - 1; /* Decrement current dimension */ curr_dim--; /* Increment chunk location in current dimension */ - coords[curr_dim]+=fm->chunk_dim[curr_dim]; - end[curr_dim]=(coords[curr_dim]+fm->chunk_dim[curr_dim])-1; - } while(coords[curr_dim]>sel_end[curr_dim]); + coords[curr_dim] += fm->chunk_dim[curr_dim]; + end[curr_dim] = (coords[curr_dim] + fm->chunk_dim[curr_dim]) - 1; + } while(coords[curr_dim] > sel_end[curr_dim]); /* Re-Calculate the index of this chunk */ if(H5V_chunk_index(fm->f_ndims, coords, fm->layout->u.chunk.dim, fm->down_chunks, &chunk_index) < 0) @@ -3007,7 +3000,6 @@ H5D_chunk_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite) /* Chunk wasn't in cache either, create it now */ if(!chunk_exists) { - H5D_chunk_ud_t udata; /* B-tree pass-through for creating chunk */ size_t chunk_size; /* Size of chunk in bytes, possibly filtered */ /* Check for VL datatype & non-default fill value */ @@ -3507,7 +3499,7 @@ H5D_chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dims) if(H5V_array_down(rank, chunks, down_chunks) < 0) HGOTO_ERROR(H5E_IO, H5E_BADVALUE, FAIL, "can't compute 'down' sizes") - /* Create a data space for a chunk & set the extent */ + /* Create a dataspace for a chunk & set the extent */ if(NULL == (chunk_space = H5S_create_simple(rank, chunk_dims, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") @@ -4360,7 +4352,7 @@ H5D_chunk_dest(H5F_t *f, hid_t dxpl_id, H5D_t *dset) /* Release cache structures */ if(rdcc->slot) - H5FL_SEQ_FREE(H5D_rdcc_ent_ptr_t, rdcc->slot); + rdcc->slot = H5FL_SEQ_FREE(H5D_rdcc_ent_ptr_t, rdcc->slot); HDmemset(rdcc, 0, sizeof(H5D_rdcc_t)); /* Compose chunked index info struct */ diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 6aafbcf..4b7a5df 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -392,7 +392,6 @@ H5D_contig_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset * Also, only the slowest varying dimension of a simple data space * can be extendible (currently only for external data storage). */ - dset->shared->layout.u.contig.addr = HADDR_UNDEF; /* Initialize to no address */ /* Check for invalid dataset dimensions */ if((ndims = H5S_get_simple_extent_dims(dset->shared->space, dim, max_dim)) < 0) diff --git a/src/H5Defl.c b/src/H5Defl.c index 2dcad4d..880edfd 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -132,7 +132,6 @@ H5D_efl_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, * Also, only the slowest varying dimension of a simple data space * can be extendible (currently only for external data storage). */ - dset->shared->layout.u.contig.addr = HADDR_UNDEF; /* Initialize to no address */ /* Check for invalid dataset dimensions */ if((ndims = H5S_get_simple_extent_dims(dset->shared->space, dim, max_dim)) < 0) @@ -150,12 +149,12 @@ H5D_efl_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, max_storage = H5O_efl_total_size(&dset->shared->dcpl_cache.efl); if(H5S_UNLIMITED == max_points) { if(H5O_EFL_UNLIMITED != max_storage) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unlimited data space but finite storage") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unlimited dataspace but finite storage") } /* end if */ else if((max_points * dt_size) < max_points) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data space * type size overflowed") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "dataspace * type size overflowed") else if((max_points * dt_size) > max_storage) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data space size exceeds external storage size") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "dataspace size exceeds external storage size") /* Compute the total size of dataset */ tmp_size = H5S_GET_EXTENT_NPOINTS(dset->shared->space) * dt_size; @@ -261,12 +260,11 @@ H5D_efl_read(const H5O_efl_t *efl, haddr_t addr, size_t size, uint8_t *buf) #else /* NDEBUG */ to_read = MIN((size_t)(efl->slot[u].size-skip), size); #endif /* NDEBUG */ - if ((n=HDread (fd, buf, to_read))<0) { - HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "read error in external raw data file") - } else if ((size_t)n<to_read) { - HDmemset (buf+n, 0, to_read-n); - } - HDclose (fd); + if((n = HDread(fd, buf, to_read)) < 0) + HGOTO_ERROR(H5E_EFL, H5E_READERROR, FAIL, "read error in external raw data file") + else if((size_t)n < to_read) + HDmemset(buf + n, 0, to_read - (size_t)n); + HDclose(fd); fd = -1; size -= to_read; buf += to_read; diff --git a/src/H5Dfill.c b/src/H5Dfill.c index e8990b9..bacaca2 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -394,8 +394,12 @@ H5D_fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, /* Fill the buffer with the user's fill value */ if(fill->buf) { + htri_t has_vlen_type; /* Whether the datatype has a VL component */ + /* Detect whether the datatype has a VL component */ - fb_info->has_vlen_fill_type = H5T_detect_class(dset_type, H5T_VLEN); + if((has_vlen_type = H5T_detect_class(dset_type, H5T_VLEN)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to detect vlen datatypes?") + fb_info->has_vlen_fill_type = (hbool_t)has_vlen_type; /* If necessary, convert fill value datatypes (which copies VL components, etc.) */ if(fb_info->has_vlen_fill_type) { @@ -466,7 +470,8 @@ H5D_fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, } /* end if */ else { /* If fill value is not library default, use it to set the element size */ - fb_info->max_elmt_size = fb_info->file_elmt_size = fb_info->mem_elmt_size = fill->size; + HDassert(fill->size >= 0); + fb_info->max_elmt_size = fb_info->file_elmt_size = fb_info->mem_elmt_size = (size_t)fill->size; /* Compute the number of elements that fit within a buffer to write */ if(total_nelmts > 0) diff --git a/src/H5Dint.c b/src/H5Dint.c index 221d448..37a4701 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -171,8 +171,8 @@ H5D_init_interface(void) if(NULL == (def_dcpl = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_CREATE_g))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get default dataset creation property list") - /* Get the default data storage method */ - if(H5P_get(def_dcpl, H5D_CRT_LAYOUT_NAME, &H5D_def_dset.layout.type) < 0) + /* Get the default data storage layout */ + if(H5P_get(def_dcpl, H5D_CRT_LAYOUT_NAME, &H5D_def_dset.layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") /* Get the default dataset creation properties */ @@ -1063,7 +1063,7 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, /* Check if the dataset has a non-default DCPL & get important values, if so */ if(new_dset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) { - H5D_layout_t *layout; /* Dataset's layout information */ + H5O_layout_t *layout; /* Dataset's layout information */ H5O_pline_t *pline; /* Dataset's I/O pipeline information */ H5O_fill_t *fill; /* Dataset's fill value info */ @@ -1083,10 +1083,10 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, pline = &new_dset->shared->dcpl_cache.pline; if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve pipeline filter") - layout = &new_dset->shared->layout.type; + layout = &new_dset->shared->layout; if(H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve layout") - if(pline->nused > 0 && H5D_CHUNKED != *layout) + if(pline->nused > 0 && H5D_CHUNKED != layout->type) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "filters can only be used with chunked layout") fill = &new_dset->shared->dcpl_cache.fill; if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, fill) < 0) @@ -1097,7 +1097,7 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "invalid space allocation state") /* Don't allow compact datasets to allocate space later */ - if(*layout == H5D_COMPACT && fill->alloc_time != H5D_ALLOC_TIME_EARLY) + if(layout->type == H5D_COMPACT && fill->alloc_time != H5D_ALLOC_TIME_EARLY) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "compact dataset must have early space allocation") /* If MPI VFD is used, no filter support yet. */ @@ -1352,8 +1352,14 @@ H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) */ if(NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout), dxpl_id)) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data layout message") - if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->shared->layout.type) < 0) + /* Adjust chunk dimensions to omit datatype size (in last dimension) for creation property */ + if(H5D_CHUNKED == dataset->shared->layout.type) + dataset->shared->layout.u.chunk.ndims--; + if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->shared->layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout") + /* Adjust chunk dimensions back again (*sigh*) */ + if(H5D_CHUNKED == dataset->shared->layout.type) + dataset->shared->layout.u.chunk.ndims++; /* Get the external file list message, which might not exist. Space is * also undefined when space allocate time is H5D_ALLOC_TIME_LATE. */ @@ -1396,25 +1402,9 @@ H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) break; case H5D_CHUNKED: - /* - * Chunked storage. The creation plist's dimension is one less than - * the chunk dimension because the chunk includes a dimension for the - * individual bytes of the datatype. - */ - { - unsigned chunk_ndims; /* Dimensionality of chunk */ - - chunk_ndims = dataset->shared->layout.u.chunk.ndims - 1; - - if(H5P_set(plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk dimensions") - if(H5P_set(plist, H5D_CRT_CHUNK_SIZE_NAME, dataset->shared->layout.u.chunk.dim) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk size") - - /* Initialize the chunk cache for the dataset */ - if(H5D_chunk_init(dataset->oloc.file, dapl_id, dxpl_id, dataset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize chunk cache") - } + /* Initialize the chunk cache for the dataset */ + if(H5D_chunk_init(dataset->oloc.file, dapl_id, dxpl_id, dataset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize chunk cache") break; case H5D_COMPACT: @@ -1464,7 +1454,7 @@ H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) /* If "old" fill value size is 0 (undefined), map it to -1 */ if(fill_prop->size == 0) - fill_prop->size = (size_t)-1; + fill_prop->size = (ssize_t)-1; } /* end if */ alloc_time_state = 0; if((dataset->shared->layout.type == H5D_COMPACT && fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY) @@ -1605,7 +1595,7 @@ H5D_close(H5D_t *dataset) * Release datatype, dataspace and creation property list -- there isn't * much we can do if one of these fails, so we just continue. */ - free_failed = (H5I_dec_ref(dataset->shared->type_id, FALSE) < 0 || H5S_close(dataset->shared->space) < 0 || + free_failed = (unsigned)(H5I_dec_ref(dataset->shared->type_id, FALSE) < 0 || H5S_close(dataset->shared->space) < 0 || H5I_dec_ref(dataset->shared->dcpl_id, FALSE) < 0); /* Remove the dataset from the list of opened objects in the file */ diff --git a/src/H5Dio.c b/src/H5Dio.c index b7c1d72..9308c33 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -550,7 +550,7 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, if(H5T_detect_class(dataset->shared->type, H5T_VLEN)) full_overwrite = FALSE; else - full_overwrite = (hsize_t)file_nelmts == nelmts ? TRUE : FALSE; + full_overwrite = (hbool_t)((hsize_t)file_nelmts == nelmts ? TRUE : FALSE); /* Allocate storage */ if(H5D_alloc_storage(dataset, dxpl_id, H5D_ALLOC_WRITE, full_overwrite) < 0) @@ -780,8 +780,8 @@ H5D_typeinfo_init(const H5D_t *dset, const H5D_dxpl_cache_t *dxpl_cache, hbool_t default_buffer_info; /* Whether the buffer information are the defaults */ /* Detect if we have all default settings for buffers */ - default_buffer_info = (H5D_TEMP_BUF_SIZE == dxpl_cache->max_temp_buf) - && (NULL == dxpl_cache->tconv_buf) && (NULL == dxpl_cache->bkgr_buf); + default_buffer_info = (hbool_t)((H5D_TEMP_BUF_SIZE == dxpl_cache->max_temp_buf) + && (NULL == dxpl_cache->tconv_buf) && (NULL == dxpl_cache->bkgr_buf)); /* Check if we are using the default buffer info */ if(default_buffer_info) diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 96a35cc..7f044e5 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -43,8 +43,6 @@ /* ======== Dataset creation property names ======== */ #define H5D_CRT_LAYOUT_NAME "layout" /* Storage layout */ -#define H5D_CRT_CHUNK_DIM_NAME "chunk_ndims" /* Chunk dimensionality */ -#define H5D_CRT_CHUNK_SIZE_NAME "chunk_size" /* Chunk size */ #define H5D_CRT_FILL_VALUE_NAME "fill_value" /* Fill value */ #define H5D_CRT_ALLOC_TIME_STATE_NAME "alloc_time_state" /* Space allocation time state */ #define H5D_CRT_EXT_FILE_LIST_NAME "efl" /* External file list */ diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c index 867303f..bb9f46b 100644 --- a/src/H5Dscatgath.c +++ b/src/H5Dscatgath.c @@ -160,9 +160,9 @@ H5D_scatter_file(const H5D_io_info_t *_io_info, done: /* Release resources, if allocated */ if(len && len != _len) - H5FL_SEQ_FREE(size_t, len); + len = H5FL_SEQ_FREE(size_t, len); if(off && off != _off) - H5FL_SEQ_FREE(hsize_t, off); + off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* H5D_scatter_file() */ @@ -261,9 +261,9 @@ H5D_gather_file(const H5D_io_info_t *_io_info, done: /* Release resources, if allocated */ if(len && len != _len) - H5FL_SEQ_FREE(size_t, len); + len = H5FL_SEQ_FREE(size_t, len); if(off && off != _off) - H5FL_SEQ_FREE(hsize_t, off); + off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* H5D_gather_file() */ @@ -346,9 +346,9 @@ H5D_scatter_mem (const void *_tscat_buf, const H5S_t *space, done: /* Release resources, if allocated */ if(len && len != _len) - H5FL_SEQ_FREE(size_t, len); + len = H5FL_SEQ_FREE(size_t, len); if(off && off != _off) - H5FL_SEQ_FREE(hsize_t, off); + off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* H5D_scatter_mem() */ @@ -433,9 +433,9 @@ H5D_gather_mem(const void *_buf, const H5S_t *space, done: /* Release resources, if allocated */ if(len && len != _len) - H5FL_SEQ_FREE(size_t, len); + len = H5FL_SEQ_FREE(size_t, len); if(off && off != _off) - H5FL_SEQ_FREE(hsize_t, off); + off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* H5D_gather_mem() */ @@ -826,9 +826,9 @@ H5D_compound_opt_read(size_t nelmts, const H5S_t *space, done: /* Release resources, if allocated */ if(len && len != _len) - H5FL_SEQ_FREE(size_t, len); + len = H5FL_SEQ_FREE(size_t, len); if(off && off != _off) - H5FL_SEQ_FREE(hsize_t, off); + off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_compound_opt_read() */ diff --git a/src/H5Dselect.c b/src/H5Dselect.c index 947c81e..6dade5c 100644 --- a/src/H5Dselect.c +++ b/src/H5Dselect.c @@ -160,7 +160,7 @@ H5D_select_io(const H5D_io_info_t *io_info, size_t elmt_size, } /* end else */ /* Decrement number of elements left to process */ - HDassert((tmp_file_len % elmt_size) == 0); + HDassert(((size_t)tmp_file_len % elmt_size) == 0); } /* end if */ else { size_t mem_nelem; /* Number of elements used in memory sequences */ @@ -218,8 +218,8 @@ H5D_select_io(const H5D_io_info_t *io_info, size_t elmt_size, } /* end else */ /* Decrement number of elements left to process */ - HDassert((tmp_file_len % elmt_size) == 0); - nelmts -= (tmp_file_len / elmt_size); + HDassert(((size_t)tmp_file_len % elmt_size) == 0); + nelmts -= ((size_t)tmp_file_len / elmt_size); } /* end while */ } /* end else */ @@ -236,13 +236,13 @@ done: /* Release vector arrays, if allocated */ if(file_len && file_len != _file_len) - H5FL_SEQ_FREE(size_t, file_len); + file_len = H5FL_SEQ_FREE(size_t, file_len); if(file_off && file_off != _file_off) - H5FL_SEQ_FREE(hsize_t, file_off); + file_off = H5FL_SEQ_FREE(hsize_t, file_off); if(mem_len && mem_len != _mem_len) - H5FL_SEQ_FREE(size_t, mem_len); + mem_len = H5FL_SEQ_FREE(size_t, mem_len); if(mem_off && mem_off != _mem_off) - H5FL_SEQ_FREE(hsize_t, mem_off); + mem_off = H5FL_SEQ_FREE(hsize_t, mem_off); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_select_io() */ @@ -394,7 +394,7 @@ H5Fget_obj_count(hid_t file_id, unsigned types) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type") /* H5F_get_obj_count doesn't fail */ - ret_value = H5F_get_obj_count(f, types, TRUE); + ret_value = (ssize_t)H5F_get_obj_count(f, types, TRUE); done: FUNC_LEAVE_API(ret_value) @@ -468,7 +468,7 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) HDassert(oid_list); /* H5F_get_objects doesn't fail */ - ret_value = H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE); + ret_value = (ssize_t)H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Fmount.c b/src/H5Fmount.c index a428cd6..ff4b1eb 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -339,7 +339,7 @@ H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id) for(u = 0; u < parent->shared->mtab.nmounts; u++) { if(parent->shared->mtab.child[u].file->shared == child->shared) { /* Found the correct index */ - child_idx = u; + child_idx = (int)u; break; } /* end if */ } /* end for */ @@ -368,7 +368,7 @@ H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point") /* Found the correct index, set the info about the child */ - child_idx = md; + child_idx = (int)md; H5G_loc_free(&mp_loc); mp_loc_setup = FALSE; mp_loc.oloc = mnt_oloc; @@ -397,8 +397,8 @@ H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name") /* Eliminate the mount point from the table */ - HDmemmove(parent->shared->mtab.child + child_idx, parent->shared->mtab.child + child_idx + 1, - (parent->shared->mtab.nmounts - child_idx - 1) * sizeof(parent->shared->mtab.child[0])); + HDmemmove(parent->shared->mtab.child + (unsigned)child_idx, (parent->shared->mtab.child + (unsigned)child_idx) + 1, + ((parent->shared->mtab.nmounts - (unsigned)child_idx) - 1) * sizeof(parent->shared->mtab.child[0])); parent->shared->mtab.nmounts -= 1; parent->nmounts -= 1; diff --git a/src/H5Gname.c b/src/H5Gname.c index 0634aef..205f2a2 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -1147,10 +1147,8 @@ H5G_get_name_by_addr(hid_t file, hid_t lapl_id, hid_t dxpl_id, const H5O_loc_t * /* Check for finding the object */ if(found_obj) { - size_t full_path_len = HDstrlen(udata.path) + 1; /* Length of path + 1 (for "/") */ - /* Set the length of the full path */ - ret_value = full_path_len; + ret_value = (ssize_t)(HDstrlen(udata.path) + 1); /* Length of path + 1 (for "/") */ /* If there's a buffer provided, copy into it, up to the limit of its size */ if(name) { diff --git a/src/H5Gtest.c b/src/H5Gtest.c index d7f102f..1f09048 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -529,14 +529,14 @@ H5G_user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsigne /* Retrieve a copy of the user path and put it into the buffer */ if(obj_path->user_path_r) { - size_t len = H5RS_len(obj_path->user_path_r); + ssize_t len = H5RS_len(obj_path->user_path_r); /* Set the user path, if given */ if(user_path) HDstrcpy(user_path, H5RS_get_str(obj_path->user_path_r)); /* Set the length of the path */ - *user_path_len = len; + *user_path_len = (size_t)len; /* Set the user path hidden flag */ *obj_hidden = obj_path->obj_hidden; @@ -2700,7 +2700,7 @@ H5L_exists_cb(H5G_loc_t UNUSED *grp_loc/*in*/, const char UNUSED *name, FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5L_exists_cb) /* Check if the name in this group resolved to a valid link */ - *udata = (lnk != NULL); + *udata = (hbool_t)(lnk != NULL); /* Indicate that this callback didn't take ownership of the group * * location for the object */ @@ -2725,8 +2725,8 @@ H5L_exists_cb(H5G_loc_t UNUSED *grp_loc/*in*/, const char UNUSED *name, static htri_t H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) { - hbool_t exists = FALSE; /* Whether the link exists in the group */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t exists = FALSE; /* Whether the link exists in the group */ + htri_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5L_exists) @@ -2735,7 +2735,7 @@ H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "path doesn't exist") /* Set return value */ - ret_value = exists; + ret_value = (htri_t)exists; done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Ofill.c b/src/H5Ofill.c index 43ec1a4..02706ec 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -378,7 +378,7 @@ H5O_fill_new_encode(H5F_t UNUSED *f, uint8_t *p, const void *_fill) *p++ = fill->fill_time; /* Whether fill value is defined */ - *p++ = fill->fill_defined; + *p++ = (uint8_t)fill->fill_defined; /* Only write out the size and fill value if it is defined */ if(fill->fill_defined) { @@ -624,14 +624,14 @@ H5O_fill_new_size(const H5F_t UNUSED *f, const void *_fill) 1; /* Fill value defined */ if(fill->fill_defined) ret_value += 4 + /* Fill value size */ - (fill->size > 0 ? fill->size : 0); /* Size of fill value */ + (fill->size > 0 ? (size_t)fill->size : 0); /* Size of fill value */ } /* end if */ else { ret_value = 1 + /* Version number */ 1; /* Status flags */ if(fill->size > 0) ret_value += 4 + /* Fill value size */ - fill->size; /* Size of fill value */ + (size_t)fill->size; /* Size of fill value */ } /* end else */ FUNC_LEAVE_NOAPI(ret_value) @@ -662,7 +662,7 @@ H5O_fill_old_size(const H5F_t UNUSED *f, const void *_fill) HDassert(fill); - FUNC_LEAVE_NOAPI(4 + fill->size) + FUNC_LEAVE_NOAPI(4 + (size_t)fill->size) } /* end H5O_fill_old_size() */ diff --git a/src/H5Olayout.c b/src/H5Olayout.c index f2b6b30..59cd7db 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -72,12 +72,6 @@ const H5O_msg_class_t H5O_MSG_LAYOUT[1] = {{ H5O_layout_debug /*debug the message */ }}; -/* For forward and backward compatibility. Version is 1 when space is - * allocated; 2 when space is delayed for allocation; 3 is default now and - * is revised to just store information needed for each storage type. */ -#define H5O_LAYOUT_VERSION_1 1 -#define H5O_LAYOUT_VERSION_2 2 -#define H5O_LAYOUT_VERSION_3 3 /* Declare a free list to manage the H5O_layout_t struct */ H5FL_DEFINE(H5O_layout_t); @@ -334,7 +328,7 @@ H5O_layout_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const voi case H5D_CHUNKED: /* Number of dimensions */ HDassert(mesg->u.chunk.ndims > 0 && mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); - *p++ = mesg->u.chunk.ndims; + *p++ = (uint8_t)mesg->u.chunk.ndims; /* B-tree address */ H5F_addr_encode(f, &p, mesg->u.chunk.addr); @@ -386,7 +380,7 @@ H5O_layout_copy(const void *_mesg, void *_dest) *dest = *mesg; /* Deep copy the buffer for compact datasets also */ - if(mesg->type == H5D_COMPACT) { + if(mesg->type == H5D_COMPACT && mesg->u.compact.size > 0) { /* Allocate memory for the raw data */ if(NULL == (dest->u.compact.buf = H5MM_malloc(dest->u.compact.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset") diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index f65b15d..39dfb5c 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -322,10 +322,24 @@ typedef struct H5O_efl_t { /* * Data Layout Message. - * (Data structure in memory) + * (Data structure in file) */ #define H5O_LAYOUT_NDIMS (H5S_MAX_RANK+1) +/* Initial version of the layout information. Used when space is allocated */ +#define H5O_LAYOUT_VERSION_1 1 + +/* This version added support for delaying allocation */ +#define H5O_LAYOUT_VERSION_2 2 + +/* This version is revised to store just the information needed for each + * storage type, and to straighten out problems with contiguous layout's + * sizes (was encoding them as 4-byte values when they were really n-byte + * values (where n usually is 8)). + */ +#define H5O_LAYOUT_VERSION_3 3 + + /* Forward declaration of structs used below */ struct H5D_layout_ops_t; /* Defined in H5Dpkg.h */ struct H5D_chunk_ops_t; /* Defined in H5Dpkg.h */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index c523544..3f6704b 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -47,17 +47,16 @@ /* Local Macros */ /****************/ +/* Define default layout information */ +#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_3, NULL, { .compact = {(hbool_t)FALSE, (size_t)0, NULL}}} +#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_3, NULL, { .contig = {HADDR_UNDEF, (hsize_t)0}}} +#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_3, NULL, { .chunk = {HADDR_UNDEF, (unsigned)1, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, (uint32_t)0, NULL, NULL}}} + /* ======== Dataset creation properties ======== */ /* Definitions for storage layout property */ -#define H5D_CRT_LAYOUT_SIZE sizeof(H5D_layout_t) -#define H5D_CRT_LAYOUT_DEF H5D_CONTIGUOUS -/* Definitions for chunk dimensionality property */ -#define H5D_CRT_CHUNK_DIM_SIZE sizeof(unsigned) -#define H5D_CRT_CHUNK_DIM_DEF 1 -/* Definitions for chunk size */ -#define H5D_CRT_CHUNK_SIZE_SIZE sizeof(uint32_t[H5O_LAYOUT_NDIMS]) -#define H5D_CRT_CHUNK_SIZE_DEF {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,\ - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} +#define H5D_CRT_LAYOUT_SIZE sizeof(H5O_layout_t) +#define H5D_CRT_LAYOUT_DEF H5D_DEF_LAYOUT_CONTIG +#define H5D_CRT_LAYOUT_CMP H5P_dcrt_layout_cmp /* Definitions for fill value. size=0 means fill value will be 0 as * library default; size=-1 means fill value is undefined. */ #define H5D_CRT_FILL_VALUE_SIZE sizeof(H5O_fill_t) @@ -91,7 +90,7 @@ /********************/ /* General routines */ -static herr_t H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout); +static herr_t H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout); /* Property class callbacks */ static herr_t H5P_dcrt_reg_prop(H5P_genclass_t *pclass); @@ -99,6 +98,7 @@ static herr_t H5P_dcrt_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_dat static herr_t H5P_dcrt_close(hid_t dxpl_id, void *close_data); /* Property callbacks */ +static int H5P_dcrt_layout_cmp(const void *value1, const void *value2, size_t size); static int H5P_dcrt_ext_file_list_cmp(const void *value1, const void *value2, size_t size); static int H5P_dcrt_data_pipeline_cmp(const void *value1, const void *value2, size_t size); @@ -130,6 +130,11 @@ const H5P_libclass_t H5P_CLS_DCRT[1] = {{ /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); +/* Defaults for each type of layout */ +static const H5O_layout_t H5D_def_layout_compact_g = H5D_DEF_LAYOUT_COMPACT; +static const H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG; +static const H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK; + /*------------------------------------------------------------------------- @@ -146,9 +151,7 @@ H5FL_BLK_EXTERN(type_conv); static herr_t H5P_dcrt_reg_prop(H5P_genclass_t *pclass) { - H5D_layout_t layout = H5D_CRT_LAYOUT_DEF; /* Default storage layout */ - unsigned chunk_ndims = H5D_CRT_CHUNK_DIM_DEF; /* Default rank for chunks */ - uint32_t chunk_size[H5O_LAYOUT_NDIMS] = H5D_CRT_CHUNK_SIZE_DEF; /* Default chunk size */ + H5O_layout_t layout = H5D_CRT_LAYOUT_DEF; /* Default storage layout */ H5O_fill_t fill = H5D_CRT_FILL_VALUE_DEF; /* Default fill value */ unsigned alloc_time_state = H5D_CRT_ALLOC_TIME_STATE_DEF; /* Default allocation time state */ H5O_efl_t efl = H5D_CRT_EXT_FILE_LIST_DEF; /* Default external file list */ @@ -158,15 +161,7 @@ H5P_dcrt_reg_prop(H5P_genclass_t *pclass) FUNC_ENTER_NOAPI_NOINIT(H5P_dcrt_reg_prop) /* Register the storage layout property */ - if(H5P_register(pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &layout, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the chunking dimensionality property */ - if(H5P_register(pclass, H5D_CRT_CHUNK_DIM_NAME, H5D_CRT_CHUNK_DIM_SIZE, &chunk_ndims, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the chunking size property */ - if(H5P_register(pclass, H5D_CRT_CHUNK_SIZE_NAME, H5D_CRT_CHUNK_SIZE_SIZE, chunk_size, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if(H5P_register(pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &layout, NULL, NULL, NULL, NULL, NULL, H5D_CRT_LAYOUT_CMP, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the fill value property */ @@ -215,6 +210,7 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) H5O_fill_t src_fill, dst_fill; /* Source & destination fill values */ H5O_efl_t src_efl, dst_efl; /* Source & destination external file lists */ H5O_pline_t src_pline, dst_pline; /* Source & destination I/O pipelines */ + H5O_layout_t src_layout, dst_layout; /* Source & destination layout */ H5P_genplist_t *src_plist; /* Pointer to source property list */ H5P_genplist_t *dst_plist; /* Pointer to destination property list */ herr_t ret_value = SUCCEED; /* Return value */ @@ -227,8 +223,11 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) if(NULL == (src_plist = (H5P_genplist_t *)H5I_object(src_plist_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") - /* Get the fill value, external file list, and data pipeline properties - * from the old property list */ + /* Get the layout, fill value, external file list, and data pipeline + * properties from the old property list + */ + if(H5P_get(src_plist, H5D_CRT_LAYOUT_NAME, &src_layout) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout") if(H5P_get(src_plist, H5D_CRT_FILL_VALUE_NAME, &src_fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") if(H5P_get(src_plist, H5D_CRT_EXT_FILE_LIST_NAME, &src_efl) < 0) @@ -236,32 +235,61 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) if(H5P_get(src_plist, H5D_CRT_DATA_PIPELINE_NAME, &src_pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - /* Make copies of fill value, external file list, and data pipeline */ + /* Make copy of layout */ + if(NULL == H5O_msg_copy(H5O_LAYOUT_ID, &src_layout, &dst_layout)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy layout") + + /* Reset layout values set when dataset is created */ + dst_layout.ops = NULL; + switch(dst_layout.type) { + case H5D_COMPACT: + dst_layout.u.compact.buf = H5MM_xfree(dst_layout.u.compact.buf); + HDmemset(&dst_layout.u.compact, 0, sizeof(dst_layout.u.compact)); + break; + + case H5D_CONTIGUOUS: + dst_layout.u.contig.addr = HADDR_UNDEF; + dst_layout.u.contig.size = 0; + break; + + case H5D_CHUNKED: + dst_layout.u.chunk.addr = HADDR_UNDEF; + dst_layout.u.chunk.size = 0; + dst_layout.u.chunk.btree_shared = NULL; + dst_layout.u.chunk.ops = NULL; + break; + + default: + HDassert(0 && "Unknown layout type!"); + } /* end switch */ + + /* Make copy of fill value */ if(NULL == H5O_msg_copy(H5O_FILL_ID, &src_fill, &dst_fill)) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy fill value") + + /* Make copy of external file list */ HDmemset(&dst_efl, 0, sizeof(H5O_efl_t)); if(NULL == H5O_msg_copy(H5O_EFL_ID, &src_efl, &dst_efl)) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy external file list") - /* reset efl name_offset and heap_addr, these are the values when the dataset is created */ - if (dst_efl.slot) - { + /* Reset efl name_offset and heap_addr, these are the values when the dataset is created */ + if(dst_efl.slot) { unsigned int i; dst_efl.heap_addr = HADDR_UNDEF; - for ( i = 0; i < dst_efl.nused; i++) - { + for(i = 0; i < dst_efl.nused; i++) dst_efl.slot[i].name_offset = 0; - } - - } - + } /* end if */ + /* Make copy of data pipeline */ if(NULL == H5O_msg_copy(H5O_PLINE_ID, &src_pline, &dst_pline)) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy data pipeline") - /* Set the fill value, external file list, and data pipeline property - * for the destination property list */ + /* Set the layout, fill value, external file list, and data pipeline + * properties for the destination property list + */ + if(H5P_set(dst_plist, H5D_CRT_LAYOUT_NAME, &dst_layout) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") if(H5P_set(dst_plist, H5D_CRT_FILL_VALUE_NAME, &dst_fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") if(H5P_set(dst_plist, H5D_CRT_EXT_FILE_LIST_NAME, &dst_efl) < 0) @@ -329,6 +357,76 @@ done: /*------------------------------------------------------------------------- + * Function: H5P_dcrt_layout_cmp + * + * Purpose: Callback routine which is called whenever the layout + * property in the dataset creation property list is + * compared. + * + * Return: positive if VALUE1 is greater than VALUE2, negative if + * VALUE2 is greater than VALUE1 and zero if VALUE1 and + * VALUE2 are equal. + * + * Programmer: Quincey Koziol + * Tuesday, December 23, 2008 + * + *------------------------------------------------------------------------- + */ +static int +H5P_dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t UNUSED size) +{ + const H5O_layout_t *layout1 = (const H5O_layout_t *)_layout1, /* Create local aliases for values */ + *layout2 = (const H5O_layout_t *)_layout2; + int cmp_value; /* Value from comparison */ + herr_t ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_dcrt_layout_cmp) + + /* Sanity check */ + HDassert(layout1); + HDassert(layout1); + HDassert(size == sizeof(H5O_layout_t)); + + /* Check for different layout type */ + if(layout1->type < layout2->type) HGOTO_DONE(-1) + if(layout1->type > layout2->type) HGOTO_DONE(1) + + /* Check for different layout version */ + if(layout1->version < layout2->version) HGOTO_DONE(-1) + if(layout1->version > layout2->version) HGOTO_DONE(1) + + /* Compare non-dataset-specific fields in layout info */ + switch(layout1->type) { + case H5D_COMPACT: + case H5D_CONTIGUOUS: + break; + + case H5D_CHUNKED: + { + unsigned u; /* Local index variable */ + + /* Check the number of dimensions */ + if(layout1->u.chunk.ndims < layout2->u.chunk.ndims) HGOTO_DONE(-1) + if(layout1->u.chunk.ndims > layout2->u.chunk.ndims) HGOTO_DONE(1) + + /* Compare the chunk dims */ + for(u = 0; u < layout1->u.chunk.ndims - 1; u++) { + if(layout1->u.chunk.dim[u] < layout2->u.chunk.dim[u]) HGOTO_DONE(-1) + if(layout1->u.chunk.dim[u] > layout2->u.chunk.dim[u]) HGOTO_DONE(1) + } /* end for */ + } /* end case */ + break; + + default: + HDassert(0 && "Unknown layout type!"); + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_dcrt_layout_cmp() */ + + +/*------------------------------------------------------------------------- * Function: H5P_fill_value_cmp * * Purpose: Callback routine which is called whenever the fill value @@ -571,7 +669,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout) +H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) { unsigned alloc_time_state; /* State of allocation time property */ herr_t ret_value = SUCCEED; /* return value */ @@ -591,7 +689,7 @@ H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Set the default based on layout */ - switch(layout) { + switch(layout->type) { case H5D_COMPACT: fill.alloc_time = H5D_ALLOC_TIME_EARLY; break; @@ -605,16 +703,16 @@ H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout) break; default: - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layou t type") + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type") } /* end switch */ /* Set updated fill value info */ if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocat ion time") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time") } /* end if */ /* Set layout value */ - if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout") done: @@ -642,29 +740,48 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_layout(hid_t plist_id, H5D_layout_t layout) +H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + const H5O_layout_t *layout; /* Pointer to default layout information for type specified */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pset_layout, FAIL) - H5TRACE2("e", "iDl", plist_id, layout); + H5TRACE2("e", "iDl", plist_id, layout_type); /* Check arguments */ - if (layout < 0 || layout >= H5D_NLAYOUTS) + if(layout_type < 0 || layout_type >= H5D_NLAYOUTS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "raw data layout method is not valid") /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + /* Get pointer to correct default layout */ + switch(layout_type) { + case H5D_COMPACT: + layout = &H5D_def_layout_compact_g; + break; + + case H5D_CONTIGUOUS: + layout = &H5D_def_layout_contig_g; + break; + + case H5D_CHUNKED: + layout = &H5D_def_layout_chunk_g; + break; + + default: + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type") + } /* end switch */ + /* Set value */ - if(H5P_set_layout (plist, layout) < 0) + if(H5P_set_layout(plist, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pset_layout() */ /*------------------------------------------------------------------------- @@ -692,7 +809,8 @@ H5D_layout_t H5Pget_layout(hid_t plist_id) { H5P_genplist_t *plist; /* Property list pointer */ - H5D_layout_t ret_value = H5D_LAYOUT_ERROR; + H5O_layout_t layout; /* Layout property */ + H5D_layout_t ret_value; /* Return value */ FUNC_ENTER_API(H5Pget_layout, H5D_LAYOUT_ERROR) H5TRACE1("Dl", "i", plist_id); @@ -701,13 +819,16 @@ H5Pget_layout(hid_t plist_id) if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5D_LAYOUT_ERROR, "can't find object for ID") - /* Get value */ - if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &ret_value) < 0) + /* Get layout property */ + if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5D_LAYOUT_ERROR, "can't get layout") + /* Set return value */ + ret_value = layout.type; + done: FUNC_LEAVE_API(ret_value) -} +} /* ed H5Pget_layout() */ /*------------------------------------------------------------------------- @@ -715,7 +836,7 @@ done: * * Purpose: Sets the number of dimensions and the size of each chunk to * the values specified. The dimensionality of the chunk should - * match the dimensionality of the data space. + * match the dimensionality of the dataspace. * * As a side effect, the layout method is changed to * H5D_CHUNKED. @@ -738,7 +859,7 @@ herr_t H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) { H5P_genplist_t *plist; /* Property list pointer */ - uint32_t real_dims[H5O_LAYOUT_NDIMS]; /* Full-sized array to hold chunk dims */ + H5O_layout_t chunk_layout; /* Layout information for setting chunk info */ uint64_t chunk_nelmts; /* Number of elements in chunk */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -754,8 +875,9 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) if(!dim) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no chunk dimensions specified") - /* Verify & initialize internal chunk dims */ - HDmemset(real_dims, 0, sizeof(real_dims)); + /* Verify & initialize property's chunk dims */ + HDmemcpy(&chunk_layout, &H5D_def_layout_chunk_g, sizeof(H5D_def_layout_chunk_g)); + HDmemset(&chunk_layout.u.chunk.dim, 0, sizeof(chunk_layout.u.chunk.dim)); chunk_nelmts = 1; for(u = 0; u < (unsigned)ndims; u++) { if(dim[u] == 0) @@ -765,7 +887,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) chunk_nelmts *= dim[u]; if(chunk_nelmts > (uint64_t)0xffffffff) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "number of elements in chunk must be < 4GB") - real_dims[u] = (uint32_t)dim[u]; /* Store user's chunk dimensions */ + chunk_layout.u.chunk.dim[u] = (uint32_t)dim[u]; /* Store user's chunk dimensions */ } /* end for */ /* Get the plist structure */ @@ -773,12 +895,9 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set chunk information in property list */ - if(H5P_set_layout(plist, H5D_CHUNKED) < 0) + chunk_layout.u.chunk.ndims = (unsigned)ndims; + if(H5P_set_layout(plist, &chunk_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") - if(H5P_set(plist, H5D_CRT_CHUNK_DIM_NAME, &ndims) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set chunk dimensionanlity") - if(H5P_set(plist, H5D_CRT_CHUNK_SIZE_NAME, real_dims) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set chunk size") done: FUNC_LEAVE_API(ret_value) @@ -812,10 +931,9 @@ done: int H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/) { - int ndims; - H5D_layout_t layout; H5P_genplist_t *plist; /* Property list pointer */ - int ret_value; + H5O_layout_t layout; /* Layout information */ + int ret_value; /* Return value */ FUNC_ENTER_API(H5Pget_chunk, FAIL) H5TRACE3("Is", "iIsx", plist_id, max_ndims, dim); @@ -824,28 +942,22 @@ H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/) if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + /* Retrieve the layout property */ if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_CHUNKED != layout) + if(H5D_CHUNKED != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a chunked storage layout") - if(H5P_get(plist, H5D_CRT_CHUNK_DIM_NAME, &ndims) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get chunk dimensionality") - if(dim) { - int i; - uint32_t chunk_size[H5O_LAYOUT_NDIMS]; - - if(H5P_get(plist, H5D_CRT_CHUNK_SIZE_NAME, chunk_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get chunk size") + unsigned u; /* Local index variable */ /* Get the dimension sizes */ - for(i = 0; i < ndims && i < max_ndims; i++) - dim[i] = chunk_size[i]; + for(u = 0; u < layout.u.chunk.ndims && u < (unsigned)max_ndims; u++) + dim[u] = layout.u.chunk.dim[u]; } /* end if */ /* Set the return value */ - ret_value = ndims; + ret_value = (int)layout.u.chunk.ndims; done: FUNC_LEAVE_API(ret_value) @@ -865,7 +977,7 @@ done: * should be defined in order. The total size of the dataset is * the sum of the SIZE arguments for all the external files. If * the total size is larger than the size of a dataset then the - * dataset can be extended (provided the data space also allows + * dataset can be extended (provided the dataspace also allows * the extending). * * Return: Non-negative on success/Negative on failure @@ -1623,24 +1735,24 @@ done: htri_t H5Pall_filters_avail(hid_t plist_id) { - H5O_pline_t pline; /* Filter pipeline */ H5P_genplist_t *plist; /* Property list pointer */ - hbool_t ret_value = TRUE; /* return value */ + H5O_pline_t pline; /* Filter pipeline */ + htri_t ret_value; /* Return value */ - FUNC_ENTER_API(H5Pall_filters_avail, UFAIL) + FUNC_ENTER_API(H5Pall_filters_avail, FAIL) H5TRACE1("t", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, UFAIL, "can't find object for ID") + if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get pipeline info */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, UFAIL, "can't get pipeline") + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - /* Set return value */ - if(UFAIL == (ret_value = H5Z_all_filters_avail(&pline))) - HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, UFAIL, "can't check pipeline information") + /* Check if all filters are available */ + if((ret_value = H5Z_all_filters_avail(&pline)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "can't check pipeline information") done: FUNC_LEAVE_API(ret_value) @@ -1970,8 +2082,10 @@ H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_fac if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") + if(scale_factor < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "scale factor must be > 0") if(scale_type!=H5Z_SO_FLOAT_DSCALE && scale_type!=H5Z_SO_FLOAT_ESCALE && scale_type!=H5Z_SO_INT) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "invalid scale type") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid scale type") /* Get the plist structure */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) @@ -1986,7 +2100,7 @@ H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_fac * if scale_factor = 0, then filter calculates minimum number of bits */ cd_values[0] = scale_type; - cd_values[1] = scale_factor; + cd_values[1] = (unsigned)scale_factor; /* Add the scaleoffset filter */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) @@ -2099,7 +2213,7 @@ H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value) /* Set the fill value */ if(NULL == (fill.type = H5T_copy(type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy datatype") - fill.size = H5T_get_size(type); + fill.size = (ssize_t)H5T_get_size(type); if(NULL == (fill.buf = H5MM_malloc((size_t)fill.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for fill value") HDmemcpy(fill.buf, value, (size_t)fill.size); @@ -2430,14 +2544,14 @@ H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) /* Check for resetting to default for layout type */ if(alloc_time == H5D_ALLOC_TIME_DEFAULT) { - H5D_layout_t layout; /* Type of storage layout */ + H5O_layout_t layout; /* Type of storage layout */ /* Retrieve the storage layout */ if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout") /* Set the default based on layout */ - switch(layout) { + switch(layout.type) { case H5D_COMPACT: alloc_time = H5D_ALLOC_TIME_EARLY; break; diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index c51f750..e082e9c 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -1984,7 +1984,7 @@ H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - latest = (low == H5F_LIBVER_LATEST) ? TRUE : FALSE; + latest = (hbool_t)((low == H5F_LIBVER_LATEST) ? TRUE : FALSE); if(H5P_set(plist, H5F_ACS_LATEST_FORMAT_NAME, &latest) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set library version bounds") diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index a4aff51..913c5f1 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -257,8 +257,8 @@ H5Pset_link_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dens ginfo.store_link_phase_change = TRUE; else ginfo.store_link_phase_change = FALSE; - ginfo.max_compact = max_compact; - ginfo.min_dense = min_dense; + ginfo.max_compact = (uint16_t)max_compact; + ginfo.min_dense = (uint16_t)min_dense; /* Set group info */ if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) @@ -361,8 +361,8 @@ H5Pset_est_link_info(hid_t plist_id, unsigned est_num_entries, unsigned est_name ginfo.store_est_entry_info = TRUE; else ginfo.store_est_entry_info = FALSE; - ginfo.est_num_entries = est_num_entries; - ginfo.est_name_len = est_name_len; + ginfo.est_num_entries = (uint16_t)est_num_entries; + ginfo.est_name_len = (uint16_t)est_name_len; /* Set group info */ if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) @@ -451,8 +451,8 @@ H5Pset_link_creation_order(hid_t plist_id, unsigned crt_order_flags) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info") /* Update fields */ - linfo.track_corder = (crt_order_flags & H5P_CRT_ORDER_TRACKED) ? TRUE : FALSE; - linfo.index_corder = (crt_order_flags & H5P_CRT_ORDER_INDEXED) ? TRUE : FALSE; + linfo.track_corder = (hbool_t)((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? TRUE : FALSE); + linfo.index_corder = (hbool_t)((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? TRUE : FALSE); /* Set link info */ if(H5P_set(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) diff --git a/src/H5Pint.c b/src/H5Pint.c index b8c7b4c..799535f 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -735,7 +735,7 @@ H5P_copy_plist(H5P_genplist_t *old_plist, hbool_t app_ref) * initialize each with default value & make property 'copy' callback. */ tclass=old_plist->pclass; - has_parent_class=(tclass!=NULL && tclass->parent!=NULL && tclass->parent->nprops>0); + has_parent_class = (hbool_t)(tclass != NULL && tclass->parent != NULL && tclass->parent->nprops > 0); while(tclass!=NULL) { if(tclass->nprops>0) { /* Walk through the properties in the old class */ @@ -4106,7 +4106,7 @@ H5P_close(void *_plist) * initialize each with default value & make property 'remove' callback. */ tclass=plist->pclass; - has_parent_class=(tclass!=NULL && tclass->parent!=NULL && tclass->parent->nprops>0); + has_parent_class = (hbool_t)(tclass != NULL && tclass->parent != NULL && tclass->parent->nprops > 0); while(tclass!=NULL) { if(tclass->nprops>0) { /* Walk through the properties in the class */ diff --git a/src/H5Plapl.c b/src/H5Plapl.c index e3f2333..e7b4381 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -254,19 +254,17 @@ done: *--------------------------------------------------------------------------- */ /* ARGSUSED */ -herr_t +static herr_t H5P_lacc_elink_fapl_close(const char UNUSED *name, size_t UNUSED size, void *value) { hid_t l_fapl_id; herr_t ret_value = SUCCEED; -int ref_count; - FUNC_ENTER_NOAPI(H5P_lacc_elink_fapl_close, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5P_lacc_elink_fapl_close) HDassert(value); l_fapl_id = (*(const hid_t *)value); - if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE) < 0)) HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") @@ -558,7 +556,7 @@ done: herr_t H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id) { - H5P_genplist_t *plist, *l_fapl_plist, *fapl_plist; /* Property list pointer */ + H5P_genplist_t *plist, *fapl_plist; /* Property list pointer */ hid_t l_fapl_id, new_fapl_id; herr_t ret_value = SUCCEED; /* Return value */ @@ -577,7 +575,7 @@ H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id) if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE) < 0)) HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") - if (NULL==(fapl_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if(NULL == (fapl_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); /* Make a copy of the property list for FAPL_ID */ diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c index 4006f0e..1e4355e 100644 --- a/src/H5Plcpl.c +++ b/src/H5Plcpl.c @@ -156,7 +156,7 @@ H5Pset_create_intermediate_group(hid_t plist_id, unsigned crt_intmd_group) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - crt_intmd_group = crt_intmd_group > 0 ? 1 : 0; + crt_intmd_group = (unsigned)(crt_intmd_group > 0 ? 1 : 0); if(H5P_set(plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, &crt_intmd_group) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set intermediate group creation flag") diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index b947bef..a28eeb3 100755 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -275,11 +275,11 @@ H5Pset_attr_creation_order(hid_t plist_id, unsigned crt_order_flags) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") /* Mask off previous attribute creation order flag settings */ - ohdr_flags &= ~(H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED); + ohdr_flags &= (uint8_t)~(H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED); /* Update with new attribute creation order flags */ - ohdr_flags |= (crt_order_flags & H5P_CRT_ORDER_TRACKED) ? H5O_HDR_ATTR_CRT_ORDER_TRACKED : 0; - ohdr_flags |= (crt_order_flags & H5P_CRT_ORDER_INDEXED) ? H5O_HDR_ATTR_CRT_ORDER_INDEXED : 0; + ohdr_flags |= (uint8_t)((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? H5O_HDR_ATTR_CRT_ORDER_TRACKED : 0); + ohdr_flags |= (uint8_t)((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? H5O_HDR_ATTR_CRT_ORDER_INDEXED : 0); /* Set object header flags */ if(H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) @@ -382,10 +382,10 @@ H5Pset_obj_track_times(hid_t plist_id, hbool_t track_times) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") /* Mask off previous time tracking flag settings */ - ohdr_flags &= ~H5O_HDR_STORE_TIMES; + ohdr_flags &= (uint8_t)~H5O_HDR_STORE_TIMES; /* Update with new time tracking flag */ - ohdr_flags |= track_times ? H5O_HDR_STORE_TIMES : 0; + ohdr_flags |= (uint8_t)(track_times ? H5O_HDR_STORE_TIMES : 0); /* Set object header flags */ if(H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) @@ -430,7 +430,7 @@ H5Pget_obj_track_times(hid_t plist_id, hbool_t *track_times) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") /* Set track times flag to return */ - *track_times = (ohdr_flags & H5O_HDR_STORE_TIMES) ? TRUE : FALSE; + *track_times = (hbool_t)((ohdr_flags & H5O_HDR_STORE_TIMES) ? TRUE : FALSE); } /* end if */ done: @@ -164,7 +164,7 @@ H5S_create(H5S_class_t type) FUNC_ENTER_NOAPI(H5S_create, NULL) - /* Create a new data space */ + /* Create a new dataspace */ if(NULL == (new_ds = H5FL_MALLOC(H5S_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") @@ -250,7 +250,7 @@ H5Screate(H5S_class_t type) /* Atomize */ if((ret_value = H5I_register (H5I_DATASPACE, new_ds, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space atom") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") done: if(ret_value < 0 && new_ds) @@ -299,7 +299,7 @@ done: /*------------------------------------------------------------------------- * Function: H5S_close * - * Purpose: Releases all memory associated with a data space. + * Purpose: Releases all memory associated with a dataspace. * * Return: Non-negative on success/Negative on failure * @@ -334,7 +334,7 @@ done: /*------------------------------------------------------------------------- * Function: H5Sclose * - * Purpose: Release access to a data space object. + * Purpose: Release access to a dataspace object. * * Return: Non-negative on success/Negative on failure * @@ -357,7 +357,7 @@ H5Sclose(hid_t space_id) /* Check args */ if (NULL == H5I_object_verify(space_id,H5I_DATASPACE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* When the reference count reaches zero the resources are freed */ if (H5I_dec_ref(space_id, TRUE) < 0) @@ -396,15 +396,15 @@ H5Scopy(hid_t space_id) /* Check args */ if (NULL==(src=(H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Copy */ if (NULL == (dst = H5S_copy(src, FALSE, TRUE))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy data space") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace") /* Atomize */ if ((ret_value=H5I_register (H5I_DATASPACE, dst, TRUE))<0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space atom") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") done: if(ret_value<0) { @@ -442,9 +442,9 @@ H5Sextent_copy(hid_t dst_id,hid_t src_id) /* Check args */ if(NULL == (src = (H5S_t *)H5I_object_verify(src_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") if(NULL == (dst = (H5S_t *)H5I_object_verify(dst_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Copy */ if(H5S_extent_copy(&(dst->extent), &(src->extent), TRUE) < 0) @@ -508,7 +508,7 @@ H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_max) break; default: - HDassert("unknown data space type" && 0); + HDassert("unknown dataspace type" && 0); break; } /* end switch */ @@ -524,7 +524,7 @@ done: /*------------------------------------------------------------------------- * Function: H5S_copy * - * Purpose: Copies a data space, by copying the extent and selection through + * Purpose: Copies a dataspace, by copying the extent and selection through * H5S_extent_copy and H5S_select_copy. If the SHARE_SELECTION flag * is set, then the selection can be shared between the source and * destination dataspaces. (This should only occur in situations @@ -595,17 +595,17 @@ H5S_get_simple_extent_npoints(const H5S_t *ds) { hssize_t ret_value; - FUNC_ENTER_NOAPI(H5S_get_simple_extent_npoints, -1); + FUNC_ENTER_NOAPI(H5S_get_simple_extent_npoints, -1) /* check args */ - assert(ds); + HDassert(ds); /* Get the number of elements in extent */ - ret_value = ds->extent.nelem; + ret_value = (hssize_t)ds->extent.nelem; done: - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5S_get_simple_extent_npoints() */ /*------------------------------------------------------------------------- @@ -631,30 +631,30 @@ H5Sget_simple_extent_npoints(hid_t space_id) H5S_t *ds; hssize_t ret_value; - FUNC_ENTER_API(H5Sget_simple_extent_npoints, FAIL); + FUNC_ENTER_API(H5Sget_simple_extent_npoints, FAIL) H5TRACE1("Hs", "i", space_id); /* Check args */ - if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - ret_value = H5S_GET_EXTENT_NPOINTS(ds); + ret_value = (hssize_t)H5S_GET_EXTENT_NPOINTS(ds); done: - FUNC_LEAVE_API(ret_value); -} + FUNC_LEAVE_API(ret_value) +} /* end H5Sget_simple_extent_npoints() */ /*------------------------------------------------------------------------- * Function: H5S_get_npoints_max * - * Purpose: Determines the maximum number of data points a data space may + * Purpose: Determines the maximum number of data points a dataspace may * have. If the `max' array is null then the maximum number of * data points is the same as the current number of data points * without regard to the hyperslab. If any element of the `max' * array is zero then the maximum possible size is returned. * - * Return: Success: Maximum number of data points the data space + * Return: Success: Maximum number of data points the dataspace * may have. * * Failure: 0 @@ -704,8 +704,8 @@ H5S_get_npoints_max(const H5S_t *ds) break; default: - assert("unknown data space class" && 0); - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "internal error (unknown data space class)") + assert("unknown dataspace class" && 0); + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "internal error (unknown dataspace class)") } done: @@ -716,9 +716,9 @@ done: /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_ndims * - * Purpose: Determines the dimensionality of a data space. + * Purpose: Determines the dimensionality of a dataspace. * - * Return: Success: The number of dimensions in a data space. + * Return: Success: The number of dimensions in a dataspace. * * Failure: Negative * @@ -735,24 +735,24 @@ H5Sget_simple_extent_ndims(hid_t space_id) H5S_t *ds; int ret_value; - FUNC_ENTER_API(H5Sget_simple_extent_ndims, FAIL); + FUNC_ENTER_API(H5Sget_simple_extent_ndims, FAIL) H5TRACE1("Is", "i", space_id); /* Check args */ - if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - ret_value = H5S_GET_EXTENT_NDIMS(ds); + ret_value = (int)H5S_GET_EXTENT_NDIMS(ds); done: - FUNC_LEAVE_API(ret_value); -} + FUNC_LEAVE_API(ret_value) +} /* end H5Sget_simple_extent_ndims() */ /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_ndims * - * Purpose: Returns the number of dimensions in a data space. + * Purpose: Returns the number of dimensions in a dataspace. * * Return: Success: Non-negative number of dimensions. Zero * implies a scalar. @@ -773,35 +773,35 @@ done: int H5S_get_simple_extent_ndims(const H5S_t *ds) { - int ret_value; + int ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5S_get_simple_extent_ndims, FAIL); + FUNC_ENTER_NOAPI(H5S_get_simple_extent_ndims, FAIL) /* check args */ - assert(ds); + HDassert(ds); - switch (H5S_GET_EXTENT_TYPE(ds)) { + switch(H5S_GET_EXTENT_TYPE(ds)) { case H5S_NULL: case H5S_SCALAR: case H5S_SIMPLE: - ret_value = ds->extent.rank; + ret_value = (int)ds->extent.rank; break; default: - assert("unknown data space class" && 0); - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "internal error (unknown data space class)") - } + HDassert("unknown dataspace class" && 0); + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "internal error (unknown dataspace class)") + } /* end switch */ done: - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5S_get_simple_extent_ndims() */ /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_dims * * Purpose: Returns the size and maximum sizes in each dimension of - * a data space DS through the DIMS and MAXDIMS arguments. + * a dataspace DS through the DIMS and MAXDIMS arguments. * * Return: Success: Number of dimensions, the same value as * returned by H5Sget_simple_extent_ndims(). @@ -843,8 +843,8 @@ done: /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_dims * - * Purpose: Returns the size in each dimension of a data space. This - * function may not be meaningful for all types of data spaces. + * Purpose: Returns the size in each dimension of a dataspace. This + * function may not be meaningful for all types of dataspaces. * * Return: Success: Number of dimensions. Zero implies scalar. * @@ -860,48 +860,48 @@ done: int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[]) { - int ret_value; - int i; + int i; /* Local index variable */ + int ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5S_get_simple_extent_dims, FAIL); + FUNC_ENTER_NOAPI(H5S_get_simple_extent_dims, FAIL) /* check args */ - assert(ds); + HDassert(ds); - switch (H5S_GET_EXTENT_TYPE(ds)) { + switch(H5S_GET_EXTENT_TYPE(ds)) { case H5S_NULL: case H5S_SCALAR: ret_value = 0; break; case H5S_SIMPLE: - ret_value = ds->extent.rank; - for (i=0; i<ret_value; i++) { - if (dims) + ret_value = (int)ds->extent.rank; + for(i = 0; i < ret_value; i++) { + if(dims) dims[i] = ds->extent.size[i]; - if (max_dims) { - if (ds->extent.max) + if(max_dims) { + if(ds->extent.max) max_dims[i] = ds->extent.max[i]; else max_dims[i] = ds->extent.size[i]; - } - } + } /* end if */ + } /* end for */ break; default: - assert("unknown data space class" && 0); - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "internal error (unknown data space class)") - } + HDassert("unknown dataspace class" && 0); + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "internal error (unknown dataspace class)") + } /* end switch */ done: - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5S_get_simple_extent_dims() */ /*------------------------------------------------------------------------- * Function: H5S_write * - * Purpose: Updates a data space by writing a message to an object + * Purpose: Updates a dataspace by writing a message to an object * header. * * Return: Non-negative on success/Negative on failure @@ -935,7 +935,7 @@ done: /*------------------------------------------------------------------------- * Function: H5S_append * - * Purpose: Updates a data space by adding a message to an object + * Purpose: Updates a dataspace by adding a message to an object * header. * * Return: Non-negative on success/Negative on failure @@ -976,9 +976,9 @@ done: /*------------------------------------------------------------------------- * Function: H5S_read * - * Purpose: Reads the data space from an object header. + * Purpose: Reads the dataspace from an object header. * - * Return: Success: Pointer to a new data space. + * Return: Success: Pointer to a new dataspace. * * Failure: NULL * @@ -1078,7 +1078,7 @@ H5Sis_simple(hid_t space_id) /* Check args and all the boring stuff. */ if ((space = (H5S_t *)H5I_object_verify(space_id,H5I_DATASPACE)) == NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") ret_value = H5S_is_simple(space); @@ -1132,7 +1132,7 @@ H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], /* Check args */ if ((space = (H5S_t *)H5I_object_verify(space_id,H5I_DATASPACE)) == NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") if (rank > 0 && dims == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified") if (rank<0 || rank>H5S_MAX_RANK) @@ -1245,7 +1245,7 @@ done: /*------------------------------------------------------------------------- * Function: H5Screate_simple * - * Purpose: Creates a new simple data space object and opens it for + * Purpose: Creates a new simple dataspace object and opens it for * access. The DIMS argument is the size of the simple dataset * and the MAXDIMS argument is the upper limit on the size of * the dataset. MAXDIMS may be the null pointer in which case @@ -1254,7 +1254,7 @@ done: * unlimited, otherwise no element of MAXDIMS should be smaller * than the corresponding element of DIMS. * - * Return: Success: The ID for the new simple data space object. + * Return: Success: The ID for the new simple dataspace object. * * Failure: Negative * @@ -1326,7 +1326,7 @@ done: * * Purpose: Internal function to create simple dataspace * - * Return: Success: The ID for the new simple data space object. + * Return: Success: The ID for the new simple dataspace object. * Failure: Negative * * Errors: @@ -1405,7 +1405,7 @@ done: * Function: H5S_encode * * Purpose: Private function for H5Sencode. Converts an object - * description for data space and its selection into binary + * description for dataspace and its selection into binary * in a buffer. * * Return: Success: non-negative @@ -1571,7 +1571,7 @@ H5S_decode(const unsigned char *buf) /* Copy the extent into dataspace structure */ if((ds = H5FL_CALLOC(H5S_t))==NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for data space conversion path table") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for dataspace conversion path table") if(H5O_msg_copy(H5O_SDSPACE_ID, extent, &(ds->extent)) == NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy object") if(H5S_extent_release(extent) < 0) @@ -1699,7 +1699,7 @@ H5Sset_extent_none(hid_t space_id) /* Check args */ if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") /* Clear the previous extent from the dataspace */ if(H5S_extent_release(&space->extent)<0) @@ -1739,7 +1739,7 @@ H5Soffset_simple(hid_t space_id, const hssize_t *offset) /* Check args */ if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") if (space->extent.rank==0 || (H5S_GET_EXTENT_TYPE(space)==H5S_SCALAR || H5S_GET_EXTENT_TYPE(space)==H5S_NULL)) HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar or null dataspace") @@ -1758,7 +1758,7 @@ done: /*------------------------------------------------------------------------- * Function: H5S_set_extent * - * Purpose: Modify the dimensions of a data space. Based on H5S_extend + * Purpose: Modify the dimensions of a dataspace. Based on H5S_extend * * Return: Success: Non-negative * @@ -1819,9 +1819,10 @@ hbool_t H5S_has_extent(const H5S_t *ds) { htri_t ret_value; + FUNC_ENTER_NOAPI(H5S_has_extent, FAIL) - assert(ds); + HDassert(ds); if(ds->extent.rank==0 && ds->extent.nelem == 0 && ds->extent.type != H5S_NULL) ret_value = FALSE; @@ -1830,13 +1831,13 @@ H5S_has_extent(const H5S_t *ds) done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5S_has_extent() */ /*------------------------------------------------------------------------- * Function: H5S_set_extent_real * - * Purpose: Modify the dimensions of a data space. Based on H5S_extend + * Purpose: Modify the dimensions of a dataspace. Based on H5S_extend * * Return: Success: Non-negative * @@ -2040,7 +2041,7 @@ done: /*------------------------------------------------------------------------- * Function: H5S_extend * - * Purpose: Extend the dimensions of a data space. + * Purpose: Extend the dimensions of a dataspace. * * Return: Success: Number of dimensions whose size increased. * diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 6e8836c..21e08d4 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -301,10 +301,10 @@ H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) /* "Flatten" dataspace extent and selection information */ curr_dim=flat_rank-1; - for(i=rank-1, acc=1; i>=0; i--) { - if(tdiminfo[i].block==mem_size[i] && i>0) { + for(i = (int)rank - 1, acc = 1; i >= 0; i--) { + if(tdiminfo[i].block == mem_size[i] && i > 0) { /* "Flatten" this dimension */ - assert(tdiminfo[i].start==0); + HDassert(tdiminfo[i].start == 0); acc *= mem_size[i]; /* Indicate that the dimension was flattened */ @@ -322,7 +322,7 @@ H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) iter->u.hyp.diminfo[curr_dim].count = tdiminfo[i].count; iter->u.hyp.diminfo[curr_dim].block = tdiminfo[i].block*acc; iter->u.hyp.size[curr_dim] = mem_size[i]*acc; - iter->u.hyp.sel_off[curr_dim] = space->select.offset[i]*acc; + iter->u.hyp.sel_off[curr_dim] = space->select.offset[i] * acc; /* Reset the "last dim flattened" flag to avoid flattened any further dimensions */ last_dim_flattened=0; @@ -441,8 +441,8 @@ H5S_hyper_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords) int u, v; /* Dimension indices */ /* Set the starting rank of both the "natural" & "flattened" dimensions */ - u = iter->rank - 1; - v = iter->u.hyp.iter_rank - 1; + u = (int)iter->rank - 1; + v = (int)iter->u.hyp.iter_rank - 1; /* Construct the "natural" dimensions from a set of flattened coordinates */ while(u >= 0) { @@ -677,7 +677,7 @@ H5S_hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) } /* end else */ /* Set the fastest dimension rank */ - fast_dim=ndims-1; + fast_dim = (int)ndims - 1; /* Set the local copy of the diminfo pointer */ tdiminfo=iter->u.hyp.diminfo; @@ -753,7 +753,7 @@ H5S_hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) /* Set the rank of the fastest changing dimension */ ndims=iter->rank; - fast_dim=(ndims-1); + fast_dim = (int)ndims - 1; /* Get the pointers to the current span info and span nodes */ abs_arr=iter->u.hyp.off; @@ -892,7 +892,7 @@ H5S_hyper_iter_next_block(H5S_sel_iter_t *iter) } /* end else */ /* Set the fastest dimension rank */ - fast_dim=ndims-1; + fast_dim = (int)ndims - 1; /* Set the local copy of the diminfo pointer */ tdiminfo=iter->u.hyp.diminfo; @@ -952,8 +952,8 @@ H5S_hyper_iter_next_block(H5S_sel_iter_t *iter) int curr_dim; /* Temporary rank holder */ /* Set the rank of the fastest changing dimension */ - ndims=iter->rank; - fast_dim=(ndims-1); + ndims = iter->rank; + fast_dim = (int)ndims - 1; /* Get the pointers to the current span info and span nodes */ abs_arr=iter->u.hyp.off; @@ -1802,7 +1802,7 @@ done: PURPOSE Count the number of blocks in a span tree USAGE - hssize_t H5S_hyper_span_nblocks(spans) + hsize_t H5S_hyper_span_nblocks(spans) const H5S_hyper_span_info_t *spans; IN: Hyperslab span tree to count elements of RETURNS Number of blocks in span tree on success; negative on failure @@ -1813,34 +1813,31 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static hssize_t -H5S_hyper_span_nblocks (H5S_hyper_span_info_t *spans) +static hsize_t +H5S_hyper_span_nblocks(H5S_hyper_span_info_t *spans) { H5S_hyper_span_t *span; /* Hyperslab span */ - hssize_t ret_value; + hsize_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_span_nblocks); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_span_nblocks) /* Count the number of elements in the span tree */ - if(spans==NULL) - ret_value=0; - else { - span=spans->head; - ret_value=0; - while(span!=NULL) { + if(spans != NULL) { + span = spans->head; + while(span != NULL) { /* If there are down spans, add the total down span blocks */ if(span->down!=NULL) - ret_value+=H5S_hyper_span_nblocks(span->down); + ret_value += H5S_hyper_span_nblocks(span->down); /* If there are no down spans, just count the block in this span */ else ret_value++; /* Advance to next span */ - span=span->next; + span = span->next; } /* end while */ } /* end else */ - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5S_hyper_span_nblocks() */ @@ -1850,7 +1847,7 @@ H5S_hyper_span_nblocks (H5S_hyper_span_info_t *spans) PURPOSE Get the number of hyperslab blocks in current hyperslab selection USAGE - hssize_t H5S_get_select_hyper_nblocks(space) + hsize_t H5S_get_select_hyper_nblocks(space) H5S_t *space; IN: Dataspace ptr of selection to query RETURNS The number of hyperslab blocks in selection on success, negative on failure @@ -1861,26 +1858,27 @@ H5S_hyper_span_nblocks (H5S_hyper_span_info_t *spans) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static hssize_t +static hsize_t H5S_get_select_hyper_nblocks(H5S_t *space) { - hssize_t ret_value; /* return value */ - unsigned u; /* Counter */ + hsize_t ret_value; /* return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_get_select_hyper_nblocks); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_get_select_hyper_nblocks) - assert(space); + HDassert(space); /* Check for a "regular" hyperslab selection */ if(space->select.sel_info.hslab->diminfo_valid) { + unsigned u; /* Local index variable */ + /* Check each dimension */ - for(ret_value=1,u=0; u<space->extent.rank; u++) - ret_value*=space->select.sel_info.hslab->app_diminfo[u].count; + for(ret_value = 1, u = 0; u < space->extent.rank; u++) + ret_value *= space->select.sel_info.hslab->app_diminfo[u].count; } /* end if */ else ret_value = H5S_hyper_span_nblocks(space->select.sel_info.hslab->span_lst); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5S_get_select_hyper_nblocks() */ @@ -1916,7 +1914,7 @@ H5Sget_select_hyper_nblocks(hid_t spaceid) if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection") - ret_value = H5S_get_select_hyper_nblocks(space); + ret_value = (hssize_t)H5S_get_select_hyper_nblocks(space); done: FUNC_LEAVE_API(ret_value) @@ -1942,37 +1940,37 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -hssize_t -H5S_hyper_serial_size (const H5S_t *space) +static hssize_t +H5S_hyper_serial_size(const H5S_t *space) { unsigned u; /* Counter */ - hssize_t block_count; /* block counter for regular hyperslabs */ + hsize_t block_count; /* block counter for regular hyperslabs */ hssize_t ret_value; /* return value */ - FUNC_ENTER_NOAPI_NOFUNC(H5S_hyper_serial_size); + FUNC_ENTER_NOAPI_NOFUNC(H5S_hyper_serial_size) - assert(space); + HDassert(space); /* Basic number of bytes required to serialize hyperslab selection: * <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> + * <length (4 bytes)> + <rank (4 bytes)> + <# of blocks (4 bytes)> = 24 bytes */ - ret_value=24; + ret_value = 24; /* Check for a "regular" hyperslab selection */ if(space->select.sel_info.hslab->diminfo_valid) { /* Check each dimension */ - for(block_count=1,u=0; u<space->extent.rank; u++) - block_count*=space->select.sel_info.hslab->opt_diminfo[u].count; - ret_value+=8*block_count*space->extent.rank; + for(block_count = 1, u = 0; u < space->extent.rank; u++) + block_count *= space->select.sel_info.hslab->opt_diminfo[u].count; } /* end if */ - else { + else /* Spin through hyperslab spans, adding 8 * rank bytes for each block */ - block_count=H5S_hyper_span_nblocks(space->select.sel_info.hslab->span_lst); - ret_value+=8*space->extent.rank*block_count; - } /* end else */ + block_count = H5S_hyper_span_nblocks(space->select.sel_info.hslab->span_lst); - FUNC_LEAVE_NOAPI(ret_value); + H5_CHECK_OVERFLOW((8 * space->extent.rank * block_count), hsize_t, hssize_t); + ret_value += (hssize_t)(8 * block_count * space->extent.rank); + + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_serial_size() */ @@ -2083,50 +2081,51 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t *buf) hsize_t end[H5O_LAYOUT_NDIMS]; /* Location of end of hyperslab */ hsize_t temp_off; /* Offset in a given dimension */ uint8_t *lenp; /* pointer to length location for later storage */ - uint32_t len=0; /* number of bytes used */ - int i; /* local counting variable */ - hssize_t block_count; /* block counter for regular hyperslabs */ - int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - int temp_dim; /* Temporary rank holder */ - int ndims; /* Rank of the dataspace */ - int done; /* Whether we are done with the iteration */ + uint32_t len = 0; /* number of bytes used */ + hsize_t block_count; /* block counter for regular hyperslabs */ + unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned ndims; /* Rank of the dataspace */ + int done; /* Whether we are done with the iteration */ - FUNC_ENTER_NOAPI_NOFUNC(H5S_hyper_serialize); + FUNC_ENTER_NOAPI_NOFUNC(H5S_hyper_serialize) - assert(space); + HDassert(space); /* Store the preamble information */ UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(buf, (uint32_t)1); /* Store the version number */ UINT32ENCODE(buf, (uint32_t)0); /* Store the un-used padding */ - lenp=buf; /* keep the pointer to the length location for later */ - buf+=4; /* skip over space for length */ + lenp = buf; /* keep the pointer to the length location for later */ + buf += 4; /* skip over space for length */ /* Encode number of dimensions */ UINT32ENCODE(buf, (uint32_t)space->extent.rank); - len+=4; + len += 4; /* Check for a "regular" hyperslab selection */ if(space->select.sel_info.hslab->diminfo_valid) { + unsigned u; /* Local counting variable */ + /* Set some convienence values */ - ndims=space->extent.rank; - fast_dim=ndims-1; + ndims = space->extent.rank; + fast_dim = ndims - 1; diminfo=space->select.sel_info.hslab->opt_diminfo; /* Check each dimension */ - for(block_count=1,i=0; i<ndims; i++) - block_count*=diminfo[i].count; + for(block_count = 1, u = 0; u < ndims; u++) + block_count *= diminfo[u].count; /* Encode number of hyperslabs */ + H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t); UINT32ENCODE(buf, (uint32_t)block_count); len+=4; /* Now serialize the information for the regular hyperslab */ /* Build the tables of count sizes as well as the initial offset */ - for(i=0; i<ndims; i++) { - tmp_count[i]=diminfo[i].count; - offset[i]=diminfo[i].start; + for(u = 0; u < ndims; u++) { + tmp_count[u] = diminfo[u].count; + offset[u] = diminfo[u].start; } /* end for */ /* We're not done with the iteration */ @@ -2140,12 +2139,12 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t *buf) len+=8*ndims; /* Encode hyperslab starting location */ - for(i=0; i<ndims; i++) - UINT32ENCODE(buf, (uint32_t)offset[i]); + for(u = 0; u < ndims; u++) + UINT32ENCODE(buf, (uint32_t)offset[u]); /* Encode hyperslab ending location */ - for(i=0; i<ndims; i++) - UINT32ENCODE(buf, (uint32_t)(offset[i]+(diminfo[i].block-1))); + for(u = 0; u < ndims; u++) + UINT32ENCODE(buf, (uint32_t)(offset[u] + (diminfo[u].block - 1))); /* Move the offset to the next sequence to start */ offset[fast_dim]+=diminfo[fast_dim].stride; @@ -2155,26 +2154,28 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t *buf) } /* end while */ /* Work on other dimensions if necessary */ - if(fast_dim>0) { + if(fast_dim > 0) { + int temp_dim; /* Temporary rank holder */ + /* Reset the block counts */ tmp_count[fast_dim]=diminfo[fast_dim].count; /* Bubble up the decrement to the slower changing dimensions */ - temp_dim=fast_dim-1; - while(temp_dim>=0 && done==0) { + temp_dim = (int)fast_dim - 1; + while(temp_dim >= 0 && done == 0) { /* Decrement the block count */ tmp_count[temp_dim]--; /* Check if we have more blocks left */ - if(tmp_count[temp_dim]>0) + if(tmp_count[temp_dim] > 0) break; /* Check for getting out of iterator */ - if(temp_dim==0) - done=1; + if(temp_dim == 0) + done = 1; /* Reset the block count in this dimension */ - tmp_count[temp_dim]=diminfo[temp_dim].count; + tmp_count[temp_dim] = diminfo[temp_dim].count; /* Wrapped a dimension, go up to next dimension */ temp_dim--; @@ -2184,32 +2185,31 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t *buf) break; /* Break out now, for 1-D selections */ /* Re-compute offset array */ - for(i=0; i<ndims; i++) { - temp_off=diminfo[i].start - +diminfo[i].stride*(diminfo[i].count-tmp_count[i]); - offset[i]=temp_off; + for(u = 0; u < ndims; u++) { + temp_off = diminfo[u].start + diminfo[u].stride * (diminfo[u].count - tmp_count[u]); + offset[u] = temp_off; } /* end for */ } /* end while */ } /* end if */ else { /* Encode number of hyperslabs */ - block_count=H5S_hyper_span_nblocks(space->select.sel_info.hslab->span_lst); + block_count = H5S_hyper_span_nblocks(space->select.sel_info.hslab->span_lst); + H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t); UINT32ENCODE(buf, (uint32_t)block_count); len+=4; /* Add 8 bytes times the rank for each hyperslab selected */ - H5_CHECK_OVERFLOW(block_count,hssize_t,hsize_t); - H5_CHECK_OVERFLOW((8*space->extent.rank*(hsize_t)block_count),hsize_t,size_t); - len+=(size_t)(8*space->extent.rank*block_count); + H5_CHECK_OVERFLOW((8 * space->extent.rank * block_count), hsize_t, size_t); + len += (size_t)(8 * space->extent.rank * block_count); /* Encode each hyperslab in selection */ - H5S_hyper_serialize_helper(space->select.sel_info.hslab->span_lst,start,end,(hsize_t)0,&buf); + H5S_hyper_serialize_helper(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, &buf); } /* end else */ /* Encode length */ UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_hyper_serialize() */ diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 74d72d9..84b427e 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -655,18 +655,18 @@ H5S_point_is_valid (const H5S_t *space) assert(space); /* Check each point to determine whether selection+offset is within extent */ - curr=space->select.sel_info.pnt_lst->head; - while(curr!=NULL) { + curr = space->select.sel_info.pnt_lst->head; + while(curr != NULL) { /* Check each dimension */ - for(u=0; u<space->extent.rank; u++) { + for(u = 0; u < space->extent.rank; u++) { /* Check if an offset has been defined */ /* Bounds check the selected point + offset against the extent */ - if(((curr->pnt[u]+space->select.offset[u])>space->extent.size[u]) - || (((hssize_t)curr->pnt[u]+space->select.offset[u])<0)) + if(((curr->pnt[u] + (hsize_t)space->select.offset[u]) > space->extent.size[u]) + || (((hssize_t)curr->pnt[u] + space->select.offset[u]) < 0)) HGOTO_DONE(FALSE) } /* end for */ - curr=curr->next; + curr = curr->next; } /* end while */ done: @@ -706,7 +706,7 @@ H5Sget_select_elem_npoints(hid_t spaceid) if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an element selection") - ret_value = H5S_GET_SELECT_NPOINTS(space); + ret_value = (hssize_t)H5S_GET_SELECT_NPOINTS(space); done: FUNC_LEAVE_API(ret_value) @@ -923,34 +923,34 @@ static herr_t H5S_get_select_elem_pointlist(H5S_t *space, hsize_t startpoint, hsize_t numpoints, hsize_t *buf) { H5S_pnt_node_t *node; /* Point node */ - int rank; /* Dataspace rank */ + unsigned rank; /* Dataspace rank */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_get_select_elem_pointlist); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_get_select_elem_pointlist) - assert(space); - assert(buf); + HDassert(space); + HDassert(buf); /* Get the dataspace extent rank */ - rank=space->extent.rank; + rank = space->extent.rank; /* Get the head of the point list */ - node=space->select.sel_info.pnt_lst->head; + node = space->select.sel_info.pnt_lst->head; /* Iterate to the first point to return */ - while(node!=NULL && startpoint>0) { + while(node != NULL && startpoint > 0) { startpoint--; - node=node->next; + node = node->next; } /* end while */ /* Iterate through the node, copying each hyperslab's information */ - while(node!=NULL && numpoints>0) { - HDmemcpy(buf,node->pnt,sizeof(hsize_t)*rank); - buf+=rank; + while(node != NULL && numpoints > 0) { + HDmemcpy(buf, node->pnt, sizeof(hsize_t) * rank); + buf += rank; numpoints--; - node=node->next; + node = node->next; } /* end while */ - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S_get_select_elem_pointlist() */ @@ -1105,7 +1105,6 @@ H5S_point_offset(const H5S_t *space, hsize_t *offset) const hssize_t *sel_offset; /* Pointer to the selection's offset */ const hsize_t *dim_size; /* Pointer to a dataspace's extent */ hsize_t accum; /* Accumulator for dimension sizes */ - int rank; /* Dataspace rank */ int i; /* index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1123,9 +1122,8 @@ H5S_point_offset(const H5S_t *space, hsize_t *offset) dim_size = space->extent.size; /* Loop through coordinates, calculating the linear offset */ - rank = space->extent.rank; accum = 1; - for(i = (rank - 1); i >= 0; i--) { + for(i = (int)space->extent.rank - 1; i >= 0; i--) { hssize_t pnt_offset = (hssize_t)pnt[i] + sel_offset[i]; /* Point's offset in this dimension */ /* Check for offset moving selection out of the dataspace */ @@ -1133,7 +1131,7 @@ H5S_point_offset(const H5S_t *space, hsize_t *offset) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") /* Add the point's offset in this dimension to the total linear offset */ - *offset += pnt_offset * accum; + *offset += (hsize_t)pnt_offset * accum; /* Increase the accumulator */ accum *= dim_size[i]; @@ -1448,9 +1446,9 @@ H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, curr_seq=0; while(node!=NULL) { /* Compute the offset of each selected point in the buffer */ - for(i=ndims-1,acc=iter->elmt_size,loc=0; i>=0; i--) { - loc+=(node->pnt[i]+space->select.offset[i])*acc; - acc*=dims[i]; + for(i = ndims - 1, acc = iter->elmt_size, loc = 0; i >= 0; i--) { + loc += (node->pnt[i] + space->select.offset[i]) * acc; + acc *= dims[i]; } /* end for */ /* Check if this is a later point in the selection */ diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 2a9c4dc..a419131 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -301,7 +301,7 @@ H5Sget_select_npoints(hid_t spaceid) if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - ret_value = H5S_GET_SELECT_NPOINTS(space); + ret_value = (hssize_t)H5S_GET_SELECT_NPOINTS(space); done: FUNC_LEAVE_API(ret_value) @@ -331,12 +331,12 @@ done: hssize_t H5S_get_select_npoints(const H5S_t *space) { - FUNC_ENTER_NOAPI_NOFUNC(H5S_get_select_npoints); + FUNC_ENTER_NOAPI_NOFUNC(H5S_get_select_npoints) /* Check args */ - assert(space); + HDassert(space); - FUNC_LEAVE_NOAPI(space->select.num_elem); + FUNC_LEAVE_NOAPI((hssize_t)space->select.num_elem) } /* H5S_get_select_npoints() */ @@ -1174,7 +1174,7 @@ H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t iter_init = TRUE; /* Selection iteration info has been initialized */ /* Get the number of elements in selection */ - if((nelmts = H5S_GET_SELECT_NPOINTS(space)) < 0) + if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected") /* Get the rank of the dataspace */ @@ -1199,21 +1199,21 @@ H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t /* Loop, while sequences left to process */ for(curr_seq=0; curr_seq<nseq && user_ret==0; curr_seq++) { /* Get the current offset */ - curr_off=off[curr_seq]; + curr_off = off[curr_seq]; /* Get the number of bytes in sequence */ - curr_len=len[curr_seq]; + curr_len = len[curr_seq]; /* Loop, while bytes left in sequence */ - while(curr_len>0 && user_ret==0) { + while(curr_len > 0 && user_ret == 0) { /* Compute the coordinate from the offset */ - for(i=ndims, tmp_off=curr_off; i>=0; i--) { - coords[i]=tmp_off%space_size[i]; - tmp_off/=space_size[i]; + for(i = (int)ndims, tmp_off = curr_off; i >= 0; i--) { + coords[i] = tmp_off % space_size[i]; + tmp_off /= space_size[i]; } /* end for */ /* Get the location within the user's buffer */ - loc=(unsigned char *)buf+curr_off; + loc = (unsigned char *)buf + curr_off; /* Call user's callback routine */ user_ret=(*op)(loc,type_id,ndims,coords,operator_data); @@ -1540,7 +1540,7 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b iter_init = 1; /* Selection iteration info has been initialized */ /* Get the number of elements in selection */ - if((nelmts = H5S_GET_SELECT_NPOINTS(space)) < 0) + if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected") /* Compute the number of bytes to process */ diff --git a/src/H5Stest.c b/src/H5Stest.c index 787cdef..5758263 100644 --- a/src/H5Stest.c +++ b/src/H5Stest.c @@ -103,7 +103,7 @@ H5S_get_rebuild_status_test(hid_t space_id) if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - ret_value = space->select.sel_info.hslab->diminfo_valid; + ret_value = (htri_t)space->select.sel_info.hslab->diminfo_valid; done: FUNC_LEAVE_NOAPI(ret_value) @@ -133,7 +133,7 @@ done: *------------------------------------------------------------------------- */ int -H5Z_term_interface (void) +H5Z_term_interface(void) { #ifdef H5Z_DEBUG size_t i; @@ -141,7 +141,7 @@ H5Z_term_interface (void) char comment[16], bandwidth[32]; #endif - if (H5_interface_initialize_g) { + if(H5_interface_initialize_g) { #ifdef H5Z_DEBUG if (H5DEBUG(Z)) { for (i=0; i<H5Z_table_used_g; i++) { @@ -191,15 +191,16 @@ H5Z_term_interface (void) } #endif /* H5Z_DEBUG */ /* Free the table of filters */ - H5Z_table_g = H5MM_xfree(H5Z_table_g); + H5Z_table_g = (H5Z_class_t *)H5MM_xfree(H5Z_table_g); #ifdef H5Z_DEBUG - H5Z_stat_table_g = H5MM_xfree(H5Z_stat_table_g); + H5Z_stat_table_g = (H5Z_stats_t *)H5MM_xfree(H5Z_stat_table_g); #endif /* H5Z_DEBUG */ H5Z_table_used_g = H5Z_table_alloc_g = 0; H5_interface_initialize_g = 0; - } - return 0; -} + } /* end if */ + + return(0); +} /* end H5Z_term_interface() */ /*------------------------------------------------------------------------- @@ -284,20 +285,18 @@ H5Z_register (const H5Z_class_t *cls) break; /* Filter not already registered */ - if (i>=H5Z_table_used_g) { - if (H5Z_table_used_g>=H5Z_table_alloc_g) { + if(i >= H5Z_table_used_g) { + if(H5Z_table_used_g >= H5Z_table_alloc_g) { size_t n = MAX(H5Z_MAX_NFILTERS, 2*H5Z_table_alloc_g); - H5Z_class_t *table = H5MM_realloc(H5Z_table_g, - n*sizeof(H5Z_class_t)); + H5Z_class_t *table = (H5Z_class_t *)H5MM_realloc(H5Z_table_g, n * sizeof(H5Z_class_t)); #ifdef H5Z_DEBUG - H5Z_stats_t *stat_table = H5MM_realloc(H5Z_stat_table_g, - n*sizeof(H5Z_stats_t)); + H5Z_stats_t *stat_table = (H5Z_stats_t *)H5MM_realloc(H5Z_stat_table_g, n * sizeof(H5Z_stats_t)); #endif /* H5Z_DEBUG */ - if (!table) + if(!table) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter table") H5Z_table_g = table; #ifdef H5Z_DEBUG - if (!stat_table) + if(!stat_table) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter statistics table") H5Z_stat_table_g = stat_table; #endif /* H5Z_DEBUG */ @@ -478,10 +477,10 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Check if the property list is non-default */ if(dcpl_id != H5P_DATASET_CREATE_DEFAULT) { H5P_genplist_t *dc_plist; /* Dataset creation property list object */ - H5D_layout_t dcpl_layout; /* Dataset's layout information */ + H5O_layout_t dcpl_layout; /* Dataset's layout information */ /* Get dataset creation property list object */ - if(NULL == (dc_plist = H5I_object(dcpl_id))) + if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") /* Get layout information */ @@ -489,7 +488,7 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") /* Check if the dataset is chunked */ - if(H5D_CHUNKED == dcpl_layout) { + if(H5D_CHUNKED == dcpl_layout.type) { H5O_pline_t dcpl_pline; /* Dataset's I/O pipeline information */ /* Get I/O pipeline information */ @@ -498,23 +497,15 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Check if the chunks have filters */ if(dcpl_pline.nused > 0) { - unsigned chunk_ndims; /* # of chunk dimensions */ - uint32_t chunk_size[H5O_LAYOUT_NDIMS]; /* Size of chunk dimensions */ hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; /* Size of chunk dimensions */ H5S_t *space; /* Dataspace describing chunk */ hid_t space_id; /* ID for dataspace describing chunk */ size_t u; /* Local index variable */ - /* Get chunk information */ - if(H5P_get(dc_plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve chunk dimensions") - if(H5P_get(dc_plist, H5D_CRT_CHUNK_SIZE_NAME, chunk_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve chunk size") - /* Create a data space for a chunk & set the extent */ - for(u = 0; u < chunk_ndims; u++) - chunk_dims[u] = chunk_size[u]; - if(NULL == (space = H5S_create_simple(chunk_ndims,chunk_dims,NULL))) + for(u = 0; u < dcpl_layout.u.chunk.ndims; u++) + chunk_dims[u] = dcpl_layout.u.chunk.dim[u]; + if(NULL == (space = H5S_create_simple(dcpl_layout.u.chunk.ndims, chunk_dims, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Get ID for dataspace to pass to filter routines */ @@ -547,22 +538,20 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Check if there is a "can apply" callback */ if(fclass->can_apply) { /* Make callback to filter's "can apply" function */ - herr_t status=(fclass->can_apply)(dcpl_id, type_id, space_id); + herr_t status = (fclass->can_apply)(dcpl_id, type_id, space_id); /* Check return value */ - if(status<=0) { + if(status <= 0) { /* We're leaving, so close dataspace */ - if(H5I_dec_ref(space_id, FALSE)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") + if(H5I_dec_ref(space_id, FALSE) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") /* Indicate filter can't apply to this combination of parameters */ - if(status==0) { + if(status == 0) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "filter parameters not appropriate") - } /* end if */ /* Indicate error during filter callback */ - else { + else HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "error during user callback") - } /* end if */ } /* end if */ } /* end if */ break; @@ -727,7 +716,7 @@ H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, /* Allocate memory or point at internal buffer */ if(cd_nelmts > H5Z_COMMON_CD_VALUES) { - pline->filter[idx].cd_values = H5MM_malloc(cd_nelmts * sizeof(unsigned)); + pline->filter[idx].cd_values = (unsigned *)H5MM_malloc(cd_nelmts * sizeof(unsigned)); if(NULL == pline->filter[idx].cd_values) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter parameters") } /* end if */ @@ -799,10 +788,10 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, */ for(n = 0; n < pline->nalloc; ++n) if(pline->filter[n].cd_values == pline->filter[n]._cd_values) - pline->filter[n].cd_values = (void *) ~((size_t)NULL); + pline->filter[n].cd_values = (unsigned *)((void *) ~((size_t)NULL)); x.nalloc = MAX(H5Z_MAX_NFILTERS, 2 * pline->nalloc); - x.filter = H5MM_realloc(pline->filter, x.nalloc * sizeof(x.filter[0])); + x.filter = (H5Z_filter_info_t *)H5MM_realloc(pline->filter, x.nalloc * sizeof(x.filter[0])); if(NULL == x.filter) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter pipeline") @@ -829,7 +818,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, /* Allocate memory or point at internal buffer */ if(cd_nelmts > H5Z_COMMON_CD_VALUES) { - pline->filter[idx].cd_values = H5MM_malloc(cd_nelmts * sizeof(unsigned)); + pline->filter[idx].cd_values = (unsigned *)H5MM_malloc(cd_nelmts * sizeof(unsigned)); if(NULL == pline->filter[idx].cd_values) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter") } /* end if */ @@ -1207,11 +1196,11 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) if(pline->filter[idx].name && pline->filter[idx].name != pline->filter[idx]._name) HDassert((HDstrlen(pline->filter[idx].name) + 1) > H5Z_COMMON_NAME_LEN); if(pline->filter[idx].name != pline->filter[idx]._name) - pline->filter[idx].name = H5MM_xfree(pline->filter[idx].name); + pline->filter[idx].name = (char *)H5MM_xfree(pline->filter[idx].name); if(pline->filter[idx].cd_values && pline->filter[idx].cd_values != pline->filter[idx]._cd_values) HDassert(pline->filter[idx].cd_nelmts > H5Z_COMMON_CD_VALUES); if(pline->filter[idx].cd_values != pline->filter[idx]._cd_values) - pline->filter[idx].cd_values = H5MM_xfree(pline->filter[idx].cd_values); + pline->filter[idx].cd_values = (unsigned *)H5MM_xfree(pline->filter[idx].cd_values); /* Remove filter from pipeline array */ if((idx + 1) < pline->nused) { |