summaryrefslogtreecommitdiffstats
path: root/src/H5FDint.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2018-09-21 19:12:05 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2018-09-21 19:12:05 (GMT)
commit265652fe5466dc9e30d7bdf60a24a355852f0bfe (patch)
tree77320e2059f5ab2ba737e0cf5ab7eb6a09dc47f7 /src/H5FDint.c
parent1c8916ca0e9fe3447efe205094a2b5d3d5ccf8f6 (diff)
downloadhdf5-265652fe5466dc9e30d7bdf60a24a355852f0bfe.zip
hdf5-265652fe5466dc9e30d7bdf60a24a355852f0bfe.tar.gz
hdf5-265652fe5466dc9e30d7bdf60a24a355852f0bfe.tar.bz2
Normalization with vol_integration (property lists, file drivers,
other misc).
Diffstat (limited to 'src/H5FDint.c')
-rw-r--r--src/H5FDint.c167
1 files changed, 72 insertions, 95 deletions
diff --git a/src/H5FDint.c b/src/H5FDint.c
index 023ff57..ea8c4d8 100644
--- a/src/H5FDint.c
+++ b/src/H5FDint.c
@@ -13,11 +13,9 @@
/*-------------------------------------------------------------------------
*
- * Created: H5FDint.c
- * Jan 17 2008
- * Quincey Koziol <koziol@hdfgroup.org>
+ * Created: H5FDint.c
*
- * Purpose: Internal routine for VFD operations
+ * Purpose: Internal routine for VFD operations
*
*-------------------------------------------------------------------------
*/
@@ -32,12 +30,12 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5CXprivate.h" /* API Contexts */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* File access */
-#include "H5FDpkg.h" /* File Drivers */
-#include "H5Iprivate.h" /* IDs */
+#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5FDpkg.h" /* File Drivers */
+#include "H5Iprivate.h" /* IDs */
/****************/
@@ -83,26 +81,26 @@
* signature can appear at address 0, or any power of two
* beginning with 512.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
- *
- * Programmer: Robb Matzke
- * Friday, November 7, 1997
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr)
{
- haddr_t addr, eoa, eof;
+ haddr_t addr = HADDR_UNDEF;
+ haddr_t eoa = HADDR_UNDEF;
+ haddr_t eof = HADDR_UNDEF;
uint8_t buf[H5F_SIGNATURE_LEN];
- unsigned n, maxpow;
+ unsigned n;
+ unsigned maxpow;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Sanity checks */
HDassert(file);
+ HDassert(sig_addr);
/* Find the least N such that 2^N is larger than the file size */
eof = H5FD_get_eof(file, H5FD_MEM_SUPER);
@@ -114,8 +112,7 @@ H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr)
addr >>= 1;
maxpow = MAX(maxpow, 9);
- /*
- * Search for the file signature at format address zero followed by
+ /* Search for the file signature at format address zero followed by
* powers of two larger than 9.
*/
for(n = 8; n < maxpow; n++) {
@@ -126,17 +123,16 @@ H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr)
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to read file signature")
if(!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN))
break;
- } /* end for */
+ }
- /*
- * If the signature was not found then reset the EOA value and return
+ /* If the signature was not found then reset the EOA value and return
* HADDR_UNDEF.
*/
if(n >= maxpow) {
if(H5FD_set_eoa(file, H5FD_MEM_SUPER, eoa) < 0)
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to reset EOA value")
*sig_addr = HADDR_UNDEF;
- } /* end if */
+ }
else
/* Set return value */
*sig_addr = addr;
@@ -147,44 +143,41 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_read
- *
- * Purpose: Private version of H5FDread()
+ * Function: H5FD_read
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Purpose: Private version of H5FDread()
*
- * Programmer: Robb Matzke
- * Wednesday, August 4, 1999
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
-H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size,
- void *buf/*out*/)
+H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/)
{
- hid_t dxpl_id; /* DXPL for operation */
- herr_t ret_value = SUCCEED; /* Return value */
+ hid_t dxpl_id = H5I_INVALID_HID; /* DXPL for operation */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Sanity checks */
- HDassert(file && file->cls);
+ HDassert(file);
+ HDassert(file->cls);
HDassert(buf);
/* Get proper DXPL for I/O */
dxpl_id = H5CX_get_dxpl();
#ifndef H5_HAVE_PARALLEL
- /* Do not return early for Parallel mode since the I/O could be a */
- /* collective transfer. */
- /* The no-op case */
+ /* The no-op case
+ *
+ * Do not return early for Parallel mode since the I/O could be a
+ * collective transfer.
+ */
if(0 == size)
HGOTO_DONE(SUCCEED)
#endif /* H5_HAVE_PARALLEL */
- /*
- * If the file is open for SWMR read access, allow access to data past
+ /* If the file is open for SWMR read access, allow access to data past
* the end of the allocated space (the 'eoa'). This is done because the
* eoa stored in the file's superblock might be out of sync with the
* objects being written within the file by the application performing
@@ -198,7 +191,7 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size,
if((addr + file->base_addr + size) > eoa)
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu, eoa = %llu", (unsigned long long)(addr + file->base_addr), (unsigned long long)size, (unsigned long long)eoa)
- } /* end if */
+ }
/* Dispatch to driver */
if((file->cls->read)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0)
@@ -210,45 +203,43 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_write
- *
- * Purpose: Private version of H5FDwrite()
+ * Function: H5FD_write
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Purpose: Private version of H5FDwrite()
*
- * Programmer: Robb Matzke
- * Wednesday, August 4, 1999
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
-H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size,
- const void *buf)
+H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf)
{
- hid_t dxpl_id; /* DXPL for operation */
- haddr_t eoa = HADDR_UNDEF; /* EOA for file */
- herr_t ret_value = SUCCEED; /* Return value */
+ hid_t dxpl_id; /* DXPL for operation */
+ haddr_t eoa = HADDR_UNDEF; /* EOA for file */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Sanity checks */
- HDassert(file && file->cls);
+ HDassert(file);
+ HDassert(file->cls);
HDassert(buf);
/* Get proper DXPL for I/O */
dxpl_id = H5CX_get_dxpl();
#ifndef H5_HAVE_PARALLEL
- /* Do not return early for Parallel mode since the I/O could be a */
- /* collective transfer. */
- /* The no-op case */
+ /* The no-op case
+ *
+ * Do not return early for Parallel mode since the I/O could be a
+ * collective transfer.
+ */
if(0 == size)
HGOTO_DONE(SUCCEED)
#endif /* H5_HAVE_PARALLEL */
if(HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type)))
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver get_eoa request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver get_eoa request failed")
if((addr + file->base_addr + size) > eoa)
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size=%llu, eoa=%llu",
(unsigned long long)(addr+ file->base_addr), (unsigned long long)size, (unsigned long long)eoa)
@@ -263,20 +254,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_set_eoa
+ * Function: H5FD_set_eoa
*
- * Purpose: Private version of H5FDset_eoa()
+ * Purpose: Private version of H5FDset_eoa()
*
* This function expects the EOA is a RELATIVE address, i.e.
* relative to the base address. This is NOT the same as the
* EOA stored in the superblock, which is an absolute
* address. Object addresses are relative.
*
- * Return: Success: Non-negative
- * Failure: Negative, no side effect
- *
- * Programmer: Robb Matzke
- * Wednesday, August 4, 1999
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -292,7 +279,7 @@ H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr)
/* Dispatch to driver, convert to absolute address */
if((file->cls->set_eoa)(file, type, addr + file->base_addr) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver set_eoa request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver set_eoa request failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -300,20 +287,18 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_get_eoa
+ * Function: H5FD_get_eoa
*
- * Purpose: Private version of H5FDget_eoa()
+ * Purpose: Private version of H5FDget_eoa()
*
* This function returns the EOA as a RELATIVE address, i.e.
* relative to the base address. This is NOT the same as the
* EOA stored in the superblock, which is an absolute
* address. Object addresses are relative.
*
- * Return: Success: First byte after allocated memory.
- * Failure: HADDR_UNDEF
+ * Return: Success: First byte after allocated memory
*
- * Programmer: Robb Matzke
- * Wednesday, August 4, 1999
+ * Failure: HADDR_UNDEF
*
*-------------------------------------------------------------------------
*/
@@ -328,7 +313,7 @@ H5FD_get_eoa(const H5FD_t *file, H5FD_mem_t type)
/* Dispatch to driver */
if(HADDR_UNDEF == (ret_value = (file->cls->get_eoa)(file, type)))
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed")
/* Adjust for base address in file (convert to relative address) */
ret_value -= file->base_addr;
@@ -339,23 +324,18 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_get_eof
+ * Function: H5FD_get_eof
*
- * Purpose: Private version of H5FDget_eof()
+ * Purpose: Private version of H5FDget_eof()
*
* This function returns the EOF as a RELATIVE address, i.e.
* relative to the base address. This will be different
* from the end of the physical file if there is a user
* block.
*
- * Return: Success: The EOF address.
+ * Return: Success: The EOF address.
*
- * Failure: HADDR_UNDEF
- *
- * Programmer: Robb Matzke
- * Wednesday, August 4, 1999
- *
- * Modifications:
+ * Failure: HADDR_UNDEF
*
*-------------------------------------------------------------------------
*/
@@ -370,11 +350,11 @@ H5FD_get_eof(const H5FD_t *file, H5FD_mem_t type)
/* Dispatch to driver */
if(file->cls->get_eof) {
- if(HADDR_UNDEF == (ret_value = (file->cls->get_eof)(file, type)))
- HGOTO_ERROR(H5E_VFL, H5E_CANTGET, HADDR_UNDEF, "driver get_eof request failed")
- } /* end if */
+ if(HADDR_UNDEF == (ret_value = (file->cls->get_eof)(file, type)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTGET, HADDR_UNDEF, "driver get_eof request failed")
+ }
else
- ret_value = file->maxaddr;
+ ret_value = file->maxaddr;
/* Adjust for base address in file (convert to relative address) */
ret_value -= file->base_addr;
@@ -385,17 +365,14 @@ done:
/*-------------------------------------------------------------------------
-* Function: H5FD_driver_query
-*
-* Purpose: Similar to H5FD_query(), but intended for cases when we don't
-* have a file available (e.g. before one is opened). Since we
-* can't use the file to get the driver, the driver is passed in
-* as a parameter.
+* Function: H5FD_driver_query
*
-* Return: SUCCEED/FAIL
+* Purpose: Similar to H5FD_query(), but intended for cases when we don't
+* have a file available (e.g. before one is opened). Since we
+* can't use the file to get the driver, the driver is passed in
+* as a parameter.
*
-* Programmer: Jacob Gruber
-* Wednesday, August 17, 2011
+* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/