summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2015-11-24 23:02:20 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2015-11-24 23:02:20 (GMT)
commitc8db4b8f62e92a1df9364c61b77e040353f58946 (patch)
tree6986f000598f9c1c698aa5219e927eb9b030efa7
parent8147b60d66a9c32f7d31545f5c7800568daaf881 (diff)
downloadhdf5-c8db4b8f62e92a1df9364c61b77e040353f58946.zip
hdf5-c8db4b8f62e92a1df9364c61b77e040353f58946.tar.gz
hdf5-c8db4b8f62e92a1df9364c61b77e040353f58946.tar.bz2
[svn-r28465] Cleaned up warnings in ohdr test.
Tested on Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only
-rw-r--r--test/ohdr.c105
1 files changed, 56 insertions, 49 deletions
diff --git a/test/ohdr.c b/test/ohdr.c
index 67d9116..6faced9 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -307,118 +307,124 @@ error:
* greater than 512 bytes. For SWMR access, the read should be done all at one time.
*/
static herr_t
-test_ohdr_swmr(hbool_t new)
+test_ohdr_swmr(hbool_t new_format)
{
- hid_t fid = -1; /* File ID */
+ hid_t fid = -1; /* File ID */
hid_t fapl = -1; /* File access property list */
- hid_t did = -1; /* Dataset ID */
- hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t sid = -1; /* Dataspace ID */
hid_t plist = -1; /* Dataset creation property list */
- size_t compact_size = 1024; /* The size of compact dataset */
- int wbuf[1024]; /* Buffer for writing */
+ size_t compact_size = 1024; /* The size of compact dataset */
+ int *wbuf = NULL; /* Buffer for writing */
hsize_t dims[1]; /* Dimension sizes */
- unsigned int n = 0, u; /* Locatl index variable */
+ size_t u; /* Iterator */
+ int n; /* Data variable */
H5O_info_t obj_info; /* Information for the object */
- if(new) {
- TESTING("exercise the coding for the re-read of the object header for SWMR access: latest-format");
+ if(new_format) {
+ TESTING("exercise the coding for the re-read of the object header for SWMR access: latest-format");
} else {
- TESTING("exercise the coding for the re-read of the object header for SWMR access: non-latest-format");
- }
+ TESTING("exercise the coding for the re-read of the object header for SWMR access: non-latest-format");
+ } /* end if */
/* File access property list */
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
FAIL_STACK_ERROR
/* Create the file with/without latest format: ensure version 2 object header for SWMR */
- if(new) {
- /* Set to use latest library format */
- if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
- FAIL_STACK_ERROR
+ if(new_format) {
+ /* Set to use latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
- if((fid = H5Fcreate(FILE_OHDR_SWMR, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
- TEST_ERROR
- } else {
- if((fid = H5Fcreate(FILE_OHDR_SWMR, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0)
- TEST_ERROR
- }
+ if((fid = H5Fcreate(FILE_OHDR_SWMR, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+ } else {
+ if((fid = H5Fcreate(FILE_OHDR_SWMR, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+ } /* end if */
/* Initialize data */
+ wbuf = (int *)HDcalloc(compact_size, sizeof(int));
+ n = 0;
for(u = 0; u < compact_size; u++)
- wbuf[u] = n++;
+ wbuf[u] = n++;
/* Create a small data space for compact dataset */
dims[0] = (hsize_t)compact_size;
if((sid = H5Screate_simple(1, dims, NULL)) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Create property list for compact dataset creation */
if((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Set the layout for the compact dataset */
if(H5Pset_layout(plist, H5D_COMPACT) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Create a compact dataset */
if((did = H5Dcreate2(fid, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, plist, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Write to the compact dataset */
if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Close the dataset */
if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Close the file */
if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Open the file for SWMR write with/without latest format */
if((fid = H5Fopen(FILE_OHDR_SWMR, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Open the compact dataset */
if((did = H5Dopen2(fid, DSET_NAME, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Get the object information */
if(H5Oget_info(did, &obj_info) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
if(obj_info.hdr.version != OBJ_VERSION_LATEST)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* The size of object header should be greater than the speculative read size of 512 */
/* This will exercise the coding for the re-read of the object header for SWMR access */
if(obj_info.hdr.space.total < 512)
- TEST_ERROR;
+ TEST_ERROR;
/* Close the dataset */
if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Close the file */
if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Close the dataspace */
if(H5Sclose(sid) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Close the dataset creation property list */
if(H5Pclose(plist) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Close the file access property list */
if(H5Pclose(fapl) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
/* Remove the test file */
if(HDremove(FILE_OHDR_SWMR) < 0)
- FAIL_STACK_ERROR
+ FAIL_STACK_ERROR
+
+ /* Free the buffer */
+ HDfree(wbuf);
PASSED();
@@ -427,11 +433,12 @@ test_ohdr_swmr(hbool_t new)
error:
H5E_BEGIN_TRY {
H5Fclose(fid);
- H5Dclose(did);
- H5Sclose(sid);
- H5Pclose(plist);
- H5Pclose(fapl);
- HDremove(FILE_OHDR_SWMR);
+ H5Dclose(did);
+ H5Sclose(sid);
+ H5Pclose(plist);
+ H5Pclose(fapl);
+ HDremove(FILE_OHDR_SWMR);
+ HDfree(wbuf);
} H5E_END_TRY;
return -1;
@@ -980,8 +987,8 @@ main(void)
if(H5Fclose(file) < 0)
TEST_ERROR
- /* Test object header creation metadata cache issues */
- if(test_ohdr_cache(filename, fapl) < 0)
+ /* Test object header creation metadata cache issues */
+ if(test_ohdr_cache(filename, fapl) < 0)
TEST_ERROR
} /* end for */
@@ -994,7 +1001,7 @@ main(void)
puts("All object header tests passed.");
h5_cleanup(FILENAME, fapl);
- return(0);
+ return 0;
error:
puts("*** TESTS FAILED ***");
@@ -1002,6 +1009,6 @@ error:
H5Fclose(file);
} H5E_END_TRY;
- return(1);
+ return 1;
} /* end main() */