Skip to content

Commit 9e7e2f8

Browse files
authored
Fix a misc warning in test/vol.c (HDFGroup#3112)
The compiler complains about using integers instead of size_t for some sizes.
1 parent 281dbf4 commit 9e7e2f8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

test/vol.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,9 @@ reg_opt_datatype_get(void H5_ATTR_UNUSED *obj, H5VL_datatype_get_args_t *args, h
573573
static herr_t
574574
fake_vol_info_to_str(const void *info, char **str)
575575
{
576-
herr_t ret_value = SUCCEED; /* Return value */
577-
const int val = *(const int *)info;
578-
const int str_size = 16; /* The size of the string */
576+
const int val = *(const int *)info;
577+
const size_t str_size = 16; /* The size of the string */
578+
herr_t ret_value = SUCCEED;
579579

580580
/* Verify the info is correct before continuing */
581581
if (val != INT_MAX) {
@@ -584,9 +584,10 @@ fake_vol_info_to_str(const void *info, char **str)
584584
}
585585

586586
/* Allocate the string long enough for the info */
587-
*str = (char *)malloc(str_size);
587+
if (NULL == (*str = (char *)HDcalloc(1, str_size)))
588+
return FAIL;
588589

589-
HDsnprintf(*str, str_size, "%d", *((const int *)info));
590+
HDsnprintf(*str, str_size, "%d", val);
590591

591592
return ret_value;
592593
} /* end fake_vol_info_to_str() */

0 commit comments

Comments
 (0)