summaryrefslogtreecommitdiffstats
path: root/test/tcoords.c
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2022-05-03 17:57:19 (GMT)
committerGitHub <noreply@github.com>2022-05-03 17:57:19 (GMT)
commit493846dbf4793b7e9f6ce5e1d8b8cfc29705ecca (patch)
tree9053e2f8881464c63630dddee33bc9ba9dafe53c /test/tcoords.c
parent5f00066eacdf2b2ddb3cf92635bea99eb1aee85e (diff)
downloadhdf5-493846dbf4793b7e9f6ce5e1d8b8cfc29705ecca.zip
hdf5-493846dbf4793b7e9f6ce5e1d8b8cfc29705ecca.tar.gz
hdf5-493846dbf4793b7e9f6ce5e1d8b8cfc29705ecca.tar.bz2
[1.12 Merge]Hdf5 1 12 warnings fixes (#1715)
* Warnings fixes (#1680) * Clean stack size warnings in sio_engine (#1687) * Fixes stack size warnings in tcoords.c (#1688) * Address some warnings from casting away of const (#1684) * Fixes stack size warnings in ntypes (#1695) * Fixes stack size warnings in dtransform (#1696) * Fixes stack size warnings in set_extent test (#1698) * Be a bit safer with signed arithmetic, thus quieting some signed-overflow warnings from GCC (#1706) * Avoid a signed overflow: check the range of `entry_ptr->age` before increasing it instead of increasing it and then checking the range. This quiets a GCC warning. * Avoid the potential for signed overflow by rewriting expressions `MAX(0, fwidth - n)` as `MAX(n, fwidth) - n` for various `n`. This change quiets some GCC warnings. * Change some local variables that cannot take sensible negative values from signed to unsigned. This quiets GCC warnings about potential signed overflow. * In a handful of instances, check the range of a signed integer before increasing/decreasing it, just in case the increase/decrease overflows. This quiets a handful of GCC signed-overflow warnings. * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Fix object size warnings in cache.c test (#1701) * Fix some const cast and stack/static object size warnings (#1700) * Fix various warnings * Move HDfree_const to H5private.h for wider use * Print output from all ranks in parallel tests on allocation failure * Move const pointer freeing macro to h5test.h for now * Stop lying about H5S_t const-ness (#1209) Hyperslabs can be reworked inside several H5S callbacks, making H5S_t non-const in some places where it is marked const. This change switches these incorrectly const H5S_t pointer parameters and variables to non-const where appropriate. * Fix a few warnings after recent H5S const-related changes (#1225) * Adjustments for HDF5 1.12 Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: David Young <dyoung@hdfgroup.org> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test/tcoords.c')
-rw-r--r--test/tcoords.c62
1 files changed, 48 insertions, 14 deletions
diff --git a/test/tcoords.c b/test/tcoords.c
index b2d68d3..37c1c1a 100644
--- a/test/tcoords.c
+++ b/test/tcoords.c
@@ -380,10 +380,14 @@ test_multiple_ends(hid_t file, hbool_t is_chunked)
int i, j, k, l, m, n, p;
hsize_t da_dims[8] = {4, 5, 3, 4, 2, 3, 6, 2};
hsize_t da_chunksize[8] = {1, 5, 3, 2, 2, 3, 3, 2};
- int data_buf[4][5][3][4][2][3][6][2];
+ struct {
+ int arr[4][5][3][4][2][3][6][2];
+ } *data_buf = NULL;
/* For testing the full selections in the fastest-growing end and in the middle dimensions */
- int mem1_buffer[1][1][1][4][2][1][6][2];
+ struct {
+ int arr[1][1][1][4][2][1][6][2];
+ } *mem1_buffer = NULL;
hsize_t mem1_dims[8] = {1, 1, 1, 4, 2, 1, 6, 2};
hsize_t mem1_start[8] = {0, 0, 0, 0, 0, 0, 0, 0};
hsize_t mem1_count[8] = {1, 1, 1, 1, 1, 1, 1, 1};
@@ -391,7 +395,9 @@ test_multiple_ends(hid_t file, hbool_t is_chunked)
hsize_t mem1_block[8] = {1, 1, 1, 4, 2, 1, 6, 2};
/* For testing the full selections in the slowest-growing end and in the middle dimensions */
- int mem2_buffer[4][5][1][4][2][1][1][1];
+ struct {
+ int arr[4][5][1][4][2][1][1][1];
+ } *mem2_buffer = NULL;
hsize_t mem2_dims[8] = {4, 5, 1, 4, 2, 1, 1, 1};
hsize_t mem2_start[8] = {0, 0, 0, 0, 0, 0, 0, 0};
hsize_t mem2_count[8] = {1, 1, 1, 1, 1, 1, 1, 1};
@@ -399,7 +405,9 @@ test_multiple_ends(hid_t file, hbool_t is_chunked)
hsize_t mem2_block[8] = {4, 5, 1, 4, 2, 1, 1, 1};
/* For testing two unadjacent full selections in the middle dimensions */
- int mem3_buffer[1][5][3][1][1][3][6][1];
+ struct {
+ int arr[1][5][3][1][1][3][6][1];
+ } *mem3_buffer = NULL;
hsize_t mem3_dims[8] = {1, 5, 3, 1, 1, 3, 6, 1};
hsize_t mem3_start[8] = {0, 0, 0, 0, 0, 0, 0, 0};
hsize_t mem3_count[8] = {1, 1, 1, 1, 1, 1, 1, 1};
@@ -407,7 +415,9 @@ test_multiple_ends(hid_t file, hbool_t is_chunked)
hsize_t mem3_block[8] = {1, 5, 3, 1, 1, 3, 6, 1};
/* For testing the full selections in the fastest-growing end and the slowest-growing end */
- int mem4_buffer[4][5][1][1][1][1][6][2];
+ struct {
+ int arr[4][5][1][1][1][1][6][2];
+ } *mem4_buffer = NULL;
hsize_t mem4_dims[8] = {4, 5, 1, 1, 1, 1, 6, 2};
hsize_t mem4_start[8] = {0, 0, 0, 0, 0, 0, 0, 0};
hsize_t mem4_count[8] = {1, 1, 1, 1, 1, 1, 1, 1};
@@ -416,13 +426,29 @@ test_multiple_ends(hid_t file, hbool_t is_chunked)
/* For testing the full selections in the fastest-growing end and slowest-growing end,
* also in the middle dimensions */
- int mem5_buffer[4][5][1][4][2][1][6][2];
+ struct {
+ int arr[4][5][1][4][2][1][6][2];
+ } *mem5_buffer = NULL;
hsize_t mem5_dims[8] = {4, 5, 1, 4, 2, 1, 6, 2};
hsize_t mem5_start[8] = {0, 0, 0, 0, 0, 0, 0, 0};
hsize_t mem5_count[8] = {1, 1, 1, 1, 1, 1, 1, 1};
hsize_t mem5_stride[8] = {1, 1, 1, 1, 1, 1, 1, 1};
hsize_t mem5_block[8] = {4, 5, 1, 4, 2, 1, 6, 2};
+ /* Initialize dynamic arrays */
+ data_buf = HDcalloc(1, sizeof(*data_buf));
+ CHECK_PTR(data_buf, "HDcalloc");
+ mem1_buffer = HDcalloc(1, sizeof(*mem1_buffer));
+ CHECK_PTR(data_buf, "HDcalloc");
+ mem2_buffer = HDcalloc(1, sizeof(*mem2_buffer));
+ CHECK_PTR(data_buf, "HDcalloc");
+ mem3_buffer = HDcalloc(1, sizeof(*mem3_buffer));
+ CHECK_PTR(data_buf, "HDcalloc");
+ mem4_buffer = HDcalloc(1, sizeof(*mem4_buffer));
+ CHECK_PTR(data_buf, "HDcalloc");
+ mem5_buffer = HDcalloc(1, sizeof(*mem5_buffer));
+ CHECK_PTR(data_buf, "HDcalloc");
+
/* Create and write the dataset */
sid = H5Screate_simple(8, da_dims, da_dims);
CHECK(sid, FAIL, "H5Screate_simple");
@@ -451,10 +477,10 @@ test_multiple_ends(hid_t file, hbool_t is_chunked)
for (m = 0; m < 2; m++)
for (n = 0; n < 3; n++)
for (p = 0; p < 6; p++) {
- data_buf[i][j][k][l][m][n][p][0] =
+ data_buf->arr[i][j][k][l][m][n][p][0] =
i * 1000000 + j * 100000 + k * 10000 + l * 1000 + m * 100 + n * 10 + p;
- data_buf[i][j][k][l][m][n][p][1] = i * 1000000 + j * 100000 + k * 10000 +
- l * 1000 + m * 100 + n * 10 + p + 1;
+ data_buf->arr[i][j][k][l][m][n][p][1] = i * 1000000 + j * 100000 + k * 10000 +
+ l * 1000 + m * 100 + n * 10 + p + 1;
}
ret = H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data_buf);
@@ -491,7 +517,7 @@ test_multiple_ends(hid_t file, hbool_t is_chunked)
for (j = 0; j < 2; j++)
for (k = 0; k < 6; k++)
for (l = 0; l < 2; l++)
- if (data_buf[0][0][0][i][j][0][k][l] != mem1_buffer[0][0][0][i][j][0][k][l]) {
+ if (data_buf->arr[0][0][0][i][j][0][k][l] != mem1_buffer->arr[0][0][0][i][j][0][k][l]) {
TestErrPrintf("%u: Read different values than written at index 0,0,0,%d,%d,0,%d,%d\n",
__LINE__, i, j, k, l);
}
@@ -524,7 +550,7 @@ test_multiple_ends(hid_t file, hbool_t is_chunked)
for (j = 0; j < 5; j++)
for (k = 0; k < 4; k++)
for (l = 0; l < 2; l++)
- if (data_buf[i][j][0][k][l][0][0][0] != mem2_buffer[i][j][0][k][l][0][0][0]) {
+ if (data_buf->arr[i][j][0][k][l][0][0][0] != mem2_buffer->arr[i][j][0][k][l][0][0][0]) {
TestErrPrintf("%u: Read different values than written at index %d,%d,0,%d,%d,0,0,0\n",
__LINE__, i, j, k, l);
}
@@ -557,7 +583,7 @@ test_multiple_ends(hid_t file, hbool_t is_chunked)
for (j = 0; j < 3; j++)
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
- if (data_buf[0][i][j][0][0][k][l][0] != mem3_buffer[0][i][j][0][0][k][l][0]) {
+ if (data_buf->arr[0][i][j][0][0][k][l][0] != mem3_buffer->arr[0][i][j][0][0][k][l][0]) {
TestErrPrintf("%u: Read different values than written at index 0,%d,%d,0,0,%d,%d,0\n",
__LINE__, i, j, k, l);
}
@@ -590,7 +616,7 @@ test_multiple_ends(hid_t file, hbool_t is_chunked)
for (j = 0; j < 5; j++)
for (k = 0; k < 6; k++)
for (l = 0; l < 2; l++)
- if (data_buf[i][j][0][0][0][0][k][l] != mem4_buffer[i][j][0][0][0][0][k][l]) {
+ if (data_buf->arr[i][j][0][0][0][0][k][l] != mem4_buffer->arr[i][j][0][0][0][0][k][l]) {
TestErrPrintf("%u: Read different values than written at index %d,%d,0,0,0,0,%d,%d\n",
__LINE__, i, j, k, l);
}
@@ -626,7 +652,8 @@ test_multiple_ends(hid_t file, hbool_t is_chunked)
for (l = 0; l < 2; l++)
for (m = 0; m < 6; m++)
for (n = 0; n < 2; n++)
- if (data_buf[i][j][0][k][l][0][m][n] != mem5_buffer[i][j][0][k][l][0][m][n]) {
+ if (data_buf->arr[i][j][0][k][l][0][m][n] !=
+ mem5_buffer->arr[i][j][0][k][l][0][m][n]) {
TestErrPrintf(
"%u: Read different values than written at index %d,%d,0,%d,%d,0,%d,%d\n",
__LINE__, i, j, k, l, m, n);
@@ -637,6 +664,13 @@ test_multiple_ends(hid_t file, hbool_t is_chunked)
ret = H5Pclose(plid);
CHECK(ret, FAIL, "H5Pclose");
+
+ HDfree(data_buf);
+ HDfree(mem1_buffer);
+ HDfree(mem2_buffer);
+ HDfree(mem3_buffer);
+ HDfree(mem4_buffer);
+ HDfree(mem5_buffer);
}
/****************************************************************