diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2021-03-25 00:39:37 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2021-03-25 00:39:37 (GMT) |
commit | feb20aac304b39e18c70f88cae2f7cf7d5c82db2 (patch) | |
tree | e15d7e751af4e3c42e77ea955d91db4cf27a71cf /tools/test/h5repack/h5repackgentest.c | |
parent | bdac2ecdbff2c389a222b3d93ff1eb1d23ec6b23 (diff) | |
download | hdf5-feb20aac304b39e18c70f88cae2f7cf7d5c82db2.zip hdf5-feb20aac304b39e18c70f88cae2f7cf7d5c82db2.tar.gz hdf5-feb20aac304b39e18c70f88cae2f7cf7d5c82db2.tar.bz2 |
Formats the source and updates the gcc warning pragmas
Diffstat (limited to 'tools/test/h5repack/h5repackgentest.c')
-rw-r--r-- | tools/test/h5repack/h5repackgentest.c | 183 |
1 files changed, 97 insertions, 86 deletions
diff --git a/tools/test/h5repack/h5repackgentest.c b/tools/test/h5repack/h5repackgentest.c index 7604964..4a6d854 100644 --- a/tools/test/h5repack/h5repackgentest.c +++ b/tools/test/h5repack/h5repackgentest.c @@ -35,28 +35,34 @@ #include "hdf5.h" #include "H5private.h" -#define MAX_NAME_SIZE 256 +#define MAX_NAME_SIZE 256 #define FILE_INT32LE_1 "h5repack_int32le_1d" #define FILE_INT32LE_2 "h5repack_int32le_2d" #define FILE_INT32LE_3 "h5repack_int32le_3d" -#define FILE_UINT8BE "h5repack_uint8be" -#define FILE_F32LE "h5repack_f32le" - -#define H5REPACKGENTEST_OOPS { \ - ret_value = -1; \ - goto done; \ -} - -#define H5REPACKGENTEST_COMMON_CLEANUP(dcpl, file, space) { \ - if ((dcpl) != H5P_DEFAULT && (dcpl) != H5I_INVALID_HID) { \ - (void)H5Pclose((dcpl)); \ - } \ - if ((file) != H5I_INVALID_HID) { (void)H5Fclose((file)); } \ - if ((space) != H5I_INVALID_HID) { (void)H5Sclose((space)); } \ -} +#define FILE_UINT8BE "h5repack_uint8be" +#define FILE_F32LE "h5repack_f32le" + +#define H5REPACKGENTEST_OOPS \ + { \ + ret_value = -1; \ + goto done; \ + } + +#define H5REPACKGENTEST_COMMON_CLEANUP(dcpl, file, space) \ + { \ + if ((dcpl) != H5P_DEFAULT && (dcpl) != H5I_INVALID_HID) { \ + (void)H5Pclose((dcpl)); \ + } \ + if ((file) != H5I_INVALID_HID) { \ + (void)H5Fclose((file)); \ + } \ + if ((space) != H5I_INVALID_HID) { \ + (void)H5Sclose((space)); \ + } \ + } struct external_def { - hsize_t type_size; + hsize_t type_size; unsigned n_elts_per_file; unsigned n_elts_total; }; @@ -66,14 +72,13 @@ struct external_def { * Returns 0 on success, -1 on failure. */ static int -__make_dataset(hid_t file_id, const char *dset_name, - hid_t mem_type_id, hid_t space_id, hid_t dcpl_id, void *wdata) { - hid_t dset_id = H5I_INVALID_HID; +__make_dataset(hid_t file_id, const char *dset_name, hid_t mem_type_id, hid_t space_id, hid_t dcpl_id, + void *wdata) +{ + hid_t dset_id = H5I_INVALID_HID; int ret_value = 0; - dset_id = H5Dcreate2(file_id, dset_name, mem_type_id, space_id, - H5P_DEFAULT, dcpl_id, - H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, dset_name, mem_type_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); if (dset_id == H5I_INVALID_HID) H5REPACKGENTEST_OOPS; @@ -82,7 +87,7 @@ __make_dataset(hid_t file_id, const char *dset_name, done: if (dset_id != H5I_INVALID_HID) - (void) H5Dclose(dset_id); + (void)H5Dclose(dset_id); return ret_value; } /* end __make_dataset() */ @@ -96,11 +101,12 @@ done: * Returns 0 on success, -1 on failure. */ static int -__set_dcpl_external_list(hid_t dcpl, const char *filename, - unsigned n_elts_per_file, unsigned n_elts_total, hsize_t elt_size) { +__set_dcpl_external_list(hid_t dcpl, const char *filename, unsigned n_elts_per_file, unsigned n_elts_total, + hsize_t elt_size) +{ char name[MAX_NAME_SIZE]; unsigned n_external_files = 0; - unsigned i = 0; + unsigned i = 0; if (NULL == filename || '\0' == *filename) return -1; @@ -109,7 +115,6 @@ __set_dcpl_external_list(hid_t dcpl, const char *filename, if (n_elts_total != (n_external_files * n_elts_per_file)) return -1; - for (i = 0; i < n_external_files; i++) { if (HDsnprintf(name, MAX_NAME_SIZE, "%s_ex-%u.dat", filename, i) >= MAX_NAME_SIZE) return -1; @@ -127,12 +132,13 @@ __set_dcpl_external_list(hid_t dcpl, const char *filename, * Returns 0 on success, -1 on failure. */ static int -__make_file(const char *basename, struct external_def *ext, - hid_t type_id, hsize_t rank, hsize_t *dims, void *wdata) { +__make_file(const char *basename, struct external_def *ext, hid_t type_id, hsize_t rank, hsize_t *dims, + void *wdata) +{ char filename[MAX_NAME_SIZE]; - hid_t file_id = H5I_INVALID_HID; - hid_t dcpl_id = H5P_DEFAULT; - hid_t space_id = H5I_INVALID_HID; + hid_t file_id = H5I_INVALID_HID; + hid_t dcpl_id = H5P_DEFAULT; + hid_t space_id = H5I_INVALID_HID; int ret_value = 0; if (HDsnprintf(filename, MAX_NAME_SIZE, "%s%s.h5", basename, (NULL != ext) ? "_ex" : "") >= MAX_NAME_SIZE) @@ -143,7 +149,8 @@ __make_file(const char *basename, struct external_def *ext, if (dcpl_id == H5I_INVALID_HID) H5REPACKGENTEST_OOPS; - if (__set_dcpl_external_list(dcpl_id, basename, ext->n_elts_per_file, ext->n_elts_total, ext->type_size) < 0) + if (__set_dcpl_external_list(dcpl_id, basename, ext->n_elts_per_file, ext->n_elts_total, + ext->type_size) < 0) H5REPACKGENTEST_OOPS; } @@ -155,29 +162,29 @@ __make_file(const char *basename, struct external_def *ext, if (file_id == H5I_INVALID_HID) H5REPACKGENTEST_OOPS; - if (__make_dataset(file_id, "dset", type_id, space_id, dcpl_id, wdata) < 0) H5REPACKGENTEST_OOPS; done: H5REPACKGENTEST_COMMON_CLEANUP(dcpl_id, file_id, space_id); -return ret_value; + return ret_value; } /* end __make_file() */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Returns 0 on success, -1 on failure. */ static int -generate_int32le_1d(hbool_t external) { - int32_t wdata[12]; - hsize_t dims[] = { 12 }; - struct external_def *def_ptr = NULL; - struct external_def def = { (hsize_t) sizeof(int32_t), 6, 12 }; - int32_t n = 0; - int ret_value = 0; +generate_int32le_1d(hbool_t external) +{ + int32_t wdata[12]; + hsize_t dims[] = {12}; + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(int32_t), 6, 12}; + int32_t n = 0; + int ret_value = 0; /* Generate values - */ + */ for (n = 0; n < 12; n++) { wdata[n] = n - 6; } @@ -193,16 +200,17 @@ generate_int32le_1d(hbool_t external) { * Returns 0 on success, -1 on failure. */ static int -generate_int32le_2d(hbool_t external) { - int32_t wdata[64]; - hsize_t dims[] = { 8, 8 }; - struct external_def *def_ptr = NULL; - struct external_def def = { (hsize_t) sizeof(int32_t), 64, 64 }; - int32_t n = 0; - int ret_value = 0; +generate_int32le_2d(hbool_t external) +{ + int32_t wdata[64]; + hsize_t dims[] = {8, 8}; + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(int32_t), 64, 64}; + int32_t n = 0; + int ret_value = 0; /* Generate values - */ + */ for (n = 0; n < 64; n++) { wdata[n] = n - 32; } @@ -218,19 +226,20 @@ generate_int32le_2d(hbool_t external) { * Returns 0 on success, -1 on failure. */ static int -generate_int32le_3d(hbool_t external) { - hsize_t dims[] = { 8, 8, 8 }; - int32_t wdata[512]; /* 8^3, from dims */ - struct external_def *def_ptr = NULL; - struct external_def def = { (hsize_t) sizeof(int32_t), 512, 512 }; - int32_t n = 0; - int i = 0; - int j = 0; - int k = 0; - int ret_value = 0; +generate_int32le_3d(hbool_t external) +{ + hsize_t dims[] = {8, 8, 8}; + int32_t wdata[512]; /* 8^3, from dims */ + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(int32_t), 512, 512}; + int32_t n = 0; + int i = 0; + int j = 0; + int k = 0; + int ret_value = 0; /* generate values, alternating positive and negative - */ + */ for (i = 0, n = 0; (hsize_t)i < dims[0]; i++) { for (j = 0; (hsize_t)j < dims[1]; j++) { for (k = 0; (hsize_t)k < dims[2]; k++, n++) { @@ -250,19 +259,20 @@ generate_int32le_3d(hbool_t external) { * Returns 0 on success, -1 on failure. */ static int -generate_uint8be(hbool_t external) { - hsize_t dims[] = { 4, 8, 8 }; - uint8_t wdata[256]; /* 4*8*8, from dims */ - struct external_def *def_ptr = NULL; - struct external_def def = { (hsize_t) sizeof(uint8_t), 64, 256 }; - uint8_t n = 0; - int i = 0; - int j = 0; - int k = 0; - int ret_value = 0; +generate_uint8be(hbool_t external) +{ + hsize_t dims[] = {4, 8, 8}; + uint8_t wdata[256]; /* 4*8*8, from dims */ + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(uint8_t), 64, 256}; + uint8_t n = 0; + int i = 0; + int j = 0; + int k = 0; + int ret_value = 0; /* Generate values, ping-pong from ends of range - */ + */ for (i = 0, n = 0; (hsize_t)i < dims[0]; i++) { for (j = 0; (hsize_t)j < dims[1]; j++) { for (k = 0; (hsize_t)k < dims[2]; k++, n++) { @@ -282,16 +292,17 @@ generate_uint8be(hbool_t external) { * Returns 0 on success, -1 on failure. */ static int -generate_f32le(hbool_t external) { - hsize_t dims[] = { 12, 6 }; - float wdata[72]; /* 12*6, from dims */ - struct external_def *def_ptr = NULL; - struct external_def def = { (hsize_t) sizeof(float), 72, 72 }; - float n = 0; - int i = 0; - int j = 0; - int k = 0; - int ret_value = 0; +generate_f32le(hbool_t external) +{ + hsize_t dims[] = {12, 6}; + float wdata[72]; /* 12*6, from dims */ + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(float), 72, 72}; + float n = 0; + int i = 0; + int j = 0; + int k = 0; + int ret_value = 0; /* Generate values */ for (i = 0, k = 0, n = 0; (hsize_t)i < dims[0]; i++) { @@ -312,7 +323,8 @@ generate_f32le(hbool_t external) { * Return 0 on success, nonzero on failure. */ int -main(void) { +main(void) +{ int i = 0; for (i = 0; i < 2; i++) { @@ -336,4 +348,3 @@ main(void) { return EXIT_SUCCESS; } /* end main() */ - |