diff options
author | Quincey Koziol <koziol@lbl.gov> | 2016-09-29 20:19:35 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@lbl.gov> | 2016-09-29 20:19:35 (GMT) |
commit | 30ca70b0969ae0ab63104d7910523818e5385ac6 (patch) | |
tree | 471b06e9f95379c79b350ec435c49ec525b9e786 /test/h5test.c | |
parent | a7fb4ede8601e135433ef2d23bf4bbb466d9f58d (diff) | |
parent | 5a7880183025f56421cf6f2274d9f1ac36f59641 (diff) | |
download | hdf5-30ca70b0969ae0ab63104d7910523818e5385ac6.zip hdf5-30ca70b0969ae0ab63104d7910523818e5385ac6.tar.gz hdf5-30ca70b0969ae0ab63104d7910523818e5385ac6.tar.bz2 |
Merge pull request #46 in HDFFV/hdf5 from ~KOZIOL/hdf5:features/warning_cleanups to develop
* commit '5a7880183025f56421cf6f2274d9f1ac36f59641':
Clean up hardcoded constants and check return values better. (Comments from group code review)
Description: Cleanups from Dana's review.
Description: Further warning cleanups: from 667 warnings to 503.
Diffstat (limited to 'test/h5test.c')
-rw-r--r-- | test/h5test.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/test/h5test.c b/test/h5test.c index aea5dc7..2ab8855 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -74,7 +74,7 @@ char *paraprefix = NULL; /* for command line option para-prefix */ MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ #endif -#define READ_BUF_SIZE 4096 +#define READ_BUF_SIZE 65536 /* * These are the letters that are appended to the file name when generating @@ -90,6 +90,9 @@ MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ */ static const char *multi_letters = "msbrglo"; +/* Length of multi-file VFD filename buffers */ +#define H5TEST_MULTI_FILENAME_LEN 1024 + /* Previous error reporting function */ static H5E_auto2_t err_func = NULL; @@ -855,7 +858,7 @@ h5_fileaccess(void) H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; + char *sv[H5FD_MEM_NTYPES]; haddr_t memb_addr[H5FD_MEM_NTYPES]; H5FD_mem_t mt; @@ -867,6 +870,8 @@ h5_fileaccess(void) HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { memb_fapl[mt] = H5P_DEFAULT; + if(NULL == (sv[mt] = (char *)HDmalloc(H5TEST_MULTI_FILENAME_LEN))) + return -1; HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); @@ -874,6 +879,9 @@ h5_fileaccess(void) if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) return -1; + + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) + HDfree(sv[mt]); } else if(!HDstrcmp(name, "family")) { hsize_t fam_size = 100*1024*1024; /*100 MB*/ @@ -989,7 +997,7 @@ h5_get_vfd_fapl(void) H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; + char *sv[H5FD_MEM_NTYPES]; haddr_t memb_addr[H5FD_MEM_NTYPES]; H5FD_mem_t mt; @@ -1001,15 +1009,18 @@ h5_get_vfd_fapl(void) HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { memb_fapl[mt] = H5P_DEFAULT; + sv[mt] = (char *)HDmalloc(H5TEST_MULTI_FILENAME_LEN); + HDassert(sv[mt]); HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); } /* end for */ - if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, - memb_addr, FALSE) < 0) { + if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) return -1; - } /* end if */ + + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) + HDfree(sv[mt]); } else if(!HDstrcmp(tok, "family")) { /* Family of files, each 1MB and using the default driver */ hsize_t fam_size = 100*1024*1024; /*100 MB*/ @@ -1573,9 +1584,13 @@ h5_make_local_copy(const char *origfilename, const char *local_copy_name) { int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */ ssize_t nread; /* Number of bytes read in */ - char buf[READ_BUF_SIZE]; /* Buffer for copying data */ + void *buf; /* Buffer for copying data */ const char *filename = H5_get_srcdir_filename(origfilename);; /* Get the test file name to copy */ + /* Allocate copy buffer */ + if(NULL == (buf = HDmalloc(READ_BUF_SIZE))) + return -1; + /* Copy old file into temporary file */ if((fd_old = HDopen(filename, O_RDONLY, 0666)) < 0) return -1; @@ -1586,6 +1601,9 @@ h5_make_local_copy(const char *origfilename, const char *local_copy_name) while((nread = HDread(fd_old, buf, (size_t)READ_BUF_SIZE)) > 0) if(HDwrite(fd_new, buf, (size_t)nread) < 0) return -1; + + /* Release memory */ + HDfree(buf); /* Close files */ if(HDclose(fd_old) < 0) return -1; |