summaryrefslogtreecommitdiffstats
path: root/src/H5Oefl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Oefl.c')
-rw-r--r--src/H5Oefl.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index 26cb732..451efbe 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -407,7 +407,12 @@ H5O_efl_read (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
size_t size, uint8_t *buf)
{
int i, fd=-1;
- size_t to_read, cur, skip=0;
+ size_t to_read;
+#ifndef NDEBUG
+ hsize_t tempto_read;
+#endif /* NDEBUG */
+ hsize_t skip;
+ haddr_t cur;
ssize_t n;
herr_t ret_value = FAIL;
@@ -422,11 +427,11 @@ H5O_efl_read (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
/* Find the first efl member from which to read */
for (i=0, cur=0; i<efl->nused; i++) {
if (H5O_EFL_UNLIMITED==efl->slot[i].size ||
- addr < cur+efl->slot[i].size) {
+ addr < cur+efl->slot[i].size) {
skip = addr - cur;
break;
}
- cur += efl->slot[i].size;
+ cur += efl->slot[i].size;
}
/* Read the data */
@@ -435,7 +440,7 @@ H5O_efl_read (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL,
"read past logical end of file");
}
- if (H5F_OVERFLOW_SIZET2OFFT (efl->slot[i].offset+skip)) {
+ if (H5F_OVERFLOW_HSIZET2OFFT (efl->slot[i].offset+skip)) {
HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL,
"external file address overflowed");
}
@@ -447,7 +452,13 @@ H5O_efl_read (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
HGOTO_ERROR (H5E_EFL, H5E_SEEKERROR, FAIL,
"unable to seek in external raw data file");
}
- to_read = MIN(efl->slot[i].size-skip, size);
+#ifndef NDEBUG
+ tempto_read = MIN(efl->slot[i].size-skip,(hsize_t)size);
+ H5_CHECK_OVERFLOW(tempto_read,hsize_t,size_t);
+ to_read = (size_t)tempto_read;
+#else /* NDEBUG */
+ to_read = MIN((size_t)(efl->slot[i].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");
@@ -492,7 +503,12 @@ H5O_efl_write (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
size_t size, const uint8_t *buf)
{
int i, fd=-1;
- size_t to_write, cur, skip=0;
+ size_t to_write;
+#ifndef NDEBUG
+ hsize_t tempto_write;
+#endif /* NDEBUG */
+ haddr_t cur;
+ hsize_t skip;
herr_t ret_value = FAIL;
FUNC_ENTER (H5O_efl_write, FAIL);
@@ -506,7 +522,7 @@ H5O_efl_write (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
/* Find the first efl member in which to write */
for (i=0, cur=0; i<efl->nused; i++) {
if (H5O_EFL_UNLIMITED==efl->slot[i].size ||
- addr < cur+efl->slot[i].size) {
+ addr < cur+efl->slot[i].size) {
skip = addr - cur;
break;
}
@@ -519,7 +535,7 @@ H5O_efl_write (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL,
"write past logical end of file");
}
- if (H5F_OVERFLOW_SIZET2OFFT (efl->slot[i].offset+skip)) {
+ if (H5F_OVERFLOW_HSIZET2OFFT (efl->slot[i].offset+skip)) {
HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL,
"external file address overflowed");
}
@@ -536,7 +552,13 @@ H5O_efl_write (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
HGOTO_ERROR (H5E_EFL, H5E_SEEKERROR, FAIL,
"unable to seek in external raw data file");
}
- to_write = MIN(efl->slot[i].size-skip, size);
+#ifndef NDEBUG
+ tempto_write = MIN(efl->slot[i].size-skip,(hsize_t)size);
+ H5_CHECK_OVERFLOW(tempto_write,hsize_t,size_t);
+ to_write = (size_t)tempto_write;
+#else /* NDEBUG */
+ to_write = MIN((size_t)(efl->slot[i].size-skip), size);
+#endif /* NDEBUG */
if ((size_t)HDwrite (fd, buf, to_write)!=to_write) {
HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL,
"write error in external raw data file");