summaryrefslogtreecommitdiffstats
path: root/test/vds_swmr_writer.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /test/vds_swmr_writer.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'test/vds_swmr_writer.c')
-rw-r--r--test/vds_swmr_writer.c98
1 files changed, 48 insertions, 50 deletions
diff --git a/test/vds_swmr_writer.c b/test/vds_swmr_writer.c
index d70352d..32ef4c7 100644
--- a/test/vds_swmr_writer.c
+++ b/test/vds_swmr_writer.c
@@ -11,32 +11,30 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
#include "h5test.h"
#include "vds_swmr.h"
int
main(int argc, char *argv[])
{
- int file_number = -1; /* Source file number */
-
- hid_t fid = -1; /* HDF5 file ID */
- hid_t faplid = -1; /* file access property list ID */
- hid_t did = -1; /* dataset ID */
- hid_t msid = -1; /* memory dataspace ID */
- hid_t fsid = -1; /* file dataspace ID */
+ int file_number = -1; /* Source file number */
- hsize_t extent[RANK]; /* dataset extents */
- hsize_t start[RANK]; /* hyperslab start point */
+ hid_t fid = -1; /* HDF5 file ID */
+ hid_t faplid = -1; /* file access property list ID */
+ hid_t did = -1; /* dataset ID */
+ hid_t msid = -1; /* memory dataspace ID */
+ hid_t fsid = -1; /* file dataspace ID */
- int *buffer = NULL; /* data buffer */
- int value = -1; /* value written to datasets */
+ hsize_t extent[RANK]; /* dataset extents */
+ hsize_t start[RANK]; /* hyperslab start point */
- hsize_t n_elements = 0; /* number of elements in a plane */
+ int *buffer = NULL; /* data buffer */
+ int value = -1; /* value written to datasets */
- hsize_t i; /* iterator */
- hsize_t j; /* iterator */
+ hsize_t n_elements = 0; /* number of elements in a plane */
+ hsize_t i; /* iterator */
+ hsize_t j; /* iterator */
/******************************
* Fill a source dataset file *
@@ -45,96 +43,95 @@ main(int argc, char *argv[])
/* The file number is passed on the command line.
* This is an integer index into the FILE_NAMES array.
*/
- if(argc != 2) {
+ if (argc != 2) {
HDfprintf(stderr, "ERROR: Must pass the source file number on the command line.\n");
return EXIT_FAILURE;
}
file_number = HDatoi(argv[1]);
- if(file_number < 0 || file_number >= N_SOURCES)
+ if (file_number < 0 || file_number >= N_SOURCES)
TEST_ERROR
/* Open the source file and dataset */
/* All SWMR files need to use the latest file format */
- if((faplid = h5_fileaccess()) < 0)
+ if ((faplid = h5_fileaccess()) < 0)
TEST_ERROR
- if(H5Pset_libver_bounds(faplid, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ if (H5Pset_libver_bounds(faplid, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
TEST_ERROR
- if((fid = H5Fopen(FILE_NAMES[file_number], H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, faplid)) < 0)
+ if ((fid = H5Fopen(FILE_NAMES[file_number], H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, faplid)) < 0)
TEST_ERROR
- if((did = H5Dopen2(fid, SOURCE_DSET_PATH, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, SOURCE_DSET_PATH, H5P_DEFAULT)) < 0)
TEST_ERROR
-
/* Create a data buffer that represents a plane */
n_elements = PLANES[file_number][1] * PLANES[file_number][2];
- if(NULL == (buffer = (int *)HDmalloc(n_elements * sizeof(int))))
+ if (NULL == (buffer = (int *)HDmalloc(n_elements * sizeof(int))))
TEST_ERROR
/* Create the memory dataspace */
- if((msid = H5Screate_simple(RANK, PLANES[file_number], NULL)) < 0)
+ if ((msid = H5Screate_simple(RANK, PLANES[file_number], NULL)) < 0)
TEST_ERROR
/* Write planes to the dataset */
- for(i = 0; i < N_PLANES_TO_WRITE; i++) {
+ for (i = 0; i < N_PLANES_TO_WRITE; i++) {
- time_t delay; /* Time interval between plane writes */
+ time_t delay; /* Time interval between plane writes */
/* Cork the dataset's metadata in the cache */
- if(H5Odisable_mdc_flushes(did) < 0)
+ if (H5Odisable_mdc_flushes(did) < 0)
TEST_ERROR
/* Set the dataset's extent. This is inefficient but that's ok here. */
extent[0] = i + 1;
extent[1] = PLANES[file_number][1];
extent[2] = PLANES[file_number][2];
- if(H5Dset_extent(did, extent) < 0)
+ if (H5Dset_extent(did, extent) < 0)
TEST_ERROR
/* Get the file dataspace */
- if((fsid = H5Dget_space(did)) < 0)
+ if ((fsid = H5Dget_space(did)) < 0)
TEST_ERROR
/* Each plane is filled with the plane number as a data value. */
value = (((int)i + 1) * 10) + (int)i;
- for(j = 0; j < n_elements; j++)
- buffer[j] = value;
+ for (j = 0; j < n_elements; j++)
+ buffer[j] = value;
/* Set up the hyperslab for writing. */
start[0] = i;
start[1] = 0;
start[2] = 0;
- if(H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, PLANES[file_number], NULL) < 0)
+ if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, PLANES[file_number], NULL) < 0)
TEST_ERROR
/* Write the plane to the dataset. */
- if(H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0)
+ if (H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0)
TEST_ERROR
/* Uncork the dataset's metadata from the cache */
- if(H5Oenable_mdc_flushes(did) < 0)
+ if (H5Oenable_mdc_flushes(did) < 0)
TEST_ERROR
/* Wait one second between writing planes */
delay = HDtime(0) + (time_t)1;
- while(HDtime(0) < delay)
+ while (HDtime(0) < delay)
;
/* Flush */
- if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0)
+ if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0)
TEST_ERROR
} /* end for */
- if(H5Pclose(faplid) < 0)
+ if (H5Pclose(faplid) < 0)
TEST_ERROR
- if(H5Sclose(msid) < 0)
+ if (H5Sclose(msid) < 0)
TEST_ERROR
- if(H5Sclose(fsid) < 0)
+ if (H5Sclose(fsid) < 0)
TEST_ERROR
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
TEST_ERROR
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
TEST_ERROR
HDfree(buffer);
@@ -143,23 +140,24 @@ main(int argc, char *argv[])
error:
- H5E_BEGIN_TRY {
- if(fid >= 0)
+ H5E_BEGIN_TRY
+ {
+ if (fid >= 0)
(void)H5Fclose(fid);
- if(faplid >= 0)
+ if (faplid >= 0)
(void)H5Pclose(faplid);
- if(did >= 0)
+ if (did >= 0)
(void)H5Dclose(did);
- if(msid >= 0)
+ if (msid >= 0)
(void)H5Sclose(msid);
- if(fsid >= 0)
+ if (fsid >= 0)
(void)H5Sclose(fsid);
- if(buffer != NULL)
+ if (buffer != NULL)
HDfree(buffer);
- } H5E_END_TRY
+ }
+ H5E_END_TRY
HDfprintf(stderr, "ERROR: SWMR writer exited with errors\n");
return EXIT_FAILURE;
} /* end main */
-