From 41aeac45047cd5a18b7862e6138b9e886c5634ed Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 18 Feb 2015 13:25:05 -0500 Subject: [svn-r26213] Description: Minor code cleanups, to align with revise_chunks branch. Tested on: Mac OSX/64 10.10.2 (amazon) w/serial & parallel Linux/32 2.6.x (jam) w/serial --- src/H5Dchunk.c | 126 +++++++++++++++++++++++++-------------------------------- src/H5Dint.c | 28 +++++++------ src/H5Dio.c | 10 ++--- 3 files changed, 76 insertions(+), 88 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 46f0a4f..9f2a020 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -318,24 +318,22 @@ H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, hsiz uint32_t data_size, const void *buf) { const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ - H5D_chunk_ud_t udata; /* User data for querying chunk info */ + H5D_chunk_ud_t udata; /* User data for querying chunk info */ hsize_t chunk_idx; H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */ const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ int space_ndims; /* Dataset's space rank */ hsize_t space_dim[H5O_LAYOUT_NDIMS]; /* Dataset's dataspace dimensions */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(dxpl_id, dset->oloc.addr, FAIL) /* Allocate data space and initialize it if it hasn't been. */ - if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { + if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) /* Allocate storage */ if(H5D__alloc_storage(dset, dxpl_id, H5D_ALLOC_WRITE, FALSE, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage") - } /* end if */ - /* Retrieve the dataset dimensions */ if((space_ndims = H5S_get_simple_extent_dims(dset->shared->space, space_dim, NULL)) < 0) @@ -385,11 +383,9 @@ H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, hsiz /* Evict the entry from the cache if present, but do not flush * it to disk */ - if(UINT_MAX != udata.idx_hint) { - if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, - rdcc->slot[udata.idx_hint], FALSE) < 0) + if(UINT_MAX != udata.idx_hint) + if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, rdcc->slot[udata.idx_hint], FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk") - } /* end if */ /* Write the data to the file */ if(H5F_block_write(dset->oloc.file, H5FD_MEM_DRAW, udata.addr, data_size, dxpl_id, buf) < 0) @@ -1317,13 +1313,12 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t new_chunk_info->mspace_shared = FALSE; /* Copy the chunk's coordinates */ - for(u=0; uf_ndims; u++) - new_chunk_info->coords[u]=coords[u]; - new_chunk_info->coords[fm->f_ndims]=0; + HDmemcpy(new_chunk_info->coords, coords, sizeof(hsize_t) * fm->f_ndims); + new_chunk_info->coords[fm->f_ndims] = 0; /* Insert the new chunk into the skip list */ if(H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) { - H5D__free_chunk_info(new_chunk_info, NULL, NULL); + H5D__free_chunk_info(new_chunk_info, NULL, NULL); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert chunk into skip list") } /* end if */ @@ -1508,7 +1503,7 @@ H5D__chunk_file_cb(void UNUSED *elem, hid_t UNUSED type_id, unsigned ndims, cons H5D_chunk_file_iter_ud_t *udata = (H5D_chunk_file_iter_ud_t *)_udata; /* User data for operation */ H5D_chunk_map_t *fm = udata->fm; /* File<->memory chunk mapping info */ H5D_chunk_info_t *chunk_info; /* Chunk information for current chunk */ - hsize_t coords_in_chunk[H5O_LAYOUT_NDIMS]; /* Coordinates of element in chunk */ + hsize_t coords_in_chunk[H5O_LAYOUT_NDIMS]; /* Coordinates of element in chunk */ hsize_t chunk_index; /* Chunk index */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2238,8 +2233,6 @@ H5D__chunk_cinfo_cache_reset(H5D_chunk_cached_t *last) static herr_t H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *udata) { - unsigned u; /* Local index variable */ - FUNC_ENTER_STATIC_NOERR /* Sanity check */ @@ -2250,8 +2243,7 @@ H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *ud HDassert(udata->common.offset); /* Stored the information to cache */ - for(u = 0; u < udata->common.layout->ndims; u++) - last->offset[u] = udata->common.offset[u]; + HDmemcpy(last->offset, udata->common.offset, sizeof(hsize_t) * udata->common.layout->ndims); last->nbytes = udata->nbytes; last->filter_mask = udata->filter_mask; last->addr = udata->addr; @@ -2820,7 +2812,6 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, haddr_t chunk_addr = HADDR_UNDEF; /* Address of chunk on disk */ size_t chunk_size; /*size of a chunk */ void *chunk = NULL; /*the file chunk */ - unsigned u; /*counters */ void *ret_value; /*return value */ FUNC_ENTER_PACKAGE @@ -2846,9 +2837,13 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, ent = rdcc->slot[udata->idx_hint]; #ifndef NDEBUG +{ + unsigned u; /*counters */ + /* Make sure this is the right chunk */ for(u = 0; u < layout->u.chunk.ndims; u++) HDassert(io_info->store->chunk.offset[u] == ent->offset[u]); +} #endif /* NDEBUG */ /* @@ -2990,15 +2985,12 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk(s) from cache") /* Create a new entry */ - if(NULL == (ent = H5FL_MALLOC(H5D_rdcc_ent_t))) + if(NULL == (ent = H5FL_CALLOC(H5D_rdcc_ent_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate raw data chunk entry") - ent->locked = 0; - ent->dirty = FALSE; - ent->deleted = FALSE; + /* Initialize the new entry */ ent->chunk_addr = chunk_addr; - for(u = 0; u < layout->u.chunk.ndims; u++) - ent->offset[u] = io_info->store->chunk.offset[u]; + HDmemcpy(ent->offset, io_info->store->chunk.offset, sizeof(hsize_t) * layout->u.chunk.ndims); H5_ASSIGN_OVERFLOW(ent->rd_count, chunk_size, size_t, uint32_t); H5_ASSIGN_OVERFLOW(ent->wr_count, chunk_size, size_t, uint32_t); ent->chunk = (uint8_t *)chunk; @@ -3011,16 +3003,13 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, rdcc->nused++; /* Add it to the linked list */ - ent->next = NULL; if(rdcc->tail) { rdcc->tail->next = ent; ent->prev = rdcc->tail; rdcc->tail = ent; } /* end if */ - else { + else rdcc->head = rdcc->tail = ent; - ent->prev = NULL; - } /* end else */ } /* end if */ else /* We did not add the chunk to cache */ @@ -3413,8 +3402,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, continue; else { /* Reset the chunk offset indices */ - HDmemset(chunk_offset, 0, ((unsigned)space_ndims - * sizeof(chunk_offset[0]))); + HDmemset(chunk_offset, 0, ((unsigned)space_ndims * sizeof(chunk_offset[0]))); chunk_offset[op_dim] = min_unalloc[op_dim]; carry = FALSE; @@ -3444,10 +3432,12 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, /* Make sure the chunk is really in the dataset and outside the * original dimensions */ { + unsigned u; /* Local index variable */ hbool_t outside_orig = FALSE; - for(i=0; i= old_dim[i]) + + for(u = 0; u < (unsigned)space_ndims; u++) { + HDassert(chunk_offset[u] < space_dim[u]); + if(chunk_offset[u] >= old_dim[u]) outside_orig = TRUE; } /* end for */ HDassert(outside_orig); @@ -3546,13 +3536,14 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, /* Increment indices */ carry = TRUE; - for(i = (int)(space_ndims - 1); i >= 0; --i) { + for(i = ((int)space_ndims - 1); i >= 0; --i) { chunk_offset[i] += chunk_dim[i]; - if(chunk_offset[i] > max_unalloc[i]) + if(chunk_offset[i] > max_unalloc[i]) { if(i == op_dim) chunk_offset[i] = min_unalloc[i]; else chunk_offset[i] = 0; + } /* end if */ else { carry = FALSE; break; @@ -4006,7 +3997,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) hsize_t hyper_start[H5O_LAYOUT_NDIMS]; /* Starting location of hyperslab */ uint32_t elmts_per_chunk; /* Elements in chunk */ hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ - int i; /* Local index variable */ + unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -4043,15 +4034,14 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) /* (also copy the chunk dimensions into 'hsize_t' array for creating dataspace) */ /* (also compute the dimensions which have been shrunk) */ elmts_per_chunk = 1; - for(i = 0; i < space_ndims; i++) { - elmts_per_chunk *= layout->u.chunk.dim[i]; - chunk_dim[i] = layout->u.chunk.dim[i]; - shrunk_dim[i] = space_dim[i] < old_dim[i]; + for(u = 0; u < (unsigned)space_ndims; u++) { + elmts_per_chunk *= layout->u.chunk.dim[u]; + chunk_dim[u] = layout->u.chunk.dim[u]; + shrunk_dim[u] = space_dim[u] < old_dim[u]; } /* end for */ /* Create a dataspace for a chunk & set the extent */ - if(NULL == (chunk_space = H5S_create_simple((unsigned)space_ndims, - chunk_dim, NULL))) + if(NULL == (chunk_space = H5S_create_simple((unsigned)space_ndims, chunk_dim, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Reset hyperslab start array */ @@ -4118,8 +4108,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) / chunk_dim[op_dim]); /* Determine if we need to fill chunks in this dimension */ - if((hssize_t)min_mod_chunk_off[op_dim] - == max_fill_chunk_off[op_dim]) { + if((hssize_t)min_mod_chunk_off[op_dim] == max_fill_chunk_off[op_dim]) { fill_dim[op_dim] = TRUE; has_fill = TRUE; } /* end if */ @@ -4136,8 +4125,8 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) if(has_fill) for(ent = rdcc->head; ent; ent = ent->next) /* Check for chunk offset outside of new dimensions */ - for(i = 0; ioffset[i] >= space_dim[i]) { + for(u = 0; u < (unsigned)space_ndims; u++) + if((hsize_t)ent->offset[u] >= space_dim[u]) { /* Mark the entry as "deleted" */ ent->deleted = TRUE; break; @@ -4149,28 +4138,28 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) if(!shrunk_dim[op_dim]) continue; else { - HDassert((hsize_t) max_mod_chunk_off[op_dim] - >= min_mod_chunk_off[op_dim]); + HDassert((hsize_t) max_mod_chunk_off[op_dim] >= min_mod_chunk_off[op_dim]); /* Reset the chunk offset indices */ - HDmemset(chunk_offset, 0, ((unsigned)space_ndims - * sizeof(chunk_offset[0]))); + HDmemset(chunk_offset, 0, ((unsigned)space_ndims * sizeof(chunk_offset[0]))); chunk_offset[op_dim] = min_mod_chunk_off[op_dim]; /* Initialize "dims_outside_fill" array */ ndims_outside_fill = 0; - for(i=0; i max_fill_chunk_off[i]) { - dims_outside_fill[i] = TRUE; + for(u = 0; u < (unsigned)space_ndims; u++) + if((hssize_t)chunk_offset[u] > max_fill_chunk_off[u]) { + dims_outside_fill[u] = TRUE; ndims_outside_fill++; } /* end if */ else - dims_outside_fill[i] = FALSE; + dims_outside_fill[u] = FALSE; carry = FALSE; } /* end if */ while(!carry) { + int i; /* Local index variable */ + /* Calculate the index of this chunk */ if(H5VM_chunk_index((unsigned)space_ndims, chunk_offset, layout->u.chunk.dim, layout->u.chunk.down_chunks, @@ -4191,8 +4180,8 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) { hbool_t outside_dim = FALSE; - for(i=0; i= space_dim[i]){ + for(u = 0; u < (unsigned)space_ndims; u++) + if(chunk_offset[u] >= space_dim[u]) { outside_dim = TRUE; break; } /* end if */ @@ -4206,11 +4195,9 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) /* Evict the entry from the cache if present, but do not flush * it to disk */ - if(UINT_MAX != chk_udata.idx_hint) { - if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, - rdcc->slot[chk_udata.idx_hint], FALSE) < 0) + if(UINT_MAX != chk_udata.idx_hint) + if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, rdcc->slot[chk_udata.idx_hint], FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk") - } /* end if */ /* Remove the chunk from disk, if present */ if(H5F_addr_defined(chk_udata.addr)) { @@ -4218,8 +4205,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) idx_udata.offset = chunk_offset; /* Remove the chunk from disk */ - if((layout->storage.u.chunk.ops->remove)(&idx_info, &idx_udata) - < 0) + if((layout->storage.u.chunk.ops->remove)(&idx_info, &idx_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to remove chunk entry from index") } /* end if */ } /* end else */ @@ -4248,8 +4234,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) } /* end if */ else { /* Check if we just went outside the fill dimension */ - if(!dims_outside_fill[i] && (hssize_t)chunk_offset[i] - > max_fill_chunk_off[i]) { + if(!dims_outside_fill[i] && (hssize_t)chunk_offset[i] > max_fill_chunk_off[i]) { dims_outside_fill[i] = TRUE; ndims_outside_fill++; } /* end if */ @@ -4267,8 +4252,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) if(min_mod_chunk_off[op_dim] == 0) break; else - max_mod_chunk_off[op_dim] = min_mod_chunk_off[op_dim] - - chunk_dim[op_dim]; + max_mod_chunk_off[op_dim] = min_mod_chunk_off[op_dim] - chunk_dim[op_dim]; } /* end for(op_dim=0...) */ /* Reset any cached chunk info for this dataset */ @@ -4278,10 +4262,9 @@ done: /* Release resources */ if(chunk_space && H5S_close(chunk_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") - if(udata_init) { + if(udata_init) if(udata.fb_info_init && H5D__fill_term(&udata.fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_prune_by_extent() */ @@ -4473,7 +4456,7 @@ H5D__chunk_update_cache(H5D_t *dset, hid_t dxpl_id) H5D_rdcc_ent_t *old_ent; /* Old cache entry */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */ - unsigned rank; /*current # of dimensions */ + unsigned rank; /* Current # of dimensions */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -5178,7 +5161,8 @@ H5D__chunk_dest(H5F_t *f, hid_t dxpl_id, H5D_t *dset) idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Free any index structures */ - if((dset->shared->layout.storage.u.chunk.ops->dest)(&idx_info) < 0) + if(dset->shared->layout.storage.u.chunk.ops->dest && + (dset->shared->layout.storage.u.chunk.ops->dest)(&idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") done: diff --git a/src/H5Dint.c b/src/H5Dint.c index ee346f3..8e1fcec 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -478,7 +478,6 @@ done: herr_t H5D__get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id) { - H5S_t *space; /* Dataset's dataspace */ hsize_t space_allocated; /* The number of bytes allocated for chunks */ hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ hsize_t nelmts; /* Number of elements in dataspace */ @@ -491,11 +490,10 @@ H5D__get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id HDassert(dset); /* Get the dataset's dataspace */ - space = dset->shared->space; - HDassert(space); + HDassert(dset->shared->space); /* Get the total number of elements in dataset's dataspace */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(space)) < 0) + if((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace") nelmts = (hsize_t)snelmts; @@ -1185,6 +1183,7 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id, hid_t dxpl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment object count") } /* end else */ + /* Set the dataset to return */ ret_value = dataset; done: @@ -1226,6 +1225,7 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) H5O_fill_t *fill_prop; /* Pointer to dataset's fill value info */ unsigned alloc_time_state; /* Allocation time state */ htri_t msg_exists; /* Whether a particular type of message exists */ + hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(dxpl_id, dataset->oloc.addr, FAIL) @@ -1263,6 +1263,9 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) if(H5D__layout_oh_read(dataset, dxpl_id, dapl_id, plist) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get layout/pline/efl info") + /* Indicate that the layout information was initialized */ + layout_init = TRUE; + /* Point at dataset's copy, to cache it for later */ fill_prop = &dataset->shared->dcpl_cache.fill; @@ -1338,6 +1341,9 @@ done: if(H5F_addr_defined(dataset->oloc.addr) && H5O_close(&(dataset->oloc)) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header") if(dataset->shared) { + if(dataset->shared->layout.type == H5D_CHUNKED && layout_init) + if(H5D__chunk_dest(dataset->oloc.file, dxpl_id, dataset) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache") if(dataset->shared->space && H5S_close(dataset->shared->space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") if(dataset->shared->type) { @@ -2212,6 +2218,7 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) */ /* Update the index values for the cached chunks for this dataset */ if(H5D_CHUNKED == dset->shared->layout.type) { + /* Update the cached chunk info */ if(H5D__chunk_set_info(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to update # of chunks") if(H5D__chunk_update_cache(dset, dxpl_id) < 0) @@ -2230,11 +2237,10 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) *------------------------------------------------------------------------- */ if(shrink && H5D_CHUNKED == dset->shared->layout.type && - (*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { + (*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) /* Remove excess chunks */ if(H5D__chunk_prune_by_extent(dset, dxpl_id, curr_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to remove chunks") - } /* end if */ /* Mark the dataspace as dirty, for later writing to the file */ if(H5D__mark(dset, dxpl_id, H5D_MARK_SPACE) < 0) @@ -2667,16 +2673,14 @@ H5D_get_space(H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get data space") /* Create an atom */ - if((ret_value = H5I_register (H5I_DATASPACE, space, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space") + if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace") done: - if(ret_value < 0) { - if(space!=NULL) { + if(ret_value < 0) + if(space != NULL) if(H5S_close(space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") - } /* end if */ - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_get_space() */ diff --git a/src/H5Dio.c b/src/H5Dio.c index 096a211..88f75b1 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -305,7 +305,7 @@ H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id, int ndims = 0; hsize_t dims[H5O_LAYOUT_NDIMS]; hsize_t internal_offset[H5O_LAYOUT_NDIMS]; - int i; + unsigned u; /* Get the dataset transfer property list */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) @@ -327,16 +327,16 @@ H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id, if((ndims = H5S_get_simple_extent_dims(dset->shared->space, dims, NULL)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve dataspace extent dims") - for(i = 0; i < ndims; i++) { + for(u = 0; u < ndims; u++) { /* Make sure the offset doesn't exceed the dataset's dimensions */ - if(direct_offset[i] > dims[i]) + if(direct_offset[u] > dims[u]) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset exceeds dimensions of dataset") /* Make sure the offset fall right on a chunk's boundary */ - if(direct_offset[i] % dset->shared->layout.u.chunk.dim[i]) + if(direct_offset[u] % dset->shared->layout.u.chunk.dim[u]) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset doesn't fall on chunks's boundary") - internal_offset[i] = direct_offset[i]; + internal_offset[u] = direct_offset[u]; } /* end for */ /* Terminate the offset with a zero */ -- cgit v0.12