summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-06-17 00:59:12 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-06-17 00:59:12 (GMT)
commite05933f2454b16a4ce8148c2a0ebcee790d4d8c0 (patch)
tree0e9acd150c491838c446a1e7a1c8dc94cdd36b6b /src
parent41b80569d76de56169e1a71a0e8f407d8ed46c09 (diff)
downloadhdf5-e05933f2454b16a4ce8148c2a0ebcee790d4d8c0.zip
hdf5-e05933f2454b16a4ce8148c2a0ebcee790d4d8c0.tar.gz
hdf5-e05933f2454b16a4ce8148c2a0ebcee790d4d8c0.tar.bz2
[svn-r17062] Description:
Correct error in calculation of the new metadata accumulator size when block to write overlaps beginning of accumulator. Tested on: FreeBSD/32 6.3 (duty) Mac OS X/32 10.5.7 (amazon)
Diffstat (limited to 'src')
-rw-r--r--src/H5Faccum.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/H5Faccum.c b/src/H5Faccum.c
index 8e5ea4a..9529e0c 100644
--- a/src/H5Faccum.c
+++ b/src/H5Faccum.c
@@ -207,7 +207,7 @@ H5F_accum_read(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr,
size_t new_size; /* New size of accumulator */
/* Adjust the buffer size to be a power of 2 that is large enough to hold data */
- new_size = (size_t)1 << (1 + H5V_log2_gen(size - 1));
+ new_size = (size_t)1 << (1 + H5V_log2_gen((uint64_t)(size - 1)));
/* Grow the metadata accumulator buffer */
if(NULL == (f->shared->accum.buf = H5FL_BLK_REALLOC(meta_accum, f->shared->accum.buf, new_size)))
@@ -290,7 +290,7 @@ H5F_accum_adjust(H5F_meta_accum_t *accum, H5FD_t *lf, hid_t dxpl_id,
size_t new_size; /* New size of accumulator */
/* Adjust the buffer size to be a power of 2 that is large enough to hold data */
- new_size = (size_t)1 << (1 + H5V_log2_gen((size + accum->size) - 1));
+ new_size = (size_t)1 << (1 + H5V_log2_gen((uint64_t)((size + accum->size) - 1)));
/* Check for accumulator getting too big */
if(new_size > H5F_ACCUM_MAX_SIZE) {
@@ -432,7 +432,7 @@ H5F_accum_write(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr,
} /* end if */
/* Check if the piece of metadata being written overlaps the metadata accumulator */
else if(H5F_addr_overlap(addr, size, f->shared->accum.loc, f->shared->accum.size)) {
- size_t new_size; /* New size of the accumulator buffer */
+ size_t add_size; /* New size of the accumulator buffer */
/* Check if the new metadata is entirely within the current accumulator */
if(addr >= f->shared->accum.loc && (addr + size) <= (f->shared->accum.loc + f->shared->accum.size)) {
@@ -446,11 +446,11 @@ H5F_accum_write(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr,
else if(addr < f->shared->accum.loc && (addr + size) <= (f->shared->accum.loc + f->shared->accum.size)) {
size_t old_offset; /* Offset of old data within the accumulator buffer */
- /* Calculate the new accumulator size, based on the amount of overlap */
- H5_ASSIGN_OVERFLOW(new_size, (f->shared->accum.loc - addr) + f->shared->accum.size, hsize_t, size_t);
+ /* Calculate the amount we will need to add to the accumulator size, based on the amount of overlap */
+ H5_ASSIGN_OVERFLOW(add_size, (f->shared->accum.loc - addr), hsize_t, size_t);
/* Check if we need to adjust accumulator size */
- if(H5F_accum_adjust(&f->shared->accum, f->shared->lf, dxpl_id, H5F_ACCUM_PREPEND, (new_size - f->shared->accum.size)) < 0)
+ if(H5F_accum_adjust(&f->shared->accum, f->shared->lf, dxpl_id, H5F_ACCUM_PREPEND, add_size) < 0)
HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator")
/* Calculate the proper offset of the existing metadata */
@@ -464,25 +464,25 @@ H5F_accum_write(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr,
/* Set the new size & location of the metadata accumulator */
f->shared->accum.loc = addr;
- f->shared->accum.size = new_size;
+ f->shared->accum.size += add_size;
/* Mark it as written to */
f->shared->accum.dirty = TRUE;
} /* end if */
/* Check if the new metadata overlaps the end of the current accumulator */
else if(addr >= f->shared->accum.loc && (addr + size) > (f->shared->accum.loc + f->shared->accum.size)) {
- /* Calculate the new accumulator size, based on the amount of overlap */
- H5_ASSIGN_OVERFLOW(new_size, (addr - f->shared->accum.loc) + size, hsize_t, size_t);
+ /* Calculate the amount we will need to add to the accumulator size, based on the amount of overlap */
+ H5_ASSIGN_OVERFLOW(add_size, (addr + size) - (f->shared->accum.loc + f->shared->accum.size), hsize_t, size_t);
/* Check if we need to adjust accumulator size */
- if(H5F_accum_adjust(&f->shared->accum, f->shared->lf, dxpl_id, H5F_ACCUM_APPEND, (new_size - f->shared->accum.size)) < 0)
+ if(H5F_accum_adjust(&f->shared->accum, f->shared->lf, dxpl_id, H5F_ACCUM_APPEND, add_size) < 0)
HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator")
/* Copy the new metadata to the end */
HDmemcpy(f->shared->accum.buf + (addr - f->shared->accum.loc), buf, size);
- /* Set the new size & location of the metadata accumulator */
- f->shared->accum.size = new_size;
+ /* Set the new size of the metadata accumulator */
+ f->shared->accum.size += add_size;
/* Mark it as written to */
f->shared->accum.dirty = TRUE;
@@ -508,7 +508,7 @@ H5F_accum_write(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr,
size_t new_size; /* New size of accumulator */
/* Adjust the buffer size to be a power of 2 that is large enough to hold data */
- new_size = (size_t)1 << (1 + H5V_log2_gen(size - 1));
+ new_size = (size_t)1 << (1 + H5V_log2_gen((uint64_t)(size - 1)));
/* Grow the metadata accumulator buffer */
if(NULL == (f->shared->accum.buf = H5FL_BLK_REALLOC(meta_accum, f->shared->accum.buf, new_size)))
@@ -554,7 +554,7 @@ HDmemset(f->shared->accum.buf + clear_size, 0, (f->shared->accum.alloc_size - cl
size_t new_size; /* New size of accumulator */
/* Adjust the buffer size to be a power of 2 that is large enough to hold data */
- new_size = (size_t)1 << (1 + H5V_log2_gen(size - 1));
+ new_size = (size_t)1 << (1 + H5V_log2_gen((uint64_t)(size - 1)));
/* Reallocate the metadata accumulator buffer */
if(NULL == (f->shared->accum.buf = H5FL_BLK_REALLOC(meta_accum, f->shared->accum.buf, new_size)))