mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-12-03 02:32:04 +08:00
[svn-r2465] Changed nbytes to an hsize_t type since that's what it holds. Also, moved
it into the if-then statement to limit it's scope.
This commit is contained in:
parent
15dfa78cd8
commit
b1b1b74b38
@ -573,8 +573,7 @@ static herr_t
|
|||||||
H5FD_core_read(H5FD_t *_file, hid_t UNUSED dxpl_id, haddr_t addr,
|
H5FD_core_read(H5FD_t *_file, hid_t UNUSED dxpl_id, haddr_t addr,
|
||||||
hsize_t size, void *buf/*out*/)
|
hsize_t size, void *buf/*out*/)
|
||||||
{
|
{
|
||||||
H5FD_core_t *file = (H5FD_core_t*)_file;
|
H5FD_core_t *file = (H5FD_core_t*)_file;
|
||||||
ssize_t nbytes;
|
|
||||||
|
|
||||||
FUNC_ENTER(H5FD_core_read, FAIL);
|
FUNC_ENTER(H5FD_core_read, FAIL);
|
||||||
|
|
||||||
@ -582,24 +581,25 @@ H5FD_core_read(H5FD_t *_file, hid_t UNUSED dxpl_id, haddr_t addr,
|
|||||||
assert(buf);
|
assert(buf);
|
||||||
|
|
||||||
/* Check for overflow conditions */
|
/* Check for overflow conditions */
|
||||||
if (HADDR_UNDEF==addr)
|
if (HADDR_UNDEF == addr)
|
||||||
HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
|
HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
|
||||||
if (REGION_OVERFLOW(addr, size))
|
if (REGION_OVERFLOW(addr, size))
|
||||||
HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
|
HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
|
||||||
if (addr+size>file->eoa)
|
if (addr + size > file->eoa)
|
||||||
HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
|
HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
|
||||||
|
|
||||||
/* Read the part which is before the EOF marker */
|
/* Read the part which is before the EOF marker */
|
||||||
if (addr<file->eof) {
|
if (addr < file->eof) {
|
||||||
nbytes = MIN(size, file->eof-addr);
|
hsize_t nbytes = MIN(size, file->eof-addr);
|
||||||
memcpy(buf, file->mem+addr, nbytes);
|
|
||||||
|
memcpy(buf, file->mem + addr, nbytes);
|
||||||
size -= nbytes;
|
size -= nbytes;
|
||||||
addr += nbytes;
|
addr += nbytes;
|
||||||
buf = (char*)buf + nbytes;
|
buf = (char *)buf + nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read zeros for the part which is after the EOF markers */
|
/* Read zeros for the part which is after the EOF markers */
|
||||||
if (size>0)
|
if (size > 0)
|
||||||
memset(buf, 0, size);
|
memset(buf, 0, size);
|
||||||
|
|
||||||
FUNC_LEAVE(SUCCEED);
|
FUNC_LEAVE(SUCCEED);
|
||||||
|
Loading…
Reference in New Issue
Block a user