Skip to content

Commit

Permalink
Fix flipped calloc args in trefer(_deprec).c
Browse files Browse the repository at this point in the history
  • Loading branch information
derobins committed Oct 19, 2024
1 parent 5f5c295 commit 3379369
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 49 deletions.
74 changes: 37 additions & 37 deletions test/trefer.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ test_reference_params(void)
MESSAGE(5, ("Testing Reference Parameters\n"));

/* Allocate write & read buffers */
wbuf = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
rbuf = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
tbuf = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
obuf = calloc(sizeof(unsigned), SPACE1_DIM1);
wbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
rbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
tbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
obuf = (unsigned *)calloc(SPACE1_DIM1, sizeof(unsigned));

for (i = 0; i < SPACE1_DIM1; i++)
obuf[i] = i * 3;
Expand Down Expand Up @@ -468,10 +468,10 @@ test_reference_obj(void)
MESSAGE(5, ("Testing Object Reference Functions\n"));

/* Allocate write & read buffers */
wbuf = calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
rbuf = calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
ibuf = calloc(sizeof(unsigned), SPACE1_DIM1);
obuf = calloc(sizeof(unsigned), SPACE1_DIM1);
wbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
rbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
ibuf = (unsigned *)calloc(SPACE1_DIM1, sizeof(unsigned));
obuf = (unsigned *)calloc(SPACE1_DIM1, sizeof(unsigned));

for (i = 0; i < SPACE1_DIM1; i++)
obuf[i] = i * 3;
Expand Down Expand Up @@ -571,7 +571,7 @@ test_reference_obj(void)
VERIFY(obj_type, H5O_TYPE_NAMED_DATATYPE, "H5Rget_obj_type3");

/* Check copying a reference */
wbuf_cp = calloc(sizeof(H5R_ref_t), 1);
wbuf_cp = (H5R_ref_t *)calloc(1, sizeof(H5R_ref_t));
ret = H5Rcopy(&wbuf[0], &wbuf_cp[0]);
CHECK(ret, FAIL, "H5Rcopy");

Expand Down Expand Up @@ -838,9 +838,9 @@ test_reference_vlen_obj(void)
MESSAGE(5, ("Testing Object Reference Functions within VLEN type\n"));

/* Allocate write & read buffers */
wbuf = calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
ibuf = calloc(sizeof(unsigned), SPACE1_DIM1);
obuf = calloc(sizeof(unsigned), SPACE1_DIM1);
wbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
ibuf = (unsigned *)calloc(SPACE1_DIM1, sizeof(unsigned));
obuf = (unsigned *)calloc(SPACE1_DIM1, sizeof(unsigned));

for (i = 0; i < SPACE1_DIM1; i++)
obuf[i] = i * 3;
Expand Down Expand Up @@ -1102,8 +1102,8 @@ test_reference_cmpnd_obj(void)
MESSAGE(5, ("Testing Object Reference Functions within compound type\n"));

/* Allocate write & read buffers */
ibuf = calloc(sizeof(unsigned), SPACE1_DIM1);
obuf = calloc(sizeof(unsigned), SPACE1_DIM1);
ibuf = (unsigned *)calloc(SPACE1_DIM1, sizeof(unsigned));
obuf = (unsigned *)calloc(SPACE1_DIM1, sizeof(unsigned));

for (i = 0; i < SPACE1_DIM1; i++)
obuf[i] = i * 3;
Expand Down Expand Up @@ -1411,10 +1411,10 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high)
MESSAGE(5, ("Testing Dataset Region Reference Functions\n"));

/* Allocate write & read buffers */
wbuf = calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
rbuf = calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
dwbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2));
drbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2));
wbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
rbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
dwbuf = (uint8_t *)calloc((SPACE2_DIM1 * SPACE2_DIM2), sizeof(uint8_t));
drbuf = (uint8_t *)calloc((SPACE2_DIM1 * SPACE2_DIM2), sizeof(uint8_t));

for (tu8 = dwbuf, i = 0; i < (SPACE2_DIM1 * SPACE2_DIM2); i++)
*tu8++ = (uint8_t)(i * 3);
Expand Down Expand Up @@ -1867,10 +1867,10 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high)
MESSAGE(5, ("Testing 1-D Dataset Region Reference Functions\n"));

/* Allocate write & read buffers */
wbuf = calloc(sizeof(H5R_ref_t), (size_t)SPACE1_DIM1);
rbuf = calloc(sizeof(H5R_ref_t), (size_t)SPACE1_DIM1);
dwbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)SPACE3_DIM1);
drbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)SPACE3_DIM1);
wbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
rbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
dwbuf = (uint8_t *)calloc(SPACE3_DIM1, sizeof(uint8_t));
drbuf = (uint8_t *)calloc(SPACE3_DIM1, sizeof(uint8_t));

for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++)
*tu8++ = (uint8_t)(i * 3);
Expand Down Expand Up @@ -3125,10 +3125,10 @@ test_reference_compat_conv(void)
}

/* Allocate write & read buffers */
wbuf_obj = (hobj_ref_t *)calloc(sizeof(hobj_ref_t), SPACE1_DIM1);
rbuf_obj = calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
wbuf_reg = calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1);
rbuf_reg = calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
wbuf_obj = (hobj_ref_t *)calloc(SPACE1_DIM1, sizeof(hobj_ref_t));
rbuf_obj = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
wbuf_reg = (hdset_reg_ref_t *)calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t));
rbuf_reg = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));

/* Create dataspace for datasets */
sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
Expand Down Expand Up @@ -3434,17 +3434,17 @@ test_reference_perf(void)
MESSAGE(5, ("Testing Object Reference Performance\n"));

/* Allocate write & read buffers */
wbuf = calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
obuf = calloc(sizeof(unsigned), SPACE1_DIM1);
ibuf = calloc(sizeof(unsigned), SPACE1_DIM1);
wbuf_deprec = (hobj_ref_t *)calloc(sizeof(hobj_ref_t), SPACE1_DIM1);
rbuf = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
rbuf_deprec = (hobj_ref_t *)calloc(sizeof(hobj_ref_t), SPACE1_DIM1);
tbuf = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
wbuf_reg = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
rbuf_reg = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1);
wbuf_reg_deprec = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1);
rbuf_reg_deprec = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1);
wbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
obuf = (unsigned *)calloc(SPACE1_DIM1, sizeof(unsigned));
ibuf = (unsigned *)calloc(SPACE1_DIM1, sizeof(unsigned));
wbuf_deprec = (hobj_ref_t *)calloc(SPACE1_DIM1, sizeof(hobj_ref_t));
rbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
rbuf_deprec = (hobj_ref_t *)calloc(SPACE1_DIM1, sizeof(hobj_ref_t));
tbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
wbuf_reg = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
rbuf_reg = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t));
wbuf_reg_deprec = (hdset_reg_ref_t *)calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t));
rbuf_reg_deprec = (hdset_reg_ref_t *)calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t));

for (i = 0; i < SPACE1_DIM1; i++)
obuf[i] = i * 3;
Expand Down
24 changes: 12 additions & 12 deletions test/trefer_deprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,10 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high)
MESSAGE(5, ("Testing Dataset Region Reference Functions\n"));

/* Allocate write & read buffers */
wbuf = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1);
rbuf = (hdset_reg_ref_t *)malloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1);
dwbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2);
drbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2));
wbuf = (hdset_reg_ref_t *)calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t));
rbuf = (hdset_reg_ref_t *)malloc(SPACE1_DIM1 * sizeof(hdset_reg_ref_t));
dwbuf = (uint8_t *)malloc((SPACE2_DIM1 * SPACE2_DIM2) * sizeof(uint8_t));
drbuf = (uint8_t *)calloc((SPACE2_DIM1 * SPACE2_DIM2), sizeof(uint8_t));

/* Create file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
Expand Down Expand Up @@ -1064,10 +1064,10 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high)
MESSAGE(5, ("Testing 1-D Dataset Region Reference Functions\n"));

/* Allocate write & read buffers */
wbuf = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1);
rbuf = (hdset_reg_ref_t *)malloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1);
dwbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE3_DIM1);
drbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)SPACE3_DIM1);
wbuf = (hdset_reg_ref_t *)calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t));
rbuf = (hdset_reg_ref_t *)malloc(SPACE1_DIM1 * sizeof(hdset_reg_ref_t));
dwbuf = (uint8_t *)malloc(SPACE3_DIM1 * sizeof(uint8_t));
drbuf = (uint8_t *)calloc(SPACE3_DIM1, sizeof(uint8_t));

/* Create the file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
Expand Down Expand Up @@ -1636,10 +1636,10 @@ test_reference_compat(void)
MESSAGE(5, ("Testing Deprecated Object Reference Functions\n"));

/* Allocate write & read buffers */
wbuf_obj = (hobj_ref_t *)calloc(sizeof(hobj_ref_t), SPACE1_DIM1);
rbuf_obj = (hobj_ref_t *)malloc(sizeof(hobj_ref_t) * SPACE1_DIM1);
wbuf_reg = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1);
rbuf_reg = (hdset_reg_ref_t *)malloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1);
wbuf_obj = (hobj_ref_t *)calloc(SPACE1_DIM1, sizeof(hobj_ref_t));
rbuf_obj = (hobj_ref_t *)malloc(SPACE1_DIM1 * sizeof(hobj_ref_t));
wbuf_reg = (hdset_reg_ref_t *)calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t));
rbuf_reg = (hdset_reg_ref_t *)malloc(SPACE1_DIM1 * sizeof(hdset_reg_ref_t));

/* Create file */
fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
Expand Down

0 comments on commit 3379369

Please sign in to comment.