summaryrefslogtreecommitdiffstats
path: root/src/H5Fsuper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Fsuper.c')
-rw-r--r--src/H5Fsuper.c62
1 files changed, 32 insertions, 30 deletions
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index 8205392..a1c67ec 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -100,34 +100,33 @@ H5F_init_super_interface(void)
/*-------------------------------------------------------------------------
- * Function: H5F_locate_signature
+ * Function: H5F_locate_signature
*
- * Purpose: Finds the HDF5 superblock signature in a file. The signature
- * can appear at address 0, or any power of two beginning with
- * 512.
+ * Purpose: Finds the HDF5 superblock signature in a file. The
+ * signature can appear at address 0, or any power of two
+ * beginning with 512.
*
- * Return: Success: The absolute format address of the signature.
- *
- * Failure: HADDR_UNDEF
+ * Return: Success: SUCCEED
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Friday, November 7, 1997
+ * Programmer: Robb Matzke
+ * Friday, November 7, 1997
*
*-------------------------------------------------------------------------
*/
-haddr_t
-H5F_locate_signature(H5FD_t *file, hid_t dxpl_id)
+herr_t
+H5F_locate_signature(H5FD_t *file, hid_t dxpl_id, haddr_t *sig_addr)
{
- haddr_t addr, eoa;
- uint8_t buf[H5F_SIGNATURE_LEN];
- unsigned n, maxpow;
- haddr_t ret_value; /* Return value */
+ haddr_t addr, eoa;
+ uint8_t buf[H5F_SIGNATURE_LEN];
+ unsigned n, maxpow;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Find the least N such that 2^N is larger than the file size */
if(HADDR_UNDEF == (addr = H5FD_get_eof(file)) || HADDR_UNDEF == (eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER)))
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to obtain EOF/EOA value")
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to obtain EOF/EOA value")
for(maxpow = 0; addr; maxpow++)
addr >>= 1;
maxpow = MAX(maxpow, 9);
@@ -137,26 +136,27 @@ H5F_locate_signature(H5FD_t *file, hid_t dxpl_id)
* powers of two larger than 9.
*/
for(n = 8; n < maxpow; n++) {
- addr = (8 == n) ? 0 : (haddr_t)1 << n;
- if(H5FD_set_eoa(file, H5FD_MEM_SUPER, addr + H5F_SIGNATURE_LEN) < 0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to set EOA value for file signature")
- if(H5FD_read(file, dxpl_id, H5FD_MEM_SUPER, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to read file signature")
- if(!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN))
+ addr = (8 == n) ? 0 : (haddr_t)1 << n;
+ if(H5FD_set_eoa(file, H5FD_MEM_SUPER, addr + H5F_SIGNATURE_LEN) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to set EOA value for file signature")
+ if(H5FD_read(file, dxpl_id, H5FD_MEM_SUPER, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0)
+ 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
- * failure.
+ * HADDR_UNDEF.
*/
if(n >= maxpow) {
- (void)H5FD_set_eoa(file, H5FD_MEM_SUPER, eoa); /* Ignore return value */
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to find a valid file signature")
+ 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 */
-
- /* Set return value */
- ret_value = addr;
+ else
+ /* Set return value */
+ *sig_addr = addr;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -330,8 +330,10 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id)
FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__SUPERBLOCK_TAG, FAIL)
/* Find the superblock */
- if(HADDR_UNDEF == (super_addr = H5F_locate_signature(f->shared->lf, dxpl_id)))
- HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to find file signature")
+ if(H5F_locate_signature(f->shared->lf, dxpl_id, &super_addr) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature")
+ if(HADDR_UNDEF == super_addr)
+ HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "file signature not found")
/* Check for userblock present */
if(H5F_addr_gt(super_addr, 0)) {