summaryrefslogtreecommitdiffstats
path: root/src/H5FD.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-01-23 07:00:00 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-01-23 07:00:00 (GMT)
commitbb25c85e794449d3bf59d8811e53288569161790 (patch)
treee6c37cf6f8bba9323540ddddb70300b43351d88f /src/H5FD.c
parentfcc03a356b4dd5e58cc88b692b3d05d75b8ae5d0 (diff)
downloadhdf5-bb25c85e794449d3bf59d8811e53288569161790.zip
hdf5-bb25c85e794449d3bf59d8811e53288569161790.tar.gz
hdf5-bb25c85e794449d3bf59d8811e53288569161790.tar.bz2
[svn-r18159] Description:
Bring Coverity fixes from 1/22/10 session to trunk: r18137: 219: Initialized hid_t to -1 and added close to error block. 189-191: Initialized line to NULL and added free line, and close fp to error block. r18138: 19: Moved code block for printing that the number of enums is empty to the error block. (Would never have been executed otherwise) r18139: Fix coverity item 58. Moved code related to displaying the parent of a repeated group to the else(isRoot) section, as the root group has no parent. r18140: 218: Initialized ret_value variable to -1. Because of throw Exception in default case of switch, the coverity problem would not have executed anyway. Good pratice is to initialize variables. r18141: Fix coverity item 92. Added code to H5E_register_class to free cls in case of an error. r18142: Fix coverity item 91. Added code to H5E_create_msg to free msg in case of an error. r18143: fixed issue 14, took away "if" and used #ifndef_xxx. r18144: Fix coverity item 110. Added code to H5Eget_minor to free msg_str in case of an error. r18145: fixed coverity #18 removed "aligned", it is always NULL. r18146: Fix coverity item 109. Added code to H5Eget_major to free msg_str in case of an error. r18147: Fixed coverity #81 and #82, Check for bad pointer(s), but can't issue error, just leave r18148: Fix coverity item 97. Added code to H5FD_fapl_open to free copied_driver_info in case of an error. r18149: Fix coverity item 96. Added code to H5FD_dxpl_open to free copied_driver_info in case of an error. r18150: Fix Coverity issue #29: Protected cache_ptr dereferences with "if(pass)" block r18151: Fix coverity item 93. Added code to H5FL_fac_init to free factory and new_node in case of an error. r18152: Fix coverity items 98 and 99. Added code free allocated space in case of error. r18155: 124: Freed head pointer before jumping to done. There was no error handling block and normal exit used same path out. 120-123: Freed list of lists in error handling block. r18156: Fix coverity issues 179, 180, 181, 182, 183, 184, 186, 320, 407. These were resource leak issues where allocated memory was not freed, generally in the case of tests that failed. Tested on: Mac OS X/32 10.6.2 (amazon) debug & production
Diffstat (limited to 'src/H5FD.c')
-rw-r--r--src/H5FD.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/H5FD.c b/src/H5FD.c
index 4c0da40..99f2e3c 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -730,8 +730,8 @@ done:
herr_t
H5FD_fapl_open(H5P_genplist_t *plist, hid_t driver_id, const void *driver_info)
{
- void *copied_driver_info; /* Temporary VFL driver info */
- herr_t ret_value=SUCCEED; /* Return value */
+ void *copied_driver_info = NULL; /* Temporary VFL driver info */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_fapl_open, FAIL)
@@ -739,15 +739,20 @@ H5FD_fapl_open(H5P_genplist_t *plist, hid_t driver_id, const void *driver_info)
if(H5I_inc_ref(driver_id, FALSE) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver")
if(H5FD_fapl_copy(driver_id, driver_info, &copied_driver_info) < 0)
- HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VFL driver info")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "can't copy VFL driver info")
/* Set the driver properties for the list */
if(H5P_set(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver ID")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set driver ID")
if(H5P_set(plist, H5F_ACS_FILE_DRV_INFO_NAME, &copied_driver_info) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set driver info")
+ copied_driver_info = NULL;
done:
+ if(ret_value < 0)
+ if(copied_driver_info && H5FD_fapl_close(driver_id, copied_driver_info) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close copy of driver info")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_fapl_open() */
@@ -847,24 +852,28 @@ done:
herr_t
H5FD_dxpl_open(H5P_genplist_t *plist, hid_t driver_id, const void *driver_info)
{
- void *copied_driver_info; /* Temporary VFL driver info */
- herr_t ret_value=SUCCEED; /* Return value */
+ void *copied_driver_info = NULL; /* Temporary VFL driver info */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_dxpl_open, FAIL)
/* Increment the reference count on the driver and copy the driver info */
if(H5I_inc_ref(driver_id, FALSE) < 0)
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINC, FAIL, "can't increment VFL driver ID")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "can't increment VFL driver ID")
if(H5FD_dxpl_copy(driver_id, driver_info, &copied_driver_info) < 0)
- HGOTO_ERROR (H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy VFL driver")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "can't copy VFL driver")
/* Set the driver information for the new property list */
if(H5P_set(plist, H5D_XFER_VFL_ID_NAME, &driver_id) < 0)
- HGOTO_ERROR (H5E_PLIST, H5E_CANTSET, FAIL, "can't set VFL driver ID")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set VFL driver ID")
if(H5P_set(plist, H5D_XFER_VFL_INFO_NAME, &copied_driver_info) < 0)
- HGOTO_ERROR (H5E_PLIST, H5E_CANTSET, FAIL, "can't set VFL driver info")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set VFL driver info")
done:
+ if(ret_value < 0)
+ if(copied_driver_info && H5FD_dxpl_close(driver_id, copied_driver_info) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close copy of driver info")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_dxpl_open() */
@@ -1060,7 +1069,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
/* Get file access property list */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list")
/* Get the VFD to open the file with */
if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0)