summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2012-03-13 04:19:46 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2012-03-13 04:19:46 (GMT)
commitc17a5d1278a43efc8b62c718f5897e4ec1ed82e9 (patch)
treeecbb6277dc6e40f442eac1ded3d0e02fd92fef92 /src
parent57295db6c750b6c8d148652b826d3a006f38e6aa (diff)
downloadhdf5-c17a5d1278a43efc8b62c718f5897e4ec1ed82e9.zip
hdf5-c17a5d1278a43efc8b62c718f5897e4ec1ed82e9.tar.gz
hdf5-c17a5d1278a43efc8b62c718f5897e4ec1ed82e9.tar.bz2
[svn-r22058] Description:
Better fix for zero-sized dataset error (r22053). Tested on: Mac OSX/64 10.7.3 (amazon) w/debug & parallel
Diffstat (limited to 'src')
-rw-r--r--src/H5Dcontig.c7
-rw-r--r--src/H5Dint.c17
-rw-r--r--src/H5Ocopy.c3
-rw-r--r--src/H5Olayout.c10
4 files changed, 24 insertions, 13 deletions
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index bb10b77..674582d 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -494,11 +494,8 @@ H5D_contig_is_space_alloc(const H5O_storage_t *storage)
/* Sanity checks */
HDassert(storage);
- /* Set return value, indicating space is allocated when size is zero */
- if(0 == storage->u.contig.size)
- ret_value = TRUE;
- else
- ret_value = (hbool_t)H5F_addr_defined(storage->u.contig.addr);
+ /* Set return value */
+ ret_value = (hbool_t)H5F_addr_defined(storage->u.contig.addr);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_contig_is_space_alloc() */
diff --git a/src/H5Dint.c b/src/H5Dint.c
index f105e0a..9a80bfc 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -1596,15 +1596,20 @@ H5D_alloc_storage(H5D_t *dset/*in,out*/, hid_t dxpl_id, H5D_time_alloc_t time_al
switch(layout->type) {
case H5D_CONTIGUOUS:
if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) {
- /* Reserve space in the file for the entire array */
- if(H5D_contig_alloc(f, dxpl_id, &layout->storage.u.contig/*out*/) < 0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize contiguous storage")
+ /* Check if we have a zero-sized dataset */
+ if(layout->storage.u.contig.size > 0) {
+ /* Reserve space in the file for the entire array */
+ if(H5D_contig_alloc(f, dxpl_id, &layout->storage.u.contig/*out*/) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize contiguous storage")
+
+ /* Indicate that we should initialize storage space */
+ must_init_space = TRUE;
+ } /* end if */
+ else
+ layout->storage.u.contig.addr = HADDR_UNDEF;
/* Indicate that we set the storage addr */
addr_set = TRUE;
-
- /* Indicate that we should initialize storage space */
- must_init_space = TRUE;
} /* end if */
break;
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index 337287d..dd649ff 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -974,8 +974,7 @@ H5O_copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
HGOTO_ERROR(H5E_SLIST, H5E_CANTCREATE, FAIL, "cannot make skip list")
/* copy the object from the source file to the destination file */
- if(H5O_copy_header_real(oloc_src, oloc_dst, dxpl_id, &cpy_info, NULL, NULL)
- < 0)
+ if(H5O_copy_header_real(oloc_src, oloc_dst, dxpl_id, &cpy_info, NULL, NULL) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
done:
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index e4d6486..1b17bff 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -241,6 +241,8 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
mesg->ops = H5D_LOPS_CHUNK;
break;
+ case H5D_LAYOUT_ERROR:
+ case H5D_NLAYOUTS:
default:
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid layout class")
} /* end switch */
@@ -342,6 +344,8 @@ H5O_layout_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const voi
UINT32ENCODE(p, mesg->u.chunk.dim[u]);
break;
+ case H5D_LAYOUT_ERROR:
+ case H5D_NLAYOUTS:
default:
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "Invalid layout class")
} /* end switch */
@@ -556,6 +560,8 @@ H5O_layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data")
break;
+ case H5D_LAYOUT_ERROR:
+ case H5D_NLAYOUTS:
default:
HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "not valid storage type")
} /* end switch */
@@ -641,6 +647,8 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
} /* end if */
break;
+ case H5D_LAYOUT_ERROR:
+ case H5D_NLAYOUTS:
default:
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid layout class")
} /* end switch */
@@ -737,6 +745,8 @@ H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg,
"Data Size:", mesg->storage.u.compact.size);
break;
+ case H5D_LAYOUT_ERROR:
+ case H5D_NLAYOUTS:
default:
HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth,
"Type:", "Unknown", (unsigned)mesg->type);