summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-05-28 19:54:36 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-05-28 19:54:36 (GMT)
commita67f73add8e9d8d40b71ad59434c00a606f9bec8 (patch)
tree941e98fffa2333c573978e1d740775314ae9981a /src
parent7deefc4211612d2f9753f5c8678f2c413ef0715e (diff)
downloadhdf5-a67f73add8e9d8d40b71ad59434c00a606f9bec8.zip
hdf5-a67f73add8e9d8d40b71ad59434c00a606f9bec8.tar.gz
hdf5-a67f73add8e9d8d40b71ad59434c00a606f9bec8.tar.bz2
Normalization with develop of the VFDs and H5F package.
Diffstat (limited to 'src')
-rw-r--r--src/H5FD.c983
-rw-r--r--src/H5FDdirect.c24
-rw-r--r--src/H5FDfamily.c39
-rw-r--r--src/H5FDint.c167
-rw-r--r--src/H5FDlog.c20
-rw-r--r--src/H5FDmpio.c2
-rw-r--r--src/H5FDmulti.c114
-rw-r--r--src/H5FDpkg.h2
-rw-r--r--src/H5FDprivate.h8
-rw-r--r--src/H5FDros3.c8
-rw-r--r--src/H5FDsec2.c6
-rw-r--r--src/H5FDspace.c16
-rw-r--r--src/H5Fint.c439
13 files changed, 939 insertions, 889 deletions
diff --git a/src/H5FD.c b/src/H5FD.c
index a0e1a44..2e80c7f 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -23,22 +23,22 @@
/* Module Setup */
/****************/
-#define H5F_FRIEND /*suppress error about including H5Fpkg */
+#define H5F_FRIEND /* Suppress error about including H5Fpkg */
#include "H5FDmodule.h" /* This source code file is part of the H5FD module */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5CXprivate.h" /* API Contexts */
-#include "H5Dprivate.h" /* Datasets */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fpkg.h" /* File access */
-#include "H5FDpkg.h" /* File Drivers */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Pprivate.h" /* Property lists */
+#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
+#include "H5Dprivate.h" /* Datasets */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fpkg.h" /* File access */
+#include "H5FDpkg.h" /* File Drivers */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Pprivate.h" /* Property lists */
/****************/
/* Local Macros */
@@ -58,8 +58,8 @@
/********************/
/* Local Prototypes */
/********************/
-static herr_t H5FD_free_cls(H5FD_class_t *cls);
-static int H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/);
+static herr_t H5FD__free_cls(H5FD_class_t *cls);
+static herr_t H5FD__query(const H5FD_t *f, unsigned long *flags/*out*/);
/*********************/
/* Package Variables */
@@ -94,21 +94,20 @@ static unsigned long H5FD_file_serial_no_g;
/* File driver ID class */
static const H5I_class_t H5I_VFL_CLS[1] = {{
- H5I_VFL, /* ID class value */
- 0, /* Class flags */
- 0, /* # of reserved IDs for class */
- (H5I_free_t)H5FD_free_cls /* Callback routine for closing objects of this class */
+ H5I_VFL, /* ID class value */
+ 0, /* Class flags */
+ 0, /* # of reserved IDs for class */
+ (H5I_free_t)H5FD__free_cls /* Callback routine for closing objects of this class */
}};
/*-------------------------------------------------------------------------
- * Function: H5FD__init_package
+ * Function: H5FD__init_package
*
- * Purpose: Initialize the virtual file layer.
+ * Purpose: Initialize the virtual file layer.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -131,16 +130,17 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_term_package
+ * Function: H5FD_term_package
+ *
+ * Purpose: Terminate this interface: free all memory and reset global
+ * variables to their initial values. Release all ID groups
+ * associated with this interface.
*
- * Purpose: Terminate this interface: free all memory and reset global
- * variables to their initial values. Release all ID groups
- * associated with this interface.
+ * Return: Success: Positive if anything was done that might
+ * have affected other interfaces; zero
+ * otherwise.
*
- * Return: Success: Positive if anything was done that might
- * have affected other interfaces; zero
- * otherwise.
- * Failure: Never fails.
+ * Failure: Never fails.
*
*-------------------------------------------------------------------------
*/
@@ -171,26 +171,24 @@ H5FD_term_package(void)
/*-------------------------------------------------------------------------
- * Function: H5FD_free_cls
+ * Function: H5FD__free_cls
*
- * Purpose: Frees a file driver class struct and returns an indication of
- * success. This function is used as the free callback for the
- * virtual file layer object identifiers (cf H5FD__init_package).
- *
- * Return: Success: Non-negative
+ * Purpose: Frees a file driver class struct and returns an indication of
+ * success. This function is used as the free callback for the
+ * virtual file layer object identifiers (cf H5FD__init_package).
*
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5FD_free_cls(H5FD_class_t *cls)
+H5FD__free_cls(H5FD_class_t *cls)
{
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
- /* Sanity check */
+ /* Sanity checks */
HDassert(cls);
/* If the file driver has a terminate callback, call it to give the file
@@ -204,7 +202,7 @@ H5FD_free_cls(H5FD_class_t *cls)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FD_free_cls() */
+} /* end H5FD__free_cls() */
/*-------------------------------------------------------------------------
@@ -219,37 +217,37 @@ done:
* library is closed or the driver is
* unregistered.
*
- * Failure: A negative value.
+ * Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
hid_t
H5FDregister(const H5FD_class_t *cls)
{
- hid_t ret_value;
- H5FD_mem_t type;
+ H5FD_mem_t type;
+ hid_t ret_value = H5I_INVALID_HID;
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE1("i", "*x", cls);
/* Check arguments */
if(!cls)
- HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "null class pointer is disallowed")
+ HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "null class pointer is disallowed")
if(!cls->open || !cls->close)
- HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`open' and/or `close' methods are not defined")
+ HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'open' and/or 'close' methods are not defined")
if(!cls->get_eoa || !cls->set_eoa)
- HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`get_eoa' and/or `set_eoa' methods are not defined")
+ HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'get_eoa' and/or 'set_eoa' methods are not defined")
if(!cls->get_eof)
- HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`get_eof' method is not defined")
+ HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'get_eof' method is not defined")
if(!cls->read || !cls->write)
- HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`read' and/or `write' method is not defined")
+ HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'read' and/or 'write' method is not defined")
for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++)
if(cls->fl_map[type] < H5FD_MEM_NOLIST || cls->fl_map[type] >= H5FD_MEM_NTYPES)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid free-list mapping")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid free-list mapping")
/* Create the new class ID */
if((ret_value = H5FD_register(cls, sizeof(H5FD_class_t), TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register file driver ID")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file driver ID")
done:
FUNC_LEAVE_API(ret_value)
@@ -268,7 +266,7 @@ done:
* library is closed or the driver is
* unregistered.
*
- * Failure: A negative value.
+ * Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
@@ -276,34 +274,35 @@ hid_t
H5FD_register(const void *_cls, size_t size, hbool_t app_ref)
{
const H5FD_class_t *cls = (const H5FD_class_t *)_cls;
- H5FD_class_t *saved = NULL;
- H5FD_mem_t type;
- hid_t ret_value = H5I_INVALID_HID; /* Return value */
+ H5FD_class_t *saved = NULL;
+ H5FD_mem_t type;
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI(H5I_INVALID_HID)
- /* Check arguments */
+ /* Sanity checks */
HDassert(cls);
HDassert(cls->open && cls->close);
HDassert(cls->get_eoa && cls->set_eoa);
HDassert(cls->get_eof);
HDassert(cls->read && cls->write);
- for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++)
+ for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) {
HDassert(cls->fl_map[type] >= H5FD_MEM_NOLIST && cls->fl_map[type] < H5FD_MEM_NTYPES);
+ }
/* Copy the class structure so the caller can reuse or free it */
if(NULL == (saved = (H5FD_class_t *)H5MM_malloc(size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for file driver class struct")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed for file driver class struct")
H5MM_memcpy(saved, cls, size);
/* Create the new class ID */
if((ret_value = H5I_register(H5I_VFL, saved, app_ref)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register file driver ID")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file driver ID")
done:
- if(ret_value < 0)
+ if(H5I_INVALID_HID == ret_value)
if(saved)
- H5MM_xfree(saved);
+ saved = (H5FD_class_t *)H5MM_xfree(saved);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_register() */
@@ -317,9 +316,7 @@ done:
* this driver or files which are already opened under this
* driver.
*
- * Return: Success: Non-negative
- *
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -333,11 +330,11 @@ H5FDunregister(hid_t driver_id)
/* Check arguments */
if(NULL == H5I_object_verify(driver_id, H5I_VFL))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver")
/* The H5FD_class_t struct will be freed by this function */
if(H5I_dec_app_ref(driver_id) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "unable to unregister file driver")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "unable to unregister file driver")
done:
FUNC_LEAVE_API(ret_value)
@@ -345,19 +342,19 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_get_class
+ * Function: H5FD_get_class
*
- * Purpose: Obtains a pointer to the driver struct containing all the
- * callback pointers, etc. The PLIST_ID argument can be a file
- * access property list, a data transfer property list, or a
- * file driver identifier.
+ * Purpose: Obtains a pointer to the driver struct containing all the
+ * callback pointers, etc. The PLIST_ID argument can be a file
+ * access property list, a data transfer property list, or a
+ * file driver identifier.
*
- * Return: Success: Ptr to the driver information. The pointer is
- * only valid as long as the driver remains
- * registered or some file or property list
- * exists which references the driver.
+ * Return: Success: Ptr to the driver information. The pointer is
+ * only valid as long as the driver remains
+ * registered or some file or property list
+ * exists which references the driver.
*
- * Failure: NULL
+ * Failure: NULL
*
*-------------------------------------------------------------------------
*/
@@ -369,7 +366,7 @@ H5FD_get_class(hid_t id)
FUNC_ENTER_NOAPI(NULL)
if(H5I_VFL == H5I_get_type(id))
- ret_value = (H5FD_class_t *)H5I_object(id);
+ ret_value = (H5FD_class_t *)H5I_object(id);
else {
H5P_genplist_t *plist; /* Property list pointer */
@@ -394,29 +391,32 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_sb_size
+ * Function: H5FD_sb_size
*
- * Purpose: Obtains the number of bytes required to store the driver file
- * access data in the HDF5 superblock.
+ * Purpose: Obtains the number of bytes required to store the driver file
+ * access data in the HDF5 superblock.
*
- * Return: Success: Number of bytes required.
+ * Return: Success: Number of bytes required. May be zero if the
+ * driver has no data to store in the superblock.
*
- * Failure: 0 if an error occurs or if the driver has no
- * data to store in the superblock.
+ * Failure: This function cannot indicate errors.
*
*-------------------------------------------------------------------------
*/
hsize_t
H5FD_sb_size(H5FD_t *file)
{
- hsize_t ret_value=0;
+ hsize_t ret_value = 0;
FUNC_ENTER_NOAPI(0)
- HDassert(file && file->cls);
+ /* Sanity checks */
+ HDassert(file);
+ HDassert(file->cls);
+ /* Dispatch to driver */
if(file->cls->sb_size)
- ret_value = (file->cls->sb_size)(file);
+ ret_value = (file->cls->sb_size)(file);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -424,31 +424,33 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_sb_encode
+ * Function: H5FD_sb_encode
*
- * Purpose: Encode driver-specific data into the output arguments. The
- * NAME is a nine-byte buffer which should get an
- * eight-character driver name and/or version followed by a null
- * terminator. The BUF argument is a buffer to receive the
- * encoded driver-specific data. The size of the BUF array is
- * the size returned by the H5FD_sb_size() call.
+ * Purpose: Encode driver-specific data into the output arguments. The
+ * NAME is a nine-byte buffer which should get an
+ * eight-character driver name and/or version followed by a null
+ * terminator. The BUF argument is a buffer to receive the
+ * encoded driver-specific data. The size of the BUF array is
+ * the size returned by the H5FD_sb_size() call.
*
- * Return: Success: Non-negative
- *
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
- HDassert(file && file->cls);
+ /* Sanity checks */
+ HDassert(file);
+ HDassert(file->cls);
+
+ /* Dispatch to driver */
if(file->cls->sb_encode && (file->cls->sb_encode)(file, name/*out*/, buf/*out*/) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_encode request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_encode request failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -456,12 +458,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD__sb_decode
+ * Function: H5FD__sb_decode
*
- * Purpose: Decodes the driver information block.
+ * Purpose: Decodes the driver information block.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -472,11 +473,13 @@ H5FD__sb_decode(H5FD_t *file, const char *name, const uint8_t *buf)
FUNC_ENTER_STATIC
- HDassert(file && file->cls);
+ /* Sanity checks */
+ HDassert(file);
+ HDassert(file->cls);
- /* Decode driver information */
+ /* Dispatch to driver */
if(file->cls->sb_decode && (file->cls->sb_decode)(file, name, buf) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_decode request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_decode request failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -484,12 +487,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_sb_load
+ * Function: H5FD_sb_load
*
- * Purpose: Validate and decode the driver information block.
+ * Purpose: Validate and decode the driver information block.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -500,7 +502,9 @@ H5FD_sb_load(H5FD_t *file, const char *name, const uint8_t *buf)
FUNC_ENTER_NOAPI(FAIL)
- HDassert(file && file->cls);
+ /* Sanity checks */
+ HDassert(file);
+ HDassert(file->cls);
/* Check if driver matches driver information saved. Unfortunately, we can't push this
* function to each specific driver because we're checking if the driver is correct.
@@ -520,37 +524,41 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_fapl_get
+ * Function: H5FD_fapl_get
+ *
+ * Purpose: Gets the file access property list associated with a file.
+ * Usually the file will copy what it needs from the original
+ * file access property list when the file is created. The
+ * purpose of this function is to create a new file access
+ * property list based on the settings in the file, which may
+ * have been modified from the original file access property
+ * list.
*
- * Purpose: Gets the file access property list associated with a file.
- * Usually the file will copy what it needs from the original
- * file access property list when the file is created. The
- * purpose of this function is to create a new file access
- * property list based on the settings in the file, which may
- * have been modified from the original file access property
- * list.
+ * Return: Success: Pointer to a new file access property list
+ * with all members copied. If the file is
+ * closed then this property list lives on, and
+ * vice versa.
*
- * Return: Success: Pointer to a new file access property list
- * with all members copied. If the file is
- * closed then this property list lives on, and
- * vice versa.
+ * This can be NULL if the file has no properties.
*
- * Failure: NULL, including when the file has no
- * properties.
+ * Failure: This function cannot indicate errors.
*
*-------------------------------------------------------------------------
*/
void *
H5FD_fapl_get(H5FD_t *file)
{
- void *ret_value=NULL;
+ void *ret_value = NULL;
FUNC_ENTER_NOAPI(NULL)
+ /* Sanity checks */
HDassert(file);
+ HDassert(file->cls);
+ /* Dispatch to driver */
if(file->cls->fapl_get)
- ret_value = (file->cls->fapl_get)(file);
+ ret_value = (file->cls->fapl_get)(file);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -558,17 +566,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_fapl_close
+ * Function: H5FD_free_driver_info
*
- * Purpose: Closes a driver for a dataset transfer property list
+ * Purpose: Frees a driver's info
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
-H5FD_fapl_close(hid_t driver_id, const void *driver_info)
+H5FD_free_driver_info(hid_t driver_id, const void *driver_info)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -594,63 +601,63 @@ H5FD_fapl_close(hid_t driver_id, const void *driver_info)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FD_fapl_close() */
+} /* end H5FD_free_driver_info() */
/*-------------------------------------------------------------------------
- * Function: H5FDopen
+ * Function: H5FDopen
*
- * Purpose: Opens a file named NAME for the type(s) of access described
- * by the bit vector FLAGS according to a file access property
- * list FAPL_ID (which may be the constant H5P_DEFAULT). The
- * file should expect to handle format addresses in the range [0,
- * MAXADDR] (if MAXADDR is the undefined address then the caller
- * doesn't care about the address range).
+ * Purpose: Opens a file named NAME for the type(s) of access described
+ * by the bit vector FLAGS according to a file access property
+ * list FAPL_ID (which may be the constant H5P_DEFAULT). The
+ * file should expect to handle format addresses in the range [0,
+ * MAXADDR] (if MAXADDR is the undefined address then the caller
+ * doesn't care about the address range).
*
- * Possible values for the FLAGS bits are:
+ * Possible values for the FLAGS bits are:
*
- * H5F_ACC_RDWR: Open the file for read and write access. If
- * this bit is not set then open the file for
- * read only access. It is permissible to open a
- * file for read and write access when only read
- * access is requested by the library (the
- * library will never attempt to write to a file
- * which it opened with only read access).
+ * H5F_ACC_RDWR: Open the file for read and write access. If
+ * this bit is not set then open the file for
+ * read only access. It is permissible to open a
+ * file for read and write access when only read
+ * access is requested by the library (the
+ * library will never attempt to write to a file
+ * which it opened with only read access).
*
- * H5F_ACC_CREATE: Create the file if it doesn't already exist.
- * However, see H5F_ACC_EXCL below.
+ * H5F_ACC_CREATE: Create the file if it doesn't already exist.
+ * However, see H5F_ACC_EXCL below.
*
- * H5F_ACC_TRUNC: Truncate the file if it already exists. This
- * is equivalent to deleting the file and then
- * creating a new empty file.
+ * H5F_ACC_TRUNC: Truncate the file if it already exists. This
+ * is equivalent to deleting the file and then
+ * creating a new empty file.
*
- * H5F_ACC_EXCL: When used with H5F_ACC_CREATE, if the file
- * already exists then the open should fail.
- * Note that this is unsupported/broken with
- * some file drivers (e.g., sec2 across nfs) and
- * will contain a race condition when used to
- * perform file locking.
+ * H5F_ACC_EXCL: When used with H5F_ACC_CREATE, if the file
+ * already exists then the open should fail.
+ * Note that this is unsupported/broken with
+ * some file drivers (e.g., sec2 across nfs) and
+ * will contain a race condition when used to
+ * perform file locking.
*
- * The MAXADDR is the maximum address which will be requested by
- * the library during an allocation operation. Usually this is
- * the same value as the MAXADDR field of the class structure,
- * but it can be smaller if the driver is being used under some
- * other driver.
+ * The MAXADDR is the maximum address which will be requested by
+ * the library during an allocation operation. Usually this is
+ * the same value as the MAXADDR field of the class structure,
+ * but it can be smaller if the driver is being used under some
+ * other driver.
*
- * Note that when the driver `open' callback gets control that
- * the public part of the file struct (the H5FD_t part) will be
- * incomplete and will be filled in after that callback returns.
+ * Note that when the driver 'open' callback gets control that
+ * the public part of the file struct (the H5FD_t part) will be
+ * incomplete and will be filled in after that callback returns.
*
- * Return: Success: Pointer to a new file driver struct.
+ * Return: Success: Pointer to a new file driver struct.
*
- * Failure: NULL
+ * Failure: NULL
*
*-------------------------------------------------------------------------
*/
H5FD_t *
H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
{
- H5FD_t *ret_value=NULL;
+ H5FD_t *ret_value = NULL;
FUNC_ENTER_API(NULL)
H5TRACE4("*x", "*sIuia", name, flags, fapl_id, maxaddr);
@@ -659,11 +666,12 @@ H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
if(H5P_DEFAULT == fapl_id)
fapl_id = H5P_FILE_ACCESS_DEFAULT;
else
- if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS))
+ if(TRUE != H5P_isa_class(fapl_id,H5P_FILE_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list")
- if(NULL==(ret_value=H5FD_open(name, flags, fapl_id, maxaddr)))
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to open file")
+ /* Call private function */
+ if(NULL == (ret_value = H5FD_open(name, flags, fapl_id, maxaddr)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to open file")
done:
FUNC_LEAVE_API(ret_value)
@@ -671,13 +679,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_open
+ * Function: H5FD_open
*
- * Purpose: Private version of H5FDopen()
+ * Purpose: Private version of H5FDopen()
*
- * Return: Success: Pointer to a new file driver struct
+ * Return: Success: Pointer to a new file driver struct
*
- * Failure: NULL
+ * Failure: NULL
*
*-------------------------------------------------------------------------
*/
@@ -694,9 +702,9 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
FUNC_ENTER_NOAPI(NULL)
- /* Sanity check */
+ /* Sanity checks */
if(0 == maxaddr)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "zero format address range")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "zero format address range")
/* Get file access property list */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
@@ -708,9 +716,9 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
/* Get driver info */
if(NULL == (driver = (H5FD_class_t *)H5I_object(driver_prop.driver_id)))
- HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "invalid driver ID in file access property list")
+ HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "invalid driver ID in file access property list")
if(NULL == driver->open)
- HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "file driver has no `open' method")
+ HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "file driver has no `open' method")
/* Query driver flag */
if(H5FD_driver_query(driver, &driver_flags) < 0)
@@ -730,13 +738,12 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
if(HADDR_UNDEF == maxaddr)
maxaddr = driver->maxaddr;
if(NULL == (file = (driver->open)(name, flags, fapl_id, maxaddr)))
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "open failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "open failed")
/* Set the file access flags */
file->access_flags = flags;
- /*
- * Fill in public fields. We must increment the reference count on the
+ /* Fill in public fields. We must increment the reference count on the
* driver ID to prevent it from being freed while this file is open.
*/
file->driver_id = driver_prop.driver_id;
@@ -750,7 +757,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment")
/* Retrieve the VFL driver feature flags */
- if(H5FD_query(file, &(file->feature_flags)) < 0)
+ if(H5FD__query(file, &(file->feature_flags)) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to query file driver")
/* Increment the global serial number & assign it to this H5FD_t object */
@@ -774,32 +781,35 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FDclose
+ * Function: H5FDclose
*
- * Purpose: Closes the file by calling the driver `close' callback, which
- * should free all driver-private data and free the file struct.
- * Note that the public part of the file struct (the H5FD_t part)
- * will be all zero during the driver close callback like during
- * the `open' callback.
+ * Purpose: Closes the file by calling the driver 'close' callback, which
+ * should free all driver-private data and free the file struct.
+ * Note that the public part of the file struct (the H5FD_t part)
+ * will be all zero during the driver close callback like during
+ * the 'open' callback.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5FDclose(H5FD_t *file)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "*x", file);
- if(!file || !file->cls)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer")
+ /* Check arguments */
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")
+ /* Call private function */
if(H5FD_close(file) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
done:
FUNC_LEAVE_API(ret_value)
@@ -807,12 +817,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_close
+ * Function: H5FD_close
*
- * Purpose: Private version of H5FDclose()
+ * Purpose: Private version of H5FDclose()
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -824,16 +833,16 @@ H5FD_close(H5FD_t *file)
FUNC_ENTER_NOAPI(FAIL)
- /* check args */
- HDassert(file && file->cls);
+ /* Sanity checks */
+ HDassert(file);
+ HDassert(file->cls);
/* Prepare to close file by clearing all public fields */
driver = file->cls;
if(H5I_dec_ref(file->driver_id) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID")
- /*
- * Dispatch to the driver for actual close. If the driver fails to
+ /* Dispatch to the driver for actual close. If the driver fails to
* close the file then the file will be in an unusable state.
*/
HDassert(driver->close);
@@ -846,47 +855,48 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FDcmp
+ * Function: H5FDcmp
*
- * Purpose: Compare the keys of two files using the file driver callback
- * if the files belong to the same driver, otherwise sort the
- * files by driver class pointer value.
+ * Purpose: Compare the keys of two files using the file driver callback
+ * if the files belong to the same driver, otherwise sort the
+ * files by driver class pointer value.
*
- * Return: Success: A value like strcmp()
+ * Return: Success: A value like strcmp()
*
- * Failure: Must never fail. If both file handles are
- * invalid then they compare equal. If one file
- * handle is invalid then it compares less than
- * the other. If both files belong to the same
- * driver and the driver doesn't provide a
- * comparison callback then the file pointers
- * themselves are compared.
+ * Failure: Must never fail. If both file handles are
+ * invalid then they compare equal. If one file
+ * handle is invalid then it compares less than
+ * the other. If both files belong to the same
+ * driver and the driver doesn't provide a
+ * comparison callback then the file pointers
+ * themselves are compared.
*
*-------------------------------------------------------------------------
*/
int
H5FDcmp(const H5FD_t *f1, const H5FD_t *f2)
{
- int ret_value;
+ int ret_value = -1;
- FUNC_ENTER_API(-1) /*return value is arbitrary*/
+ FUNC_ENTER_API(-1) /* return value is arbitrary */
H5TRACE2("Is", "*x*x", f1, f2);
+ /* Call private function */
ret_value = H5FD_cmp(f1, f2);
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5FDcmp() */
/*-------------------------------------------------------------------------
- * Function: H5FD_cmp
+ * Function: H5FD_cmp
*
- * Purpose: Private version of H5FDcmp()
+ * Purpose: Private version of H5FDcmp()
*
- * Return: Success: A value like strcmp()
+ * Return: Success: A value like strcmp()
*
- * Failure: Must never fail.
+ * Failure: Must never fail.
*
*-------------------------------------------------------------------------
*/
@@ -895,7 +905,7 @@ H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2)
{
int ret_value = -1; /* Return value */
- FUNC_ENTER_NOAPI(-1) /*return value is arbitrary*/
+ FUNC_ENTER_NOAPI(-1) /* return value is arbitrary */
if((!f1 || !f1->cls) && (!f2 || !f2->cls))
HGOTO_DONE(0)
@@ -910,43 +920,50 @@ H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2)
/* Files are same driver; no cmp callback */
if(!f1->cls->cmp) {
- if(f1<f2)
+ if(f1 < f2)
HGOTO_DONE(-1)
- if(f1>f2)
+ if(f1 > f2)
HGOTO_DONE(1)
- HGOTO_DONE(0)
+ HGOTO_DONE(0)
}
+ /* Dispatch to driver */
ret_value = (f1->cls->cmp)(f1, f2);
done:
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5FD_cmp() */
/*-------------------------------------------------------------------------
- * Function: H5FDquery
- *
- * Purpose: Query a VFL driver for its feature flags. (listed in H5FDpublic.h)
+ * Function: H5FDquery
*
- * Return: Success: non-negative
+ * Purpose: Query a VFL driver for its feature flags. (listed in H5FDpublic.h)
*
- * Failure: negative
+ * Return: Success: 0
+ * Failure: -1
*
*-------------------------------------------------------------------------
*/
int
-H5FDquery(const H5FD_t *f, unsigned long *flags/*out*/)
+H5FDquery(const H5FD_t *file, unsigned long *flags/*out*/)
{
- int ret_value;
+ int ret_value = 0;
- FUNC_ENTER_API(FAIL)
- H5TRACE2("Is", "*xx", f, flags);
+ FUNC_ENTER_API((-1))
+ H5TRACE2("Is", "*xx", file, flags);
- HDassert(f);
- HDassert(flags);
+ /* Check arguments */
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "file class pointer cannot be NULL")
+ if(!flags)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "flags parameter cannot be NULL")
- ret_value = H5FD_query(f, flags);
+ /* Call private function */
+ if(H5FD__query(file, flags) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTGET, (-1), "unable to query feature flags")
done:
FUNC_LEAVE_API(ret_value)
@@ -954,69 +971,72 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_query
- *
- * Purpose: Private version of H5FDquery()
+ * Function: H5FD_query
*
- * Return: Success: non-negative
+ * Purpose: Private version of H5FDquery()
*
- * Failure: negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
-static int
-H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/)
+static herr_t
+H5FD__query(const H5FD_t *file, unsigned long *flags/*out*/)
{
- int ret_value = 0; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC
- HDassert(f);
+ /* Sanity checks */
+ HDassert(file);
+ HDassert(file->cls);
HDassert(flags);
- /* Check for query driver and call it */
- if(f->cls->query)
- ret_value = (f->cls->query)(f, flags);
+ /* Dispatch to driver (if available) */
+ if(file->cls->query) {
+ if((file->cls->query)(file, flags) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to query feature flags")
+ }
else
*flags=0;
+done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_query() */
/*-------------------------------------------------------------------------
- * Function: H5FDalloc
+ * Function: H5FDalloc
*
- * Purpose: Allocates SIZE bytes of memory from the FILE. The memory will
- * be used according to the allocation class TYPE. First we try
- * to satisfy the request from one of the free lists, according
- * to the free list map provided by the driver. The free list
- * array has one entry for each request type and the value of
- * that array element can be one of four possibilities:
+ * Purpose: Allocates SIZE bytes of memory from the FILE. The memory will
+ * be used according to the allocation class TYPE. First we try
+ * to satisfy the request from one of the free lists, according
+ * to the free list map provided by the driver. The free list
+ * array has one entry for each request type and the value of
+ * that array element can be one of four possibilities:
*
- * It can be the constant H5FD_MEM_DEFAULT (or zero) which
- * indicates that the identity mapping is used. In other
- * words, the request type maps to its own free list.
+ * It can be the constant H5FD_MEM_DEFAULT (or zero) which
+ * indicates that the identity mapping is used. In other
+ * words, the request type maps to its own free list.
*
- * It can be the request type itself, which has the same
- * effect as the H5FD_MEM_DEFAULT value above.
+ * It can be the request type itself, which has the same
+ * effect as the H5FD_MEM_DEFAULT value above.
*
- * It can be the ID for another request type, which
- * indicates that the free list for the specified type
- * should be used instead.
+ * It can be the ID for another request type, which
+ * indicates that the free list for the specified type
+ * should be used instead.
*
- * It can be the constant H5FD_MEM_NOLIST which means that
- * no free list should be used for this type of request.
+ * It can be the constant H5FD_MEM_NOLIST which means that
+ * no free list should be used for this type of request.
*
- * If the request cannot be satisfied from a free list then
- * either the driver's `alloc' callback is invoked (if one was
- * supplied) or the end-of-address marker is extended. The
- * `alloc' callback is always called with the same arguments as
- * the H5FDalloc().
+ * If the request cannot be satisfied from a free list then
+ * either the driver's 'alloc' callback is invoked (if one was
+ * supplied) or the end-of-address marker is extended. The
+ * 'alloc' callback is always called with the same arguments as
+ * the H5FDalloc().
*
- * Return: Success: The format address of the new file memory.
+ * Return: Success: The format address of the new file memory.
*
- * Failure: The undefined address HADDR_UNDEF
+ * Failure: The undefined address HADDR_UNDEF
*
*-------------------------------------------------------------------------
*/
@@ -1028,13 +1048,15 @@ H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size)
FUNC_ENTER_API(HADDR_UNDEF)
H5TRACE4("a", "*xMtih", file, type, dxpl_id, size);
- /* Check args */
- if(!file || !file->cls)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer")
+ /* Check arguments */
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file class pointer cannot be NULL")
if(type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid request type")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid request type")
if(size == 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "zero-size request")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "zero-size request")
if(H5P_DEFAULT == dxpl_id)
dxpl_id = H5P_DATASET_XFER_DEFAULT;
else
@@ -1044,9 +1066,9 @@ H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size)
/* Set DXPL for operation */
H5CX_set_dxpl(dxpl_id);
- /* Do the real work */
+ /* Call private function */
if(HADDR_UNDEF == (ret_value = H5FD__alloc_real(file, type, size, NULL, NULL)))
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file memory")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file memory")
/* (Note compensating for base address subtraction in internal routine) */
ret_value += file->base_addr;
@@ -1057,32 +1079,32 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FDfree
+ * Function: H5FDfree
*
- * Purpose: Frees format addresses starting with ADDR and continuing for
- * SIZE bytes in the file FILE. The type of space being freed is
- * specified by TYPE, which is mapped to a free list as
- * described for the H5FDalloc() function above. If the request
- * doesn't map to a free list then either the application `free'
- * callback is invoked (if defined) or the memory is leaked.
- *
- * Return: Success: Non-negative
+ * Purpose: Frees format addresses starting with ADDR and continuing for
+ * SIZE bytes in the file FILE. The type of space being freed is
+ * specified by TYPE, which is mapped to a free list as
+ * described for the H5FDalloc() function above. If the request
+ * doesn't map to a free list then either the application 'free'
+ * callback is invoked (if defined) or the memory is leaked.
*
- * Failure: Negative
+ * Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE5("e", "*xMtiah", file, type, dxpl_id, addr, size);
- /* Check args */
- if(!file || !file->cls)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer")
+ /* Check arguments */
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")
if(type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid request type")
if(H5P_DEFAULT == dxpl_id)
@@ -1094,9 +1116,9 @@ H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t siz
/* Set DXPL for operation */
H5CX_set_dxpl(dxpl_id);
- /* Do the real work */
+ /* Call private function */
/* (Note compensating for base address addition in internal routine) */
- if(H5FD_free_real(file, type, addr - file->base_addr, size) < 0)
+ if(H5FD__free_real(file, type, addr - file->base_addr, size) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "file deallocation request failed")
done:
@@ -1123,13 +1145,15 @@ H5FDget_eoa(H5FD_t *file, H5FD_mem_t type)
FUNC_ENTER_API(HADDR_UNDEF)
H5TRACE2("a", "*xMt", file, type);
- /* Check args */
- if(!file || !file->cls)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer")
+ /* Check arguments */
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file class pointer cannot be NULL")
if(type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file type")
- /* The real work */
+ /* Call private function */
if(HADDR_UNDEF == (ret_value = H5FD_get_eoa(file, type)))
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file get eoa request failed")
@@ -1170,15 +1194,17 @@ H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr)
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "*xMta", file, type, addr);
- /* Check args */
- if(!file || !file->cls)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer")
+ /* Check arguments */
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")
if(type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file type")
if(!H5F_addr_defined(addr) || addr > file->maxaddr)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid end-of-address value")
- /* The real work */
+ /* Call private function */
/* (Note compensating for base address addition in internal routine) */
if(H5FD_set_eoa(file, type, addr - file->base_addr) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file set eoa request failed")
@@ -1189,23 +1215,23 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FDget_eof
+ * Function: H5FDget_eof
*
- * Purpose: Returns the end-of-file address, which is the greater of the
- * end-of-format address and the actual EOF marker. This
- * function is called after an existing file is opened in order
- * for the library to learn the true size of the underlying file
- * and to determine whether the hdf5 data has been truncated.
+ * Purpose: Returns the end-of-file address, which is the greater of the
+ * end-of-format address and the actual EOF marker. This
+ * function is called after an existing file is opened in order
+ * for the library to learn the true size of the underlying file
+ * and to determine whether the hdf5 data has been truncated.
*
- * It is also used when a file is first opened to learn whether
- * the file is empty or not.
+ * It is also used when a file is first opened to learn whether
+ * the file is empty or not.
*
- * It is permissible for the driver to return the maximum address
- * for the file size if the file is not empty.
+ * It is permissible for the driver to return the maximum address
+ * for the file size if the file is not empty.
*
- * Return: Success: The EOF address.
+ * Return: Success: The EOF address.
*
- * Failure: HADDR_UNDEF
+ * Failure: HADDR_UNDEF
*
*-------------------------------------------------------------------------
*/
@@ -1218,10 +1244,12 @@ H5FDget_eof(H5FD_t *file, H5FD_mem_t type)
H5TRACE2("a", "*xMt", file, type);
/* Check arguments */
- if(!file || !file->cls)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer")
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file class pointer cannot be NULL")
- /* The real work */
+ /* Call private function */
if(HADDR_UNDEF == (ret_value = H5FD_get_eof(file, type)))
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file get eof request failed")
@@ -1234,12 +1262,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_get_maxaddr
+ * Function: H5FD_get_maxaddr
*
- * Purpose: Private version of H5FDget_eof()
+ * Purpose: Private version of H5FDget_eof()
*
- * Return: Success: The maximum address allowed in the file.
- * Failure: HADDR_UNDEF
+ * Return: Success: The maximum address allowed in the file.
+ * Failure: HADDR_UNDEF
*
*-------------------------------------------------------------------------
*/
@@ -1250,6 +1278,7 @@ H5FD_get_maxaddr(const H5FD_t *file)
FUNC_ENTER_NOAPI(HADDR_UNDEF)
+ /* Sanity checks */
HDassert(file);
/* Set return value */
@@ -1261,12 +1290,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_get_feature_flags
+ * Function: H5FD_get_feature_flags
*
- * Purpose: Retrieve the feature flags for the VFD
+ * Purpose: Retrieve the feature flags for the VFD
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1275,6 +1303,7 @@ H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
+ /* Sanity checks */
HDassert(file);
HDassert(feature_flags);
@@ -1286,12 +1315,11 @@ H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags)
/*-------------------------------------------------------------------------
- * Function: H5FD_set_feature_flags
+ * Function: H5FD_set_feature_flags
*
- * Purpose: Set the feature flags for the VFD
+ * Purpose: Set the feature flags for the VFD
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1300,6 +1328,7 @@ H5FD_set_feature_flags(H5FD_t *file, unsigned long feature_flags)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
+ /* Sanity checks */
HDassert(file);
/* Set the file's feature flags */
@@ -1310,12 +1339,11 @@ H5FD_set_feature_flags(H5FD_t *file, unsigned long feature_flags)
/*-------------------------------------------------------------------------
- * Function: H5FD_get_fs_type_map
+ * Function: H5FD_get_fs_type_map
*
- * Purpose: Retrieve the free space type mapping for the VFD
+ * Purpose: Retrieve the free space type mapping for the VFD
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1326,8 +1354,9 @@ H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map)
FUNC_ENTER_NOAPI(FAIL)
- /* Sanity check */
- HDassert(file && file->cls);
+ /* Sanity checks */
+ HDassert(file);
+ HDassert(file->cls);
HDassert(type_map);
/* Check for VFD class providing a type map retrieval rouine */
@@ -1346,18 +1375,19 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FDread
+ * Function: H5FDread
*
- * Purpose: Reads SIZE bytes from FILE beginning at address ADDR
- * according to the data transfer property list DXPL_ID (which may
- * be the constant H5P_DEFAULT). The result is written into the
- * buffer BUF.
+ * Purpose: Reads SIZE bytes from FILE beginning at address ADDR
+ * according to the data transfer property list DXPL_ID (which may
+ * be the constant H5P_DEFAULT). The result is written into the
+ * buffer BUF.
*
- * Return: Success: Non-negative. The read result is written into
- * the BUF buffer which should be allocated by
- * the caller.
+ * Return: Success: Non-negative
+ * The read result is written into the BUF buffer
+ * which should be allocated by the caller.
*
- * Failure: Negative. The contents of BUF is undefined.
+ * Failure: Negative
+ * The contents of BUF are undefined.
*
*-------------------------------------------------------------------------
*/
@@ -1365,14 +1395,18 @@ herr_t
H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size,
void *buf/*out*/)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "*xMtiazx", file, type, dxpl_id, addr, size, buf);
- /* Check args */
- if(!file || !file->cls)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer")
+ /* Check arguments */
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")
+ if(!buf)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "result buffer parameter can't be NULL")
/* Get the default dataset transfer property list if the user didn't provide one */
if(H5P_DEFAULT == dxpl_id)
@@ -1380,16 +1414,14 @@ H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size
else
if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list")
- if(!buf)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null result buffer")
/* Set DXPL for operation */
H5CX_set_dxpl(dxpl_id);
- /* Do the real work */
+ /* Call private function */
/* (Note compensating for base address addition in internal routine) */
if(H5FD_read(file, type, addr - file->base_addr, size, buf) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed")
done:
FUNC_LEAVE_API(ret_value)
@@ -1397,16 +1429,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FDwrite
+ * Function: H5FDwrite
*
- * Purpose: Writes SIZE bytes to FILE beginning at address ADDR according
- * to the data transfer property list DXPL_ID (which may be the
- * constant H5P_DEFAULT). The bytes to be written come from the
- * buffer BUF.
+ * Purpose: Writes SIZE bytes to FILE beginning at address ADDR according
+ * to the data transfer property list DXPL_ID (which may be the
+ * constant H5P_DEFAULT). The bytes to be written come from the
+ * buffer BUF.
*
- * Return: Success: Non-negative
- *
- * Failure: Negative
+ * Return: SNon-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
@@ -1414,30 +1444,33 @@ herr_t
H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size,
const void *buf)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "*xMtiaz*x", file, type, dxpl_id, addr, size, buf);
- /* Check args */
- if(!file || !file->cls)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer")
+ /* Check arguments */
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")
+ if(!buf)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "result buffer parameter can't be NULL")
+
/* Get the default dataset transfer property list if the user didn't provide one */
if(H5P_DEFAULT == dxpl_id)
dxpl_id = H5P_DATASET_XFER_DEFAULT;
else
if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list")
- if(!buf)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null buffer")
/* Set DXPL for operation */
H5CX_set_dxpl(dxpl_id);
- /* The real work */
+ /* Call private function */
/* (Note compensating for base address addition in internal routine) */
if(H5FD_write(file, type, addr - file->base_addr, size, buf) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file write request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file write request failed")
done:
FUNC_LEAVE_API(ret_value)
@@ -1445,17 +1478,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FDflush
+ * Function: H5FDflush
*
- * Purpose: Notify driver to flush all cached data. If the driver has no
- * flush method then nothing happens.
- *
- * Return: Success: Non-negative
+ * Purpose: Notify driver to flush all cached data. If the driver has no
+ * flush method then nothing happens.
*
- * Failure: Negative
- *
- * Programmer: Robb Matzke
- * Thursday, July 29, 1999
+ * Return: Non-negative on success/Negative on failureL
*
*-------------------------------------------------------------------------
*/
@@ -1467,9 +1495,12 @@ H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing)
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "*xib", file, dxpl_id, closing);
- /* Check args */
- if(!file || !file->cls)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer")
+ /* Check arguments */
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")
+
if(H5P_DEFAULT == dxpl_id)
dxpl_id = H5P_DATASET_XFER_DEFAULT;
else
@@ -1479,9 +1510,9 @@ H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing)
/* Set DXPL for operation */
H5CX_set_dxpl(dxpl_id);
- /* Do the real work */
+ /* Call private function */
if(H5FD_flush(file, closing) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTFLUSH, FAIL, "file flush request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTFLUSH, FAIL, "file flush request failed")
done:
FUNC_LEAVE_API(ret_value)
@@ -1489,12 +1520,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_flush
+ * Function: H5FD_flush
*
- * Purpose: Private version of H5FDflush()
+ * Purpose: Private version of H5FDflush()
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1506,8 +1536,10 @@ H5FD_flush(H5FD_t *file, hbool_t closing)
FUNC_ENTER_NOAPI(FAIL)
/* Sanity checks */
- HDassert(file && file->cls);
+ HDassert(file);
+ HDassert(file->cls);
+ /* Dispatch to driver */
if(file->cls->flush && (file->cls->flush)(file, H5CX_get_dxpl(), closing) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver flush request failed")
@@ -1517,12 +1549,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FDtruncate
+ * Function: H5FDtruncate
*
- * Purpose: Notify driver to truncate the file back to the allocated size.
+ * Purpose: Notify driver to truncate the file back to the allocated size.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
@@ -1534,9 +1565,11 @@ H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing)
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "*xib", file, dxpl_id, closing);
- /* Check args */
- if(!file || !file->cls)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer")
+ /* Check arguments */
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")
if(H5P_DEFAULT == dxpl_id)
dxpl_id = H5P_DATASET_XFER_DEFAULT;
else
@@ -1546,9 +1579,9 @@ H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing)
/* Set DXPL for operation */
H5CX_set_dxpl(dxpl_id);
- /* Do the real work */
+ /* Call private function */
if(H5FD_truncate(file, closing) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "file flush request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "file flush request failed")
done:
FUNC_LEAVE_API(ret_value)
@@ -1558,22 +1591,22 @@ done:
/*-------------------------------------------------------------------------
* Function: H5FD_truncate
*
- * Purpose: Private version of H5FDtruncate()
+ * Purpose: Private version of H5FDtruncate()
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5FD_truncate(H5FD_t *file, hbool_t closing)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Sanity checks */
- HDassert(file && file->cls);
+ HDassert(file);
+ HDassert(file->cls);
/* Dispatch to driver */
if(file->cls->truncate && (file->cls->truncate)(file, H5CX_get_dxpl(), closing) < 0)
@@ -1585,12 +1618,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FDlock
+ * Function: H5FDlock
*
- * Purpose: Set a file lock
+ * Purpose: Set a file lock
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
@@ -1602,13 +1634,15 @@ H5FDlock(H5FD_t *file, hbool_t rw)
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "*xb", file, rw);
- /* Check args */
- if(!file || !file->cls)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer")
+ /* Check arguments */
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")
- /* The real work */
+ /* Call private function */
if(H5FD_lock(file, rw) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file lock request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file lock request failed")
done:
FUNC_LEAVE_API(ret_value)
@@ -1617,12 +1651,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_lock
+ * Function: H5FD_lock
*
- * Purpose: Private version of H5FDlock()
+ * Purpose: Private version of H5FDlock()
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1633,8 +1666,11 @@ H5FD_lock(H5FD_t *file, hbool_t rw)
FUNC_ENTER_NOAPI(FAIL)
- HDassert(file && file->cls);
+ /* Sanity checks */
+ HDassert(file);
+ HDassert(file->cls);
+ /* Dispatch to driver */
if(file->cls->lock && (file->cls->lock)(file, rw) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver lock request failed")
@@ -1644,12 +1680,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FDunlock
+ * Function: H5FDunlock
*
- * Purpose: Remove a file lock
+ * Purpose: Remove a file lock
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
@@ -1661,13 +1696,15 @@ H5FDunlock(H5FD_t *file)
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "*x", file);
- /* Check args */
- if(!file || !file->cls)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer")
+ /* Check arguments */
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")
- /* The real work */
+ /* Call private function */
if(H5FD_unlock(file) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file unlock request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file unlock request failed")
done:
FUNC_LEAVE_API(ret_value)
@@ -1675,12 +1712,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_unlock
+ * Function: H5FD_unlock
*
- * Purpose: Private version of H5FDunlock()
+ * Purpose: Private version of H5FDunlock()
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1691,8 +1727,11 @@ H5FD_unlock(H5FD_t *file)
FUNC_ENTER_NOAPI(FAIL)
- HDassert(file && file->cls);
+ /* Sanity checks */
+ HDassert(file);
+ HDassert(file->cls);
+ /* Dispatch to driver */
if(file->cls->unlock && (file->cls->unlock)(file) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver unlock request failed")
@@ -1702,13 +1741,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_get_fileno
+ * Function: H5FD_get_fileno
*
- * Purpose: Quick and dirty routine to retrieve the file's 'fileno' value
- * (Mainly added to stop non-file routines from poking about in the
- * H5FD_t data structure)
+ * Purpose: Quick and dirty routine to retrieve the file's 'fileno' value
+ * (Mainly added to stop non-file routines from poking about in the
+ * H5FD_t data structure)
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1717,6 +1756,7 @@ H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
+ /* Sanity checks */
HDassert(file);
HDassert(filenum);
@@ -1733,28 +1773,36 @@ H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum)
* Purpose: Returns a pointer to the file handle of low-level virtual
* file driver.
*
- * Return: Non-negative if succeed; negative otherwise.
- *
- * Programmer: Raymond Lu
- * Sep. 16, 2002
+ * Return: Non-negative on success/Negative on failure
*
*--------------------------------------------------------------------------
*/
herr_t
-H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle)
+H5FDget_vfd_handle(H5FD_t *file, hid_t fapl_id, void **file_handle)
{
- herr_t ret_value;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_API(FAIL)
- H5TRACE3("e", "*xi**x", file, fapl, file_handle);
+ H5TRACE3("e", "*xi**x", file, fapl_id, file_handle);
/* Check arguments */
- HDassert(file);
- HDassert(file_handle);
-
- ret_value = H5FD_get_vfd_handle(file, fapl, file_handle);
+ if(!file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL")
+ if(!file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL")
+ if(FALSE == H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fapl_id parameter is not a file access property list")
+ if(!file_handle)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle parameter cannot be NULL")
+
+ /* Call private function */
+ if(H5FD_get_vfd_handle(file, fapl_id, file_handle) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver")
done:
+ if(FAIL == ret_value)
+ *file_handle = NULL;
+
FUNC_LEAVE_API(ret_value)
} /* end H5FDget_vfd_handle() */
@@ -1762,29 +1810,28 @@ done:
/*--------------------------------------------------------------------------
* Function: H5FD_get_vfd_handle
*
- * Purpose: Retrieve the file handle for file driver.
+ * Purpose: Private version of H5FDget_vfd_handle()
*
- * Return: Non-negative if succeed; negative if fails.
- *
- * Programmer: Raymond Lu
- * Sep. 16, 2002
+ * Return: SUCCEED/FAIL
*
*--------------------------------------------------------------------------
*/
herr_t
-H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle)
+H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl_id, void **file_handle)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- /* Sanity check */
+ /* Sanity checks */
HDassert(file);
+ HDassert(file->cls);
HDassert(file_handle);
+ /* Dispatch to driver */
if(NULL == file->cls->get_handle)
- HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "file driver has no `get_vfd_handle' method")
- if((file->cls->get_handle)(file, fapl, file_handle) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "file driver has no `get_vfd_handle' method")
+ if((file->cls->get_handle)(file, fapl_id, file_handle) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver")
done:
@@ -1797,7 +1844,7 @@ done:
*
* Purpose: Set the base address for the file
*
- * Return: Non-negative if succeed; negative if fails.
+ * Return: SUCCEED (Can't fail)
*
*--------------------------------------------------------------------------
*/
@@ -1806,6 +1853,7 @@ H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
+ /* Sanity checks */
HDassert(file);
HDassert(H5F_addr_defined(base_addr));
@@ -1821,8 +1869,8 @@ H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr)
*
* Purpose: Get the base address for the file
*
- * Return: Success: The absolute base address of the file
- * Failure: The undefined address (HADDR_UNDEF)
+ * Return: Success: The absolute base address of the file
+ * (Can't fail)
*
*--------------------------------------------------------------------------
*/
@@ -1831,6 +1879,7 @@ H5FD_get_base_addr(const H5FD_t *file)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
+ /* Sanity checks */
HDassert(file);
/* Return the file's base address */
@@ -1843,7 +1892,7 @@ H5FD_get_base_addr(const H5FD_t *file)
*
* Purpose: Set "paged_aggr" for the file.
*
- * Return: Non-negative if succeed; negative if fails.
+ * Return: SUCCEED (Can't fail)
*
*--------------------------------------------------------------------------
*/
@@ -1852,6 +1901,7 @@ H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
+ /* Sanity checks */
HDassert(file);
/* Indicate whether paged aggregation for handling file space is enabled or not */
@@ -1869,7 +1919,7 @@ H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged)
* can't use the file to get the driver, the driver ID is passed
* in as a parameter.
*
-* Return: SUCCEED/FAIL
+* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
@@ -1882,6 +1932,7 @@ H5FDdriver_query(hid_t driver_id, unsigned long *flags/*out*/)
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "ix", driver_id, flags);
+ /* Check arguments */
if(NULL == flags)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "flags parameter cannot be NULL")
diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c
index ca1a11d..34c4346 100644
--- a/src/H5FDdirect.c
+++ b/src/H5FDdirect.c
@@ -206,30 +206,27 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_direct_init
+ * Function: H5FD_direct_init
*
- * Purpose: Initialize this driver by registering the driver with the
- * library.
+ * Purpose: Initialize this driver by registering the driver with the
+ * library.
*
- * Return: Success: The driver ID for the direct driver.
- *
- * Failure: Negative.
+ * Return: Success: The driver ID for the direct driver
+ * Failure: H5I_INVALID_HID
*
* Programmer: Raymond Lu
* Wednesday, 20 September 2006
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
hid_t
H5FD_direct_init(void)
{
- hid_t ret_value; /* Return value */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI(H5I_INVALID_HID)
- if (H5I_VFL!=H5I_get_type(H5FD_DIRECT_g))
+ if (H5I_VFL != H5I_get_type(H5FD_DIRECT_g))
H5FD_DIRECT_g = H5FD_register(&H5FD_direct_g,sizeof(H5FD_class_t),FALSE);
/* Set return value */
@@ -237,7 +234,7 @@ H5FD_direct_init(void)
done:
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5FD_direct_init() */
/*---------------------------------------------------------------------------
@@ -291,6 +288,7 @@ H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbu
if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
+ HDmemset(&fa, 0, sizeof(H5FD_direct_fapl_t));
if(boundary != 0)
fa.mboundary = boundary;
else
@@ -417,7 +415,7 @@ static void *
H5FD_direct_fapl_copy(const void *_old_fa)
{
const H5FD_direct_fapl_t *old_fa = (const H5FD_direct_fapl_t*)_old_fa;
- H5FD_direct_fapl_t *new_fa = H5MM_malloc(sizeof(H5FD_direct_fapl_t));
+ H5FD_direct_fapl_t *new_fa = H5MM_calloc(sizeof(H5FD_direct_fapl_t));
FUNC_ENTER_NOAPI_NOINIT_NOERR
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index d383cdb..d110ef7 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -171,28 +171,25 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_family_init
+ * Function: H5FD_family_init
*
- * Purpose: Initialize this driver by registering the driver with the
- * library.
+ * Purpose: Initialize this driver by registering the driver with the
+ * library.
*
- * Return: Success: The driver ID for the family driver.
+ * Return: Success: The driver ID for the family driver
+ * Failure: H5I_INVALID_HID
*
- * Failure: Negative
- *
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, August 4, 1999
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
hid_t
H5FD_family_init(void)
{
- hid_t ret_value = H5FD_FAMILY_g; /* Return value */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI(H5I_INVALID_HID)
if(H5I_VFL != H5I_get_type(H5FD_FAMILY_g))
H5FD_FAMILY_g = H5FD_register(&H5FD_family_g, sizeof(H5FD_class_t), FALSE);
@@ -616,6 +613,13 @@ done:
*
*-------------------------------------------------------------------------
*/
+/* Disable warning for "format not a string literal" here -QAK */
+/*
+ * This pragma only needs to surround the snprintf() calls with
+ * memb_name & temp in the code below, but early (4.4.7, at least) gcc only
+ * allows diagnostic pragmas to be toggled outside of functions.
+ */
+H5_GCC_DIAG_OFF(format-nonliteral)
static H5FD_t *
H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
haddr_t maxaddr)
@@ -718,7 +722,7 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
(0==file->nmembs ? flags : t_flags), file->memb_fapl_id, HADDR_UNDEF);
} H5E_END_TRY;
if (!file->memb[file->nmembs]) {
- if (0==file->nmembs)
+ if (0 == file->nmembs)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open member file")
H5E_clear_stack(NULL);
break;
@@ -726,7 +730,7 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
file->nmembs++;
}
- /* If the file is reopened and there's only one member file existing, this file maybe
+ /* If the file is reopened and there's only one member file existing, this file may be
* smaller than the size specified through H5Pset_fapl_family(). Update the actual
* member size.
*/
@@ -766,6 +770,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_family_open() */
+H5_GCC_DIAG_ON(format-nonliteral)
/*-------------------------------------------------------------------------
@@ -945,6 +950,13 @@ H5FD_family_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type)
*
*-------------------------------------------------------------------------
*/
+/* Disable warning for "format not a string literal" here -QAK */
+/*
+ * This pragma only needs to surround the snprintf() call with
+ * memb_name in the code below, but early (4.4.7, at least) gcc only
+ * allows diagnostic pragmas to be toggled outside of functions.
+ */
+H5_GCC_DIAG_OFF(format-nonliteral)
static herr_t
H5FD_family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa)
{
@@ -1011,6 +1023,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
}
+H5_GCC_DIAG_ON(format-nonliteral)
/*-------------------------------------------------------------------------
diff --git a/src/H5FDint.c b/src/H5FDint.c
index b46ecf2..8a2148a 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
*
*-------------------------------------------------------------------------
*/
diff --git a/src/H5FDlog.c b/src/H5FDlog.c
index 0e50df0..f649bc4 100644
--- a/src/H5FDlog.c
+++ b/src/H5FDlog.c
@@ -252,8 +252,8 @@ done:
* Purpose: Initialize this driver by registering the driver with the
* library.
*
- * Return: Success: The driver ID for the log driver.
- * Failure: Negative.
+ * Return: Success: The driver ID for the log driver
+ * Failure: H5I_INVALID_HID
*
* Programmer: Robb Matzke
* Thursday, July 29, 1999
@@ -265,7 +265,7 @@ H5FD_log_init(void)
{
hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI(H5I_INVALID_HID)
if(H5I_VFL != H5I_get_type(H5FD_LOG_g))
H5FD_LOG_g = H5FD_register(&H5FD_log_g, sizeof(H5FD_class_t), FALSE);
@@ -329,16 +329,24 @@ H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, si
if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
- /* This shallow copy is correct! The string will be properly
- * copied deep down in the H5P code.
+ HDmemset(&fa, 0, sizeof(H5FD_log_fapl_t));
+
+ /* Duplicate the log file string
+ * A little wasteful, since this string will just be copied later, but
+ * passing it in as a pointer sets off a chain of impossible-to-resolve
+ * const cast warnings.
*/
- fa.logfile = (char *)logfile;
+ if(logfile != NULL && NULL == (fa.logfile = H5MM_xstrdup(logfile)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to copy log file name")
fa.flags = flags;
fa.buf_size = buf_size;
ret_value = H5P_set_driver(plist, H5FD_LOG, &fa);
done:
+ if(fa.logfile)
+ H5MM_free(fa.logfile);
+
FUNC_LEAVE_API(ret_value)
} /* end H5Pset_fapl_log() */
diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c
index 87f9e09..9a0fa5b 100644
--- a/src/H5FDmpio.c
+++ b/src/H5FDmpio.c
@@ -15,7 +15,7 @@
* Programmer: Robb Matzke <matzke@llnl.gov>
* Thursday, July 29, 1999
*
- * Purpose: This is the MPI-2 I/O driver.
+ * Purpose: This is the MPI-2 I/O driver.
*
*/
diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c
index 4e24fda..72f4da5 100644
--- a/src/H5FDmulti.c
+++ b/src/H5FDmulti.c
@@ -26,11 +26,6 @@
#include <stdlib.h>
#include <string.h>
-/* Disable certain warnings in PC-Lint: */
-/*lint --emacro( {534, 830}, H5P_DEFAULT, H5P_FILE_ACCESS, H5P_DATASET_XFER) */
-/*lint --emacro( {534, 830}, H5FD_MULTI) */
-/*lint -esym( 534, H5Eclear2, H5Epush2) */
-
#include "hdf5.h"
@@ -211,16 +206,15 @@ my_strdup(const char *s)
/*-------------------------------------------------------------------------
- * Function: H5FD_multi_init
- *
- * Purpose: Initialize this driver by registering the driver with the
- * library.
+ * Function: H5FD_multi_init
*
- * Return: Success: The driver ID for the multi driver.
+ * Purpose: Initialize this driver by registering the driver with the
+ * library.
*
- * Failure: Negative
+ * Return: Success: The driver ID for the multi driver
+ * Failure: H5I_INVALID_HID
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, August 4, 1999
*
*-------------------------------------------------------------------------
@@ -231,11 +225,11 @@ H5FD_multi_init(void)
/* Clear the error stack */
H5Eclear2(H5E_DEFAULT);
- if(H5I_VFL!=H5Iget_type(H5FD_MULTI_g))
+ if(H5I_VFL != H5Iget_type(H5FD_MULTI_g))
H5FD_MULTI_g = H5FDregister(&H5FD_multi_g);
return H5FD_MULTI_g;
-}
+} /* end H5FD_multi_init() */
/*---------------------------------------------------------------------------
@@ -497,6 +491,7 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map,
* Initialize driver specific information. No need to copy it into the FA
* struct since all members will be copied by H5Pset_driver().
*/
+ memset(&fa, 0, sizeof(H5FD_multi_fapl_t));
memcpy(fa.memb_map, memb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t));
memcpy(fa.memb_fapl, memb_fapl, H5FD_MEM_NTYPES*sizeof(hid_t));
memcpy(fa.memb_name, memb_name, H5FD_MEM_NTYPES*sizeof(char*));
@@ -776,7 +771,7 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf)
buf += nseen*2*8;
if (H5Tconvert(H5T_STD_U64LE, H5T_NATIVE_HADDR, nseen*2, x, NULL, H5P_DEFAULT)<0)
H5Epush_ret(func, H5E_ERR_CLS, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1)
- ap = (haddr_t*)x;
+ ap = (haddr_t*)((void *)x); /* Extra (void *) cast to quiet "cast to create alignment" warning - 2019/07/05, QAK */
UNIQUE_MEMBERS(map, mt) {
memb_addr[_unmapped] = *ap++;
memb_eoa[_unmapped] = *ap++;
@@ -892,7 +887,7 @@ static void *
H5FD_multi_fapl_copy(const void *_old_fa)
{
const H5FD_multi_fapl_t *old_fa = (const H5FD_multi_fapl_t*)_old_fa;
- H5FD_multi_fapl_t *new_fa = (H5FD_multi_fapl_t *)malloc(sizeof(H5FD_multi_fapl_t));
+ H5FD_multi_fapl_t *new_fa = (H5FD_multi_fapl_t *)calloc(1, sizeof(H5FD_multi_fapl_t));
int nerrors = 0;
static const char *func="H5FD_multi_fapl_copy"; /* Function Name for error reporting */
@@ -986,8 +981,7 @@ H5FD_multi_fapl_free(void *_fa)
*-------------------------------------------------------------------------
*/
static H5FD_t *
-H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id,
- haddr_t maxaddr)
+H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
{
H5FD_multi_t *file=NULL;
hid_t close_fapl=-1;
@@ -1001,7 +995,7 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id,
/* Check arguments */
if (!name || !*name)
H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL)
- if (0==maxaddr || HADDR_UNDEF==maxaddr)
+ if (0 == maxaddr || HADDR_UNDEF == maxaddr)
H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL)
/*
@@ -1012,41 +1006,41 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id,
*/
if(NULL == (file = (H5FD_multi_t *)calloc((size_t)1, sizeof(H5FD_multi_t))))
H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL)
- if(H5P_FILE_ACCESS_DEFAULT==fapl_id || H5FD_MULTI!=H5Pget_driver(fapl_id)) {
+ if(H5P_FILE_ACCESS_DEFAULT == fapl_id || H5FD_MULTI != H5Pget_driver(fapl_id)) {
close_fapl = fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if(H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE)<0)
+ if(H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0)
H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTSET, "can't set property value", error)
}
fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id);
assert(fa);
ALL_MEMBERS(mt) {
- file->fa.memb_map[mt] = fa->memb_map[mt];
- file->fa.memb_addr[mt] = fa->memb_addr[mt];
- if (fa->memb_fapl[mt]>=0)
- H5Iinc_ref(fa->memb_fapl[mt]);
+ file->fa.memb_map[mt] = fa->memb_map[mt];
+ file->fa.memb_addr[mt] = fa->memb_addr[mt];
+ if (fa->memb_fapl[mt] >= 0)
+ H5Iinc_ref(fa->memb_fapl[mt]);
file->fa.memb_fapl[mt] = fa->memb_fapl[mt];
- if (fa->memb_name[mt])
- file->fa.memb_name[mt] = my_strdup(fa->memb_name[mt]);
- else
- file->fa.memb_name[mt] = NULL;
+ if (fa->memb_name[mt])
+ file->fa.memb_name[mt] = my_strdup(fa->memb_name[mt]);
+ else
+ file->fa.memb_name[mt] = NULL;
} END_MEMBERS;
file->fa.relax = fa->relax;
file->flags = flags;
file->name = my_strdup(name);
- if (close_fapl>=0)
- if(H5Pclose(close_fapl)<0)
+ if (close_fapl >= 0)
+ if(H5Pclose(close_fapl) < 0)
H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTCLOSEOBJ, "can't close property list", error)
/* Compute derived properties and open member files */
- if (compute_next(file)<0)
+ if (compute_next(file) < 0)
H5Epush_goto(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", error);
- if (open_members(file)<0)
+ if (open_members(file) < 0)
H5Epush_goto(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", error);
/* We must have opened at least the superblock file */
- if (H5FD_MEM_DEFAULT==(m=file->fa.memb_map[H5FD_MEM_SUPER]))
+ if (H5FD_MEM_DEFAULT == (m = file->fa.memb_map[H5FD_MEM_SUPER]))
m = H5FD_MEM_SUPER;
- if (NULL==file->memb[m])
+ if (NULL == file->memb[m])
goto error;
return (H5FD_t*)file;
@@ -1054,13 +1048,14 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id,
error:
/* Cleanup and fail */
if (file) {
- ALL_MEMBERS(mt) {
- if (file->memb[mt]) (void)H5FDclose(file->memb[mt]);
- if (file->fa.memb_fapl[mt]>=0) (void)H5Idec_ref(file->fa.memb_fapl[mt]);
- if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]);
- } END_MEMBERS;
- if (file->name) free(file->name);
- free(file);
+ ALL_MEMBERS(mt) {
+ if (file->memb[mt]) (void)H5FDclose(file->memb[mt]);
+ if (file->fa.memb_fapl[mt] >= 0) (void)H5Idec_ref(file->fa.memb_fapl[mt]);
+ if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]);
+ } END_MEMBERS;
+ if (file->name)
+ free(file->name);
+ free(file);
}
return NULL;
}
@@ -1960,38 +1955,47 @@ compute_next(H5FD_multi_t *file)
*
*-------------------------------------------------------------------------
*/
+/* Disable warning for "format not a string literal" here -QAK */
+/*
+ * This pragma only needs to surround the snprintf() call with
+ * tmp in the code below, but early (4.4.7, at least) gcc only
+ * allows diagnostic pragmas to be toggled outside of functions.
+ */
+H5_GCC_DIAG_OFF(format-nonliteral)
static int
open_members(H5FD_multi_t *file)
{
- char tmp[H5FD_MULT_MAX_FILE_NAME_LEN];
- int nerrors=0;
+ char tmp[H5FD_MULT_MAX_FILE_NAME_LEN];
+ int nerrors = 0;
static const char *func="(H5FD_multi)open_members"; /* Function Name for error reporting */
/* Clear the error stack */
H5Eclear2(H5E_DEFAULT);
UNIQUE_MEMBERS(file->fa.memb_map, mt) {
- if(file->memb[mt])
+ if(file->memb[mt])
continue; /*already open*/
- assert(file->fa.memb_name[mt]);
+ assert(file->fa.memb_name[mt]);
/* Note: This truncates the user's filename down to only sizeof(tmp)
* characters. -QK & JK, 2013/01/17
*/
- sprintf(tmp, file->fa.memb_name[mt], file->name);
-
- H5E_BEGIN_TRY {
- file->memb[mt] = H5FDopen(tmp, file->flags, file->fa.memb_fapl[mt], HADDR_UNDEF);
- } H5E_END_TRY;
- if(!file->memb[mt]) {
- if(!file->fa.relax || (file->flags & H5F_ACC_RDWR))
- nerrors++;
- }
+ sprintf(tmp, file->fa.memb_name[mt], file->name);
+ tmp[sizeof(tmp) - 1] = '\0';
+
+ H5E_BEGIN_TRY {
+ file->memb[mt] = H5FDopen(tmp, file->flags, file->fa.memb_fapl[mt], HADDR_UNDEF);
+ } H5E_END_TRY;
+ if(!file->memb[mt]) {
+ if(!file->fa.relax || (file->flags & H5F_ACC_RDWR))
+ nerrors++;
+ }
} END_MEMBERS;
if (nerrors)
H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error opening member files", -1)
return 0;
}
+H5_GCC_DIAG_ON(format-nonliteral)
#ifdef _H5private_H
diff --git a/src/H5FDpkg.h b/src/H5FDpkg.h
index efebe1d..22b5d17 100644
--- a/src/H5FDpkg.h
+++ b/src/H5FDpkg.h
@@ -50,7 +50,7 @@
/* Package Private Prototypes */
/******************************/
H5_DLL haddr_t H5FD__alloc_real(H5FD_t *file, H5FD_mem_t type, hsize_t size, haddr_t *align_addr, hsize_t *align_size);
-H5_DLL herr_t H5FD_free_real(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size);
+H5_DLL herr_t H5FD__free_real(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size);
/* Testing functions */
#ifdef H5FD_TESTING
diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h
index c4f8006..7e9e610 100644
--- a/src/H5FDprivate.h
+++ b/src/H5FDprivate.h
@@ -123,7 +123,7 @@ H5_DLL hsize_t H5FD_sb_size(H5FD_t *file);
H5_DLL herr_t H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf);
H5_DLL herr_t H5FD_sb_load(H5FD_t *file, const char *name, const uint8_t *buf);
H5_DLL void *H5FD_fapl_get(H5FD_t *file);
-H5_DLL herr_t H5FD_fapl_close(hid_t driver_id, const void *fapl);
+H5_DLL herr_t H5FD_free_driver_info(hid_t driver_id, const void *driver_info);
H5_DLL hid_t H5FD_register(const void *cls, size_t size, hbool_t app_ref);
H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id,
haddr_t maxaddr);
@@ -143,10 +143,8 @@ H5_DLL haddr_t H5FD_get_maxaddr(const H5FD_t *file);
H5_DLL herr_t H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags);
H5_DLL herr_t H5FD_set_feature_flags(H5FD_t *file, unsigned long feature_flags);
H5_DLL herr_t H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map);
-H5_DLL herr_t H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr,
- size_t size, void *buf/*out*/);
-H5_DLL herr_t H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr,
- size_t size, const void *buf);
+H5_DLL herr_t H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/);
+H5_DLL herr_t H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf);
H5_DLL herr_t H5FD_flush(H5FD_t *file, hbool_t closing);
H5_DLL herr_t H5FD_truncate(H5FD_t *file, hbool_t closing);
H5_DLL herr_t H5FD_lock(H5FD_t *file, hbool_t rw);
diff --git a/src/H5FDros3.c b/src/H5FDros3.c
index 75fcfd7..d99272c 100644
--- a/src/H5FDros3.c
+++ b/src/H5FDros3.c
@@ -325,7 +325,9 @@ hid_t
H5FD_ros3_init(void)
{
hid_t ret_value = H5I_INVALID_HID;
+#if ROS3_STATS
unsigned int bin_i;
+#endif
FUNC_ENTER_NOAPI(FAIL)
@@ -1347,7 +1349,7 @@ H5FD_ros3_cmp(
}
/* FAPL: AWS_REGION */
- if (f1->fa.aws_region[0] != '\0' && f1->fa.aws_region[0] != '\0') {
+ if (f1->fa.aws_region[0] != '\0' && f2->fa.aws_region[0] != '\0') {
if (HDstrcmp(f1->fa.aws_region, f2->fa.aws_region)) {
HGOTO_DONE(-1);
}
@@ -1362,7 +1364,7 @@ H5FD_ros3_cmp(
}
/* FAPL: SECRET_ID */
- if (f1->fa.secret_id[0] != '\0' && f1->fa.secret_id[0] != '\0') {
+ if (f1->fa.secret_id[0] != '\0' && f2->fa.secret_id[0] != '\0') {
if (HDstrcmp(f1->fa.secret_id, f2->fa.secret_id)) {
HGOTO_DONE(-1);
}
@@ -1377,7 +1379,7 @@ H5FD_ros3_cmp(
}
/* FAPL: SECRET_KEY */
- if (f1->fa.secret_key[0] != '\0' && f1->fa.secret_key[0] != '\0') {
+ if (f1->fa.secret_key[0] != '\0' && f2->fa.secret_key[0] != '\0') {
if (HDstrcmp(f1->fa.secret_key, f2->fa.secret_key)) {
HGOTO_DONE(-1);
}
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index b316666..ba4750e 100644
--- a/src/H5FDsec2.c
+++ b/src/H5FDsec2.c
@@ -208,8 +208,8 @@ done:
* Purpose: Initialize this driver by registering the driver with the
* library.
*
- * Return: Success: The driver ID for the sec2 driver.
- * Failure: Negative
+ * Return: Success: The driver ID for the sec2 driver
+ * Failure: H5I_INVALID_HID
*
* Programmer: Robb Matzke
* Thursday, July 29, 1999
@@ -221,7 +221,7 @@ H5FD_sec2_init(void)
{
hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI(H5I_INVALID_HID)
if(H5I_VFL != H5I_get_type(H5FD_SEC2_g))
H5FD_SEC2_g = H5FD_register(&H5FD_sec2_g, sizeof(H5FD_class_t), FALSE);
diff --git a/src/H5FDspace.c b/src/H5FDspace.c
index e158a44..e1f0cb2 100644
--- a/src/H5FDspace.c
+++ b/src/H5FDspace.c
@@ -38,6 +38,7 @@
#include "H5Fprivate.h" /* File access */
#include "H5FDpkg.h" /* File Drivers */
#include "H5FDmulti.h" /* Usage-partitioned file family */
+#include "H5FLprivate.h" /* Free lists */
/****************/
@@ -273,7 +274,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_free_real
+ * Function: H5FD__free_real
*
* Purpose: Release space back to the VFD
*
@@ -286,11 +287,11 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5FD_free_real(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size)
+H5FD__free_real(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
/* Check args */
HDassert(file);
@@ -348,13 +349,13 @@ HDfprintf(stderr, "%s: LEAKED MEMORY!!! type = %u, addr = %a, size = %Hu\n", FUN
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FD_free_real() */
+} /* end H5FD__free_real() */
/*-------------------------------------------------------------------------
* Function: H5FD_free
*
- * Purpose: Wrapper for H5FD_free_real, to make certain EOA changes are
+ * Purpose: Wrapper for H5FD__free_real, to make certain EOA changes are
* reflected in superblock.
*
* Note: When the metadata cache routines are updated to allow
@@ -383,7 +384,7 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t addr, hsize_t size)
HDassert(size > 0);
/* Call the real 'free' routine */
- if(H5FD_free_real(file, type, addr, size) < 0)
+ if(H5FD__free_real(file, type, addr, size) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "real 'free' request failed")
/* Mark EOA info dirty in cache, so change will get encoded */
@@ -414,8 +415,7 @@ done:
*-------------------------------------------------------------------------
*/
htri_t
-H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t blk_end,
- hsize_t extra_requested)
+H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t blk_end, hsize_t extra_requested)
{
haddr_t eoa; /* End of allocated space in file */
htri_t ret_value = FALSE; /* Return value */
diff --git a/src/H5Fint.c b/src/H5Fint.c
index abc2840..73776ff 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -104,19 +104,19 @@ H5FL_DEFINE(H5F_shared_t);
/*-------------------------------------------------------------------------
- * Function: H5F_get_access_plist
+ * Function: H5F_get_access_plist
*
- * Purpose: Returns a copy of the file access property list of the
- * specified file.
+ * Purpose: Returns a copy of the file access property list of the
+ * specified file.
*
* NOTE: Make sure that, if you are going to overwrite
* information in the copied property list that was
* previously opened and assigned to the property list, then
* you must close it before overwriting the values.
*
- * Return: Success: Object ID for a copy of the file access
- * property list.
- * Failure: FAIL
+ * Return: Success: Object ID for a copy of the file access
+ * property list.
+ * Failure: H5I_INVALID_HID
*-------------------------------------------------------------------------
*/
hid_t
@@ -127,71 +127,71 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref)
H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */
hbool_t driver_prop_copied = FALSE; /* Whether the driver property has been set up */
unsigned efc_size = 0;
- hid_t ret_value = SUCCEED; /* Return value */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI(H5I_INVALID_HID)
/* Check args */
HDassert(f);
/* Make a copy of the default file access property list */
if(NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list")
if((ret_value = H5P_copy_plist(old_plist, app_ref)) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy file access property list")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "can't copy file access property list")
if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(ret_value)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list")
/* Copy properties of the file access property list */
if(H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set initial metadata cache resize config.")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set initial metadata cache resize config.")
if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache number of slots")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set data cache number of slots")
if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set data cache byte size")
if(H5P_set(new_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set preempt read chunks")
if(H5P_set(new_plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment threshold")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set alignment threshold")
if(H5P_set(new_plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set alignment")
if(H5P_set(new_plist, H5F_ACS_GARBG_COLCT_REF_NAME, &(f->shared->gc_ref)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set garbage collect reference")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set garbage collect reference")
if(H5P_set(new_plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache size")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set metadata cache size")
if(H5P_set(new_plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't sieve buffer size")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't sieve buffer size")
if(H5P_set(new_plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->sdata_aggr.alloc_size)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'small data' cache size")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'small data' cache size")
if(H5P_set(new_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &f->shared->low_bound) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'low' bound for library format versions")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'low' bound for library format versions")
if(H5P_set(new_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &f->shared->high_bound) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'high' bound for library format versions")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'high' bound for library format versions")
if(H5P_set(new_plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &(f->shared->read_attempts)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'read attempts ' flag")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'read attempts ' flag")
if(H5P_set(new_plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object flush callback")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set object flush callback")
if(f->shared->efc)
efc_size = H5F__efc_max_nfiles(f->shared->efc);
if(H5P_set(new_plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set elink file cache size")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set elink file cache size")
if(f->shared->page_buf != NULL) {
if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &(f->shared->page_buf->max_size)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set page buffer size")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set page buffer size")
if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &(f->shared->page_buf->min_meta_perc)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set minimum metadata fraction of page buffer")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set minimum metadata fraction of page buffer")
if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &(f->shared->page_buf->min_raw_perc)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set minimum raw data fraction of page buffer")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set minimum raw data fraction of page buffer")
} /* end if */
#ifdef H5_HAVE_PARALLEL
if(H5P_set(new_plist, H5_COLL_MD_READ_FLAG_NAME, &(f->coll_md_read)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set collective metadata read flag")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set collective metadata read flag")
if(H5P_set(new_plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &(f->coll_md_write)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set collective metadata read flag")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set collective metadata read flag")
#endif /* H5_HAVE_PARALLEL */
if(H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, &(f->shared->mdc_initCacheImageCfg)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set initial metadata cache resize config.")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set initial metadata cache resize config.")
/* Prepare the driver property */
driver_prop.driver_id = f->shared->lf->driver_id;
@@ -200,18 +200,18 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref)
/* Set the driver property */
if(H5P_set(new_plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver ID & info")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set file driver ID & info")
/* Set the file close degree appropriately */
if(f->shared->fc_degree == H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->lf->cls->fc_degree)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree")
else if(f->shared->fc_degree != H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->fc_degree)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree")
done:
/* Release the copy of the driver info, if it was set up */
- if(driver_prop_copied && H5FD_fapl_close(driver_prop.driver_id, driver_prop.driver_info) < 0)
- HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close copy of driver info")
+ if(driver_prop_copied && H5FD_free_driver_info(driver_prop.driver_id, driver_prop.driver_info) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, H5I_INVALID_HID, "can't close copy of driver info")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_get_access_plist() */
@@ -238,7 +238,7 @@ H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref, size_t *obj_i
/* Perform the query */
if((ret_value = H5F_get_objects(f, types, 0, NULL, app_ref, obj_id_count_ptr)) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_objects failed")
+ HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_objects failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -265,7 +265,7 @@ H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *oid_list
/* Perform the query */
if((ret_value = H5F_get_objects(f, types, max_objs, oid_list, app_ref, obj_id_count_ptr)) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_objects failed")
+ HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_objects failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -273,19 +273,19 @@ done:
/*---------------------------------------------------------------------------
- * Function: H5F_get_objects
+ * Function: H5F__get_objects
*
- * Purpose: This function is called by H5F_get_obj_count or
- * H5F_get_obj_ids to get number of object IDs and/or a
- * list of opened object IDs (in return value).
+ * Purpose: This function is called by H5F_get_obj_count or
+ * H5F_get_obj_ids to get number of object IDs and/or a
+ * list of opened object IDs (in return value).
*
- * Return: Non-negative on success; Can't fail.
+ * Return: SUCCEED/FAIL
*---------------------------------------------------------------------------
*/
herr_t
H5F_get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr)
{
- size_t obj_id_count=0; /* Number of open IDs */
+ size_t obj_id_count = 0; /* Number of open IDs */
H5F_olist_t olist; /* Structure to hold search results */
herr_t ret_value = SUCCEED; /* Return value */
@@ -323,7 +323,7 @@ H5F_get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_
* search through dataset IDs to count number of datasets, and put their
* IDs on the object list */
if(!olist.max_nobjs || (olist.max_nobjs && olist.list_index<olist.max_nobjs)) {
- if (types & H5F_OBJ_DATASET) {
+ if(types & H5F_OBJ_DATASET) {
olist.obj_type = H5I_DATASET;
if(H5I_iterate(H5I_DATASET, H5F_get_objects_cb, &olist, app_ref) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(2)")
@@ -339,7 +339,7 @@ H5F_get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_
olist.obj_type = H5I_GROUP;
if(H5I_iterate(H5I_GROUP, H5F_get_objects_cb, &olist, app_ref) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(3)")
- } /* end if */
+ }
}
/* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero),
@@ -375,14 +375,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_get_objects_cb
+ * Function: H5F_get_objects_cb
*
- * Purpose: H5F_get_objects' callback function. It verifies if an
- * object is in the file, and either count it or put its ID
- * on the list.
+ * Purpose: H5F__get_objects' callback function. It verifies if an
+ * object is in the file, and either count it or put its ID
+ * on the list.
*
- * Return: H5_ITER_STOP if the array of object IDs is filled up.
- * H5_ITER_CONT otherwise.
+ * Return: H5_ITER_STOP if the array of object IDs is filled up.
+ * H5_ITER_CONT otherwise.
*-------------------------------------------------------------------------
*/
static int
@@ -408,7 +408,7 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key)
add_obj = TRUE;
} /* end if */
} /* end if */
- else { /* either count opened object IDs or put the IDs on the list */
+ else { /* Either count opened object IDs or put the IDs on the list */
H5O_loc_t *oloc; /* Group entry info for object */
switch(olist->obj_type) {
@@ -473,7 +473,8 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key)
/* Check if we've filled up the array. Return H5_ITER_STOP only if
* we have filled up the array. Otherwise return H5_ITER_CONT(RET_VALUE is
* preset to H5_ITER_CONT) because H5I_iterate needs the return value of
- * H5_ITER_CONT to continue the iteration. */
+ * H5_ITER_CONT to continue the iteration.
+ */
if(olist->max_nobjs > 0 && olist->list_index >= olist->max_nobjs)
HGOTO_DONE(H5_ITER_STOP) /* Indicate that the iterator should stop */
} /* end if */
@@ -513,7 +514,6 @@ H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize)
* Purpose: Prepend PREFIX to FILE_NAME and store in FULL_NAME
*
* Return: SUCCEED/FAIL
- *
*--------------------------------------------------------------------------*/
static herr_t
H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/)
@@ -528,11 +528,11 @@ H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out
fname_len = HDstrlen(file_name);
/* Allocate a buffer to hold the filename + prefix + possibly the delimiter + terminating null byte */
- if(NULL == (*full_name = (char *)H5MM_malloc(prefix_len + fname_len + 2)))
+ if(NULL == (*full_name = (char *)H5MM_malloc(prefix_len + fname_len + 2 + 2))) /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */
HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate filename buffer")
/* Compose the full file name */
- HDsnprintf(*full_name, (prefix_len + fname_len + 2), "%s%s%s", prefix,
+ HDsnprintf(*full_name, (prefix_len + fname_len + 2 + 2), "%s%s%s", prefix, /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */
((prefix_len == 0 || H5_CHECK_DELIMITER(prefix[prefix_len - 1])) ? "" : H5_DIR_SEPS), file_name);
done:
@@ -541,14 +541,14 @@ done:
/*--------------------------------------------------------------------------
- * Function: H5F__getenv_prefix_name
+ * Function: H5F__getenv_prefix_name
*
- * Purpose: Get the first pathname in the list of pathnames stored in env_prefix,
- * which is separated by the environment delimiter.
- * env_prefix is modified to point to the remaining pathnames
- * in the list.
+ * Purpose: Get the first pathname in the list of pathnames stored in env_prefix,
+ * which is separated by the environment delimiter.
+ * env_prefix is modified to point to the remaining pathnames
+ * in the list.
*
- * Return: A pointer to a pathname
+ * Return: A pointer to a pathname (can't fail but can return NULL)
--------------------------------------------------------------------------*/
static char *
H5F__getenv_prefix_name(char **env_prefix/*in,out*/)
@@ -815,26 +815,26 @@ done:
htri_t
H5F__is_hdf5(const char *name)
{
- H5FD_t *file = NULL; /* Low-level file struct */
- haddr_t sig_addr; /* Addess of hdf5 file signature */
- htri_t ret_value = FAIL; /* Return value */
+ H5FD_t *file = NULL; /* Low-level file struct */
+ haddr_t sig_addr = HADDR_UNDEF; /* Addess of hdf5 file signature */
+ htri_t ret_value = FAIL; /* Return value */
FUNC_ENTER_PACKAGE
/* Open the file at the virtual file layer */
if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, H5P_FILE_ACCESS_DEFAULT, HADDR_UNDEF)))
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to open file")
/* The file is an hdf5 file if the hdf5 file signature can be found */
if(H5FD_locate_signature(file, &sig_addr) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature")
+ HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "error while trying to locate file signature")
ret_value = (HADDR_UNDEF != sig_addr);
done:
/* Close the file */
if(file)
- if(H5FD_close(file) < 0 && ret_value >= 0)
- HDONE_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
+ if(H5FD_close(file) < 0 && TRUE == ret_value)
+ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F__is_hdf5() */
@@ -1103,14 +1103,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F__dest
+ * Function: H5F__dest
*
- * Purpose: Destroys a file structure. This function flushes the cache
- * but doesn't do any other cleanup other than freeing memory
- * for the file struct. The shared info for the file is freed
- * only when its reference count reaches zero.
+ * Purpose: Destroys a file structure. This function flushes the cache
+ * but doesn't do any other cleanup other than freeing memory
+ * for the file struct. The shared info for the file is freed
+ * only when its reference count reaches zero.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
herr_t
@@ -1433,15 +1433,15 @@ H5F_t *
H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
{
H5F_t *file = NULL; /*the success return value */
- H5F_shared_t *shared = NULL; /*shared part of `file' */
+ H5F_shared_t *shared = NULL; /*shared part of `file' */
H5FD_t *lf = NULL; /*file driver part of `shared' */
unsigned tent_flags; /*tentative flags */
H5FD_class_t *drvr; /*file driver class info */
H5P_genplist_t *a_plist; /*file access property list */
H5F_close_degree_t fc_degree; /*file close degree */
size_t page_buf_size;
- unsigned page_buf_min_meta_perc;
- unsigned page_buf_min_raw_perc;
+ unsigned page_buf_min_meta_perc = 0;
+ unsigned page_buf_min_raw_perc = 0;
hbool_t set_flag = FALSE; /*set the status_flags in the superblock */
hbool_t clear = FALSE; /*clear the status_flags */
hbool_t evict_on_close; /* evict on close value from plist */
@@ -1646,7 +1646,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
if(H5G_mkroot(file, TRUE) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create/open root group")
} /* end if */
- else if (1 == shared->nrefs) {
+ else if(1 == shared->nrefs) {
/* Read the superblock if it hasn't been read before. */
if(H5F__super_read(file, a_plist, TRUE) < 0)
HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock")
@@ -1773,11 +1773,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_flush_phase1
+ * Function: H5F_flush_phase1
*
- * Purpose: First phase of flushing cached data.
+ * Purpose: First phase of flushing cached data.
+ *
+ * Return: SUCCEED/FAIL
*
- * Return: Non-negative on success/Negative on failure
*-------------------------------------------------------------------------
*/
static herr_t
@@ -1810,11 +1811,12 @@ H5F__flush_phase1(H5F_t *f)
/*-------------------------------------------------------------------------
- * Function: H5F__flush_phase2
+ * Function: H5F__flush_phase2
*
- * Purpose: Second phase of flushing cached data.
+ * Purpose: Second phase of flushing cached data.
+ *
+ * Return: SUCCEED/FAIL
*
- * Return: Non-negative on success/Negative on failure
*-------------------------------------------------------------------------
*/
static herr_t
@@ -1833,13 +1835,14 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing)
HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache")
#ifdef H5_HAVE_PARALLEL
- if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI))
+ if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) {
/* Since we just returned from a call to H5AC_flush(), we just
* passed through a barrier. Hence we can skip the barrier on
* entry to the mpio file driver truncate call below, and the first
* barrier in the following call to flush the cache again.
*/
H5CX_set_mpi_file_flushing(TRUE);
+ }
#endif /* H5_HAVE_PARALLEL */
/* Truncate the file to the current allocated size */
@@ -1878,11 +1881,12 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing)
/*-------------------------------------------------------------------------
- * Function: H5F__flush
+ * Function: H5F__flush
*
- * Purpose: Flushes cached data.
+ * Purpose: Flushes cached data.
+ *
+ * Return: SUCCEED/FAIL
*
- * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
herr_t
@@ -1914,10 +1918,7 @@ H5F__flush(H5F_t *f)
*
* Purpose: Internal routine to close a file.
*
- * Return: Non-negative on success / Negative on failure
- *
- * Programmer: Quincey Koziol
- * December 16, 2017
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1985,7 +1986,8 @@ H5F__close_cb(H5F_t *f)
HDassert(f->file_id > 0); /* This routine should only be called when a file ID's ref count drops to zero */
/* Perform checks for "semi" file close degree here, since closing the
- * file is not allowed if there are objects still open */
+ * file is not allowed if there are objects still open.
+ */
if(f->shared->fc_degree == H5F_CLOSE_SEMI) {
unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */
unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */
@@ -1997,13 +1999,14 @@ H5F__close_cb(H5F_t *f)
/* If there are no other file IDs open on this file/mount hier., but
* there are still open objects, issue an error and bail out now,
* without decrementing the file ID's reference count and triggering
- * a "real" attempt at closing the file */
+ * a "real" attempt at closing the file.
+ */
if(nopen_files == 1 && nopen_objs > 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, there are objects still open")
- } /* end if */
+ }
/* Reset the file ID for this file */
- f->file_id = -1;
+ f->file_id = H5I_INVALID_HID;
/* Attempt to close the file/mount hierarchy */
if(H5F_try_close(f, NULL) < 0)
@@ -2015,14 +2018,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_try_close
+ * Function: H5F_try_close
*
- * Purpose: Attempts to close a file due to one of several actions:
- * - The reference count on the file ID dropped to zero
- * - The last open object was closed in the file
- * - The file was unmounted
+ * Purpose: Attempts to close a file due to one of several actions:
+ * - The reference count on the file ID dropped to zero
+ * - The last open object was closed in the file
+ * - The file was unmounted
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -2053,7 +2056,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/)
if(was_closed)
*was_closed = TRUE;
HGOTO_DONE(SUCCEED)
- } /* end if */
+ }
/* Get the number of open objects and open files on this file/mount hierarchy */
if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0)
@@ -2087,7 +2090,8 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/)
HGOTO_DONE(SUCCEED)
/* Sanity check: If close degree if "semi" and we have gotten this
- * far and there are objects left open, bail out now */
+ * far and there are objects left open, bail out now.
+ */
HDassert(nopen_files == 0 && nopen_objs == 0);
/* If we've gotten this far (ie. there are no open objects in the file), fall through to flush & close */
@@ -2128,9 +2132,9 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/)
for(u = 0; u < obj_count; u++)
if(H5I_dec_ref(objs[u]) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object")
- } /* end while */
+ }
if(result < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_ids failed(1)")
+ HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed(1)")
/* Get the list of IDs of open named datatype objects */
/* (Do this separately from the dataset & attribute IDs, because
@@ -2144,7 +2148,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/)
for(u = 0; u < obj_count; u++)
if(H5I_dec_ref(objs[u]) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object")
- } /* end while */
+ }
if(result < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_ids failed(2)")
} /* end if */
@@ -2163,17 +2167,18 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/)
/* If there is more than one reference to the shared file struct and the
* file has an external file cache, we should see if it can be closed. This
- * can happen if a cycle is formed with external file caches */
+ * can happen if a cycle is formed with external file caches.
+ */
if(f->shared->efc && (f->shared->nrefs > 1))
if(H5F__efc_try_close(f) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't attempt to close EFC")
/* Delay flush until the shared file struct is closed, in H5F__dest. If the
* application called H5Fclose, it would have been flushed in that function
- * (unless it will have been flushed in H5F_dest anyways). */
+ * (unless it will have been flushed in H5F_dest anyways).
+ */
- /*
- * Destroy the H5F_t struct and decrement the reference count for the
+ /* Destroy the H5F_t struct and decrement the reference count for the
* shared H5F_shared_t struct. If the reference count for the H5F_shared_t
* struct reaches zero then destroy it also.
*/
@@ -2189,12 +2194,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_get_id
+ * Function: H5F_get_id
*
- * Purpose: Get the file ID, incrementing it, or "resurrecting" it as
- * appropriate.
+ * Purpose: Get the file ID, incrementing it, or "resurrecting" it as
+ * appropriate.
+ *
+ * Return: Success: An ID for a file
+ *
+ * Failure: H5I_INVALID_HID
*
- * Return: Non-negative on success/Negative on failure
*-------------------------------------------------------------------------
*/
hid_t
@@ -2206,15 +2214,15 @@ H5F_get_id(H5F_t *file, hbool_t app_ref)
HDassert(file);
- if(file->file_id == -1) {
+ if(file->file_id == H5I_INVALID_HID) {
/* Get an atom for the file */
if((file->file_id = H5I_register(H5I_FILE, file, app_ref)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file")
}
else {
- /* Increment reference count on atom. */
+ /* Increment reference count on existing ID */
if(H5I_inc_ref(file->file_id, app_ref) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, H5I_INVALID_HID, "incrementing file ID failed")
} /* end else */
ret_value = file->file_id;
@@ -2225,12 +2233,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_incr_nopen_objs
+ * Function: H5F_incr_nopen_objs
*
- * Purpose: Increment the number of open objects for a file.
+ * Purpose: Increment the number of open objects for a file.
*
- * Return: Success: The number of open objects, after the increment
- * Failure: (can't happen)
+ * Return: Success: The number of open objects, after the increment
+ * Failure: (can't happen)
*-------------------------------------------------------------------------
*/
unsigned
@@ -2246,12 +2254,12 @@ H5F_incr_nopen_objs(H5F_t *f)
/*-------------------------------------------------------------------------
- * Function: H5F_decr_nopen_objs
+ * Function: H5F_decr_nopen_objs
*
- * Purpose: Decrement the number of open objects for a file.
+ * Purpose: Decrement the number of open objects for a file.
*
- * Return: Success: The number of open objects, after the decrement
- * Failure: (can't happen)
+ * Return: Success: The number of open objects, after the decrement
+ * Failure: (can't happen)
*-------------------------------------------------------------------------
*/
unsigned
@@ -2267,21 +2275,20 @@ H5F_decr_nopen_objs(H5F_t *f)
/*-------------------------------------------------------------------------
- * Function: H5F_build_actual_name
+ * Function: H5F_build_actual_name
*
- * Purpose: Retrieve the name of a file, after following symlinks, etc.
+ * Purpose: Retrieve the name of a file, after following symlinks, etc.
*
- * Note: Currently only working for "POSIX I/O compatible" VFDs
+ * Note: Currently only working for "POSIX I/O compatible" VFDs
*
- * Return: Success: 0
- * Failure: -1
+ * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
static herr_t
H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name,
char **actual_name/*out*/)
{
- hid_t new_fapl_id = -1; /* ID for duplicated FAPL */
+ hid_t new_fapl_id = H5I_INVALID_HID; /* ID for duplicated FAPL */
#ifdef H5_HAVE_SYMLINK
/* This has to be declared here to avoid unfreed resources on errors */
char *realname = NULL; /* Fully resolved path name of file */
@@ -2389,13 +2396,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_addr_encode_len
+ * Function: H5F_addr_encode_len
*
- * Purpose: Encodes an address into the buffer pointed to by *PP and
- * then increments the pointer to the first byte after the
- * address. An undefined value is stored as all 1's.
+ * Purpose: Encodes an address into the buffer pointed to by *PP and
+ * then increments the pointer to the first byte after the
+ * address. An undefined value is stored as all 1's.
*
- * Return: void
+ * Return: void
*-------------------------------------------------------------------------
*/
void
@@ -2426,13 +2433,13 @@ H5F_addr_encode_len(size_t addr_len, uint8_t **pp/*in,out*/, haddr_t addr)
/*-------------------------------------------------------------------------
- * Function: H5F_addr_encode
+ * Function: H5F_addr_encode
*
- * Purpose: Encodes an address into the buffer pointed to by *PP and
- * then increments the pointer to the first byte after the
- * address. An undefined value is stored as all 1's.
+ * Purpose: Encodes an address into the buffer pointed to by *PP and
+ * then increments the pointer to the first byte after the
+ * address. An undefined value is stored as all 1's.
*
- * Return: void
+ * Return: void
*-------------------------------------------------------------------------
*/
void
@@ -2450,16 +2457,16 @@ H5F_addr_encode(const H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr)
/*-------------------------------------------------------------------------
- * Function: H5F_addr_decode_len
+ * Function: H5F_addr_decode_len
*
- * Purpose: Decodes an address from the buffer pointed to by *PP and
- * updates the pointer to point to the next byte after the
- * address.
+ * Purpose: Decodes an address from the buffer pointed to by *PP and
+ * updates the pointer to point to the next byte after the
+ * address.
*
- * If the value read is all 1's then the address is returned
- * with an undefined value.
+ * If the value read is all 1's then the address is returned
+ * with an undefined value.
*
- * Return: void
+ * Return: void
*-------------------------------------------------------------------------
*/
void
@@ -2514,16 +2521,16 @@ H5F_addr_decode_len(size_t addr_len, const uint8_t **pp/*in,out*/, haddr_t *addr
/*-------------------------------------------------------------------------
- * Function: H5F_addr_decode
+ * Function: H5F_addr_decode
*
- * Purpose: Decodes an address from the buffer pointed to by *PP and
- * updates the pointer to point to the next byte after the
- * address.
+ * Purpose: Decodes an address from the buffer pointed to by *PP and
+ * updates the pointer to point to the next byte after the
+ * address.
*
- * If the value read is all 1's then the address is returned
- * with an undefined value.
+ * If the value read is all 1's then the address is returned
+ * with an undefined value.
*
- * Return: void
+ * Return: void
*-------------------------------------------------------------------------
*/
void
@@ -2545,8 +2552,7 @@ H5F_addr_decode(const H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*o
*
* Purpose: Set the grp_btree_shared field with a valid ref-count pointer.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
herr_t
@@ -2571,8 +2577,7 @@ H5F_set_grp_btree_shared(H5F_t *f, H5UC_t *rc)
*
* Purpose: Set the sohm_addr field with a new value.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
herr_t
@@ -2596,8 +2601,7 @@ H5F_set_sohm_addr(H5F_t *f, haddr_t addr)
*
* Purpose: Set the sohm_vers field with a new value.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
herr_t
@@ -2621,8 +2625,7 @@ H5F_set_sohm_vers(H5F_t *f, unsigned vers)
*
* Purpose: Set the sohm_nindexes field with a new value.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
herr_t
@@ -2646,8 +2649,7 @@ H5F_set_sohm_nindexes(H5F_t *f, unsigned nindexes)
*
* Purpose: Set the store_msg_crt_idx field with a new value.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
herr_t
@@ -2674,7 +2676,7 @@ H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag)
* This is done only if the existing setting is different
* from the inputs.
*
- * Return: SUCCEED on success, and FAIL on failure.
+ * Return: SUCCEED/FAIL
*
* Programmer: Vailin Choi; December 2017
*
@@ -2719,7 +2721,7 @@ H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high)
/* Set the new bounds */
f->shared->low_bound = low;
f->shared->high_bound = high;
- } /* end if */
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -2732,7 +2734,7 @@ done:
* Purpose: Private version of H5Fget_file_image
*
* Return: Success: Bytes copied / number of bytes needed.
- * Failure: negative value
+ * Failure: -1
*-------------------------------------------------------------------------
*/
ssize_t
@@ -2746,10 +2748,10 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len)
/* Check args */
if(!file || !file->shared || !file->shared->lf)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file_id yields invalid file pointer")
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "file_id yields invalid file pointer")
fd_ptr = file->shared->lf;
if(!fd_ptr->cls)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "fd_ptr yields invalid class pointer")
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "fd_ptr yields invalid class pointer")
/* the address space used by the split and multi file drivers is not
* a good fit for this call. Since the plan is to depreciate these
@@ -2770,7 +2772,7 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len)
* JRM -- 11/11/22
*/
if(HDstrcmp(fd_ptr->cls->name, "multi") == 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Not supported for multi file driver.")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "Not supported for multi file driver.")
/* While the family file driver is conceptually fully compatible
* with the get file image operation, it sets a file driver message
@@ -2792,11 +2794,11 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len)
* JRM -- 12/21/11
*/
if(HDstrcmp(fd_ptr->cls->name, "family") == 0)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "Not supported for family file driver.")
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "Not supported for family file driver.")
/* Go get the actual file size */
if(HADDR_UNDEF == (eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT)))
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file size")
/* set ret_value = to eoa -- will overwrite this if appropriate */
ret_value = (ssize_t)eoa;
@@ -2804,28 +2806,27 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len)
/* test to see if a buffer was provided -- if not, we are done */
if(buf_ptr != NULL) {
size_t space_needed; /* size of file image */
- hsize_t tmp;
- size_t tmp_size;
+ unsigned tmp, tmp_size;
/* Check for buffer too small */
if((haddr_t)buf_len < eoa)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "supplied buffer too small")
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "supplied buffer too small")
space_needed = (size_t)eoa;
/* read in the file image */
/* (Note compensation for base address addition in internal routine) */
if(H5FD_read(fd_ptr, H5FD_MEM_DEFAULT, 0, space_needed, buf_ptr) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "file image read request failed")
+ HGOTO_ERROR(H5E_FILE, H5E_READERROR, (-1), "file image read request failed")
/* Offset to "status_flags" in the superblock */
tmp = H5F_SUPER_STATUS_FLAGS_OFF(file->shared->sblock->super_vers);
+
/* Size of "status_flags" depends on the superblock version */
tmp_size = H5F_SUPER_STATUS_FLAGS_SIZE(file->shared->sblock->super_vers);
/* Clear "status_flags" */
- HDmemset((uint8_t *)(buf_ptr) + tmp, 0, tmp_size);
-
+ HDmemset((uint8_t *)buf_ptr + tmp, 0, tmp_size);
} /* end if */
done:
@@ -2881,16 +2882,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_track_metadata_read_retries
+ * Function: H5F_track_metadata_read_retries
*
- * Purpose: To track the # of a "retries" (log10) for a metadata item.
- * This routine should be used only when:
- * "retries" > 0
- * f->shared->read_attempts > 1 (does not have retry when 1)
- * f->shared->retries_nbins > 0 (calculated based on f->shared->read_attempts)
+ * Purpose: To track the # of a "retries" (log10) for a metadata item.
+ * This routine should be used only when:
+ * "retries" > 0
+ * f->shared->read_attempts > 1 (does not have retry when 1)
+ * f->shared->retries_nbins > 0 (calculated based on f->shared->read_attempts)
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
herr_t
@@ -2929,14 +2929,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_set_retries
+ * Function: H5F_set_retries
*
- * Purpose: To initialize data structures for read retries:
- * --zero out "retries"
- * --set up "retries_nbins" based on read_attempts
+ * Purpose: To initialize data structures for read retries:
+ * --zero out "retries"
+ * --set up "retries_nbins" based on read_attempts
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
herr_t
@@ -3079,11 +3078,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F__get_max_eof_eoa
+ * Function: H5F__get_max_eof_eoa
*
- * Purpose: Determine the maximum of (EOA, EOF) for the file
+ * Purpose: Determine the maximum of (EOA, EOF) for the file
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
herr_t
@@ -3172,7 +3171,7 @@ H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info)
HDmemset(info->retries, 0, sizeof(info->retries));
/* Return if there are no bins -- no retries */
- if (!info->nbins)
+ if(!info->nbins)
HGOTO_DONE(SUCCEED);
/* Calculate size for each retries[i] */
@@ -3180,7 +3179,7 @@ H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info)
/* Map and copy information to info's retries for metadata items with tracking for read retries */
j = 0;
- for (i = 0; i < H5AC_NTYPES; i++) {
+ for(i = 0; i < H5AC_NTYPES; i++) {
switch (i) {
case H5AC_OHDR_ID:
case H5AC_OHDR_CHK_ID:
@@ -3204,13 +3203,13 @@ H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info)
case H5AC_FARRAY_DBLK_PAGE_ID:
case H5AC_SUPERBLOCK_ID:
HDassert(j < H5F_NUM_METADATA_READ_RETRY_TYPES);
- if (file->shared->retries[i] != NULL) {
+ if(file->shared->retries[i] != NULL) {
/* Allocate memory for retries[i]
*
* This memory should be released by the user with
* the H5free_memory() call.
*/
- if (NULL == (info->retries[j] = (uint32_t *)H5MM_malloc(tot_size)))
+ if(NULL == (info->retries[j] = (uint32_t *)H5MM_malloc(tot_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Copy the information */
@@ -3256,14 +3255,14 @@ done:
* --disallow named datatype with/without attributes
* --disallow opened attributes attached to objects
*
- * Note: Currently, only opened groups and datasets are allowed
+ * NOTE: Currently, only opened groups and datasets are allowed
* when enabling SWMR via H5Fstart_swmr_write().
* Will later implement a different approach--
* set up flush dependency/proxy even for file opened without
* SWMR to resolve issues with opened objects.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: SUCCEED/FAIL
+ *
*-------------------------------------------------------------------------
*/
herr_t
@@ -3315,19 +3314,19 @@ H5F__start_swmr_write(H5F_t *f)
/* Flush data buffers */
if(H5F__flush(f) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush f's cached information")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information")
/* Get the # of opened named datatypes and attributes */
- if(H5F_get_obj_count(f, H5F_OBJ_DATATYPE|H5F_OBJ_ATTR, FALSE, &nt_attr_count) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
- if(nt_attr_count)
+ if(H5F_get_obj_count(f, H5F_OBJ_DATATYPE | H5F_OBJ_ATTR, FALSE, &nt_attr_count) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
+ if(nt_attr_count > 0)
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "named datatypes and/or attributes opened in the file")
/* Get the # of opened datasets and groups */
- if(H5F_get_obj_count(f, H5F_OBJ_GROUP|H5F_OBJ_DATASET, FALSE, &grp_dset_count) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
+ if(H5F_get_obj_count(f, H5F_OBJ_GROUP | H5F_OBJ_DATASET, FALSE, &grp_dset_count) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
- if(grp_dset_count) {
+ if(grp_dset_count > 0) {
/* Allocate space for group and object locations */
if((obj_ids = (hid_t *) H5MM_malloc(grp_dset_count * sizeof(hid_t))) == NULL)
HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for hid_t")
@@ -3428,7 +3427,7 @@ done:
/* Un-set H5F_ACC_SWMR_WRITE in shared open flags */
f->shared->flags &= ~H5F_ACC_SWMR_WRITE;
- /* Unmark the f: not in SWMR writing mode */
+ /* Unmark the file: not in SWMR writing mode */
f->shared->sblock->status_flags &= (uint8_t)(~H5F_SUPER_SWMR_WRITE_ACCESS);
/* Mark superblock as dirty */
@@ -3451,7 +3450,7 @@ done:
H5MM_xfree(obj_paths);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5F__start_swmr_write() */
+} /* end H5F__start_swmr_write() */
/*-------------------------------------------------------------------------
@@ -3477,9 +3476,9 @@ H5F__format_convert(H5F_t *f)
/* Check if the superblock should be downgraded */
if(f->shared->sblock->super_vers > HDF5_SUPERBLOCK_VERSION_V18_LATEST) {
- f->shared->sblock->super_vers = HDF5_SUPERBLOCK_VERSION_V18_LATEST;
- mark_dirty = TRUE;
- } /* end if */
+ f->shared->sblock->super_vers = HDF5_SUPERBLOCK_VERSION_V18_LATEST;
+ mark_dirty = TRUE;
+ }
/* Check for persistent freespace manager, which needs to be downgraded */
if(!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF &&