diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2016-08-01 16:45:44 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2016-08-01 16:45:44 (GMT) |
commit | 2bb3a09add7b2d6acb5a3b16c6a6d5aa0926eb82 (patch) | |
tree | 22c4b2ab199e8fcf2db69852c67ef05d1cecde82 /src/H5PL.c | |
parent | e61ed09aab3b6c97e71948ad7a7eeee12d2b89fc (diff) | |
download | hdf5-2bb3a09add7b2d6acb5a3b16c6a6d5aa0926eb82.zip hdf5-2bb3a09add7b2d6acb5a3b16c6a6d5aa0926eb82.tar.gz hdf5-2bb3a09add7b2d6acb5a3b16c6a6d5aa0926eb82.tar.bz2 |
[svn-r30231] HDFFV-9944: else statement and braces.
refactored out the assert statement since H5MM_xfree allows null argument.
Diffstat (limited to 'src/H5PL.c')
-rw-r--r-- | src/H5PL.c | 41 |
1 files changed, 24 insertions, 17 deletions
@@ -70,6 +70,9 @@ /* Clear error - nothing to do */ #define H5PL_CLR_ERROR +/* maximum size for expanding env vars */ +#define EXPAND_BUFFER_SIZE 32767 + typedef const void *(__cdecl *H5PL_get_plugin_info_t)(void); /* Unix support */ @@ -419,6 +422,19 @@ H5PL__init_path_table(void) if(NULL == dl_path) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path") +#ifdef H5_HAVE_WIN32_API + else { /* Expand windows env var*/ + long bufCharCount; + char tempbuf[EXPAND_BUFFER_SIZE]; + if((bufCharCount = ExpandEnvironmentStrings(dl_path, tempbuf, EXPAND_BUFFER_SIZE)) > EXPAND_BUFFER_SIZE) + HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "expanded path is too long") + if(bufCharCount == 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "failed to expand path") + dl_path = (char *)H5MM_xfree(dl_path); + dl_path = H5MM_strdup(tempbuf); + } +#endif H5_HAVE_WIN32_API + /* Put paths in the path table. They are separated by ":" */ dir = HDstrtok(dl_path, H5PL_PATH_SEPARATOR); while(dir) { @@ -471,7 +487,7 @@ H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info) /* Open the directory */ if(!(dirp = HDopendir(dir))) - HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, FAIL, "can't open directory") + HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, FAIL, "can't open directory: %s", dir) /* Iterates through all entries in the directory to find the right plugin library */ while(NULL != (dp = HDreaddir(dirp))) { @@ -507,13 +523,9 @@ H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info) /* Attempt to open the dynamic library as a filter library */ if((found_in_dir = H5PL__open(plugin_type, pathname, type_id, info)) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed") - if(found_in_dir) { - /* Indicate success */ - HGOTO_DONE(TRUE) - } /* end if */ - else - HDassert(pathname); - pathname = (char *)H5MM_xfree(pathname); + if(found_in_dir) + HGOTO_DONE(TRUE) /* Indicate success */ + pathname = (char *)H5MM_xfree(pathname); } /* end if */ } /* end while */ @@ -521,8 +533,7 @@ done: if(dirp) if(HDclosedir(dirp) < 0) HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "can't close directory: %s", HDstrerror(errno)) - if(pathname) - pathname = (char *)H5MM_xfree(pathname); + pathname = (char *)H5MM_xfree(pathname); FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__find() */ @@ -563,13 +574,9 @@ H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info) if((found_in_dir = H5PL__open(plugin_type, pathname, type_id, info)) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed") - if(found_in_dir) { - /* Indicate success */ - HGOTO_DONE(TRUE) - } /* end if */ - else - HDassert(pathname); - pathname = (char *)H5MM_xfree(pathname); + if(found_in_dir) + HGOTO_DONE(TRUE) /* Indicate success */ + pathname = (char *)H5MM_xfree(pathname); } /* end if */ } while(FindNextFileA(hFind, &fdFile)); /* Find the next file. */ |