diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/API/H5_api_async_test.c | 22 | ||||
-rw-r--r-- | test/API/H5_api_attribute_test.c | 2 | ||||
-rw-r--r-- | test/API/H5_api_dataset_test.c | 17 | ||||
-rw-r--r-- | test/API/H5_api_file_test.c | 2 | ||||
-rw-r--r-- | test/API/H5_api_group_test.c | 8 | ||||
-rw-r--r-- | test/filter_plugin.c | 10 |
6 files changed, 29 insertions, 32 deletions
diff --git a/test/API/H5_api_async_test.c b/test/API/H5_api_async_test.c index 7777e10..6bcbe8d 100644 --- a/test/API/H5_api_async_test.c +++ b/test/API/H5_api_async_test.c @@ -369,7 +369,7 @@ test_multi_dataset_io(void) /* Loop over datasets */ for (i = 0; i < 5; i++) { /* Set dataset name */ - sprintf(dset_name, "dset%d", i); + snprintf(dset_name, sizeof(dset_name), "dset%d", i); /* Create the dataset asynchronously */ if ((dset_id[i] = H5Dcreate_async(file_id, dset_name, H5T_NATIVE_INT, space_id, H5P_DEFAULT, @@ -450,7 +450,7 @@ test_multi_dataset_io(void) /* Loop over datasets */ for (i = 0; i < 5; i++) { /* Set dataset name */ - sprintf(dset_name, "dset%d", i); + snprintf(dset_name, sizeof(dset_name), "dset%d", i); /* Open the dataset asynchronously */ if ((dset_id[0] = H5Dopen_async(file_id, dset_name, H5P_DEFAULT, es_id)) < 0) @@ -479,7 +479,7 @@ test_multi_dataset_io(void) /* Loop over datasets */ for (i = 0; i < 5; i++) { /* Set dataset name */ - sprintf(dset_name, "dset%d", i); + snprintf(dset_name, sizeof(dset_name), "dset%d", i); /* Open the dataset asynchronously */ if ((dset_id[0] = H5Dopen_async(file_id, dset_name, H5P_DEFAULT, es_id)) < 0) @@ -619,7 +619,7 @@ test_multi_file_dataset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - sprintf(file_name, ASYNC_API_TEST_FILE_PRINTF, i); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Create file asynchronously */ if ((file_id[i] = @@ -761,7 +761,7 @@ test_multi_file_dataset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - sprintf(file_name, ASYNC_API_TEST_FILE_PRINTF, i); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Open the file asynchronously */ if ((file_id[0] = H5Fopen_async(file_name, H5F_ACC_RDWR, H5P_DEFAULT, es_id)) < 0) @@ -799,7 +799,7 @@ test_multi_file_dataset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - sprintf(file_name, ASYNC_API_TEST_FILE_PRINTF, i); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Open the file asynchronously */ if ((file_id[0] = H5Fopen_async(file_name, H5F_ACC_RDONLY, H5P_DEFAULT, es_id)) < 0) @@ -929,7 +929,7 @@ test_multi_file_grp_dset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - sprintf(file_name, ASYNC_API_TEST_FILE_PRINTF, i); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Create file asynchronously */ if ((file_id = H5Fcreate_async(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT, es_id)) < @@ -981,7 +981,7 @@ test_multi_file_grp_dset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - sprintf(file_name, ASYNC_API_TEST_FILE_PRINTF, i); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Open the file asynchronously */ if ((file_id = H5Fopen_async(file_name, H5F_ACC_RDONLY, H5P_DEFAULT, es_id)) < 0) @@ -1039,7 +1039,7 @@ test_multi_file_grp_dset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - sprintf(file_name, ASYNC_API_TEST_FILE_PRINTF, i); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Create file asynchronously */ if ((file_id = H5Fcreate_async(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT, es_id)) < @@ -1096,7 +1096,7 @@ test_multi_file_grp_dset_io(void) /* Loop over files */ for (i = 0; i < 5; i++) { /* Set file name */ - sprintf(file_name, ASYNC_API_TEST_FILE_PRINTF, i); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); /* Open the file asynchronously */ if ((file_id = H5Fopen_async(file_name, H5F_ACC_RDONLY, H5P_DEFAULT, es_id)) < 0) @@ -2676,7 +2676,7 @@ cleanup_files(void) H5Fdelete(ASYNC_API_TEST_FILE, H5P_DEFAULT); for (i = 0; i <= max_printf_file; i++) { - snprintf(file_name, 64, ASYNC_API_TEST_FILE_PRINTF, i); + snprintf(file_name, sizeof(file_name), ASYNC_API_TEST_FILE_PRINTF, i); H5Fdelete(file_name, H5P_DEFAULT); } /* end for */ } diff --git a/test/API/H5_api_attribute_test.c b/test/API/H5_api_attribute_test.c index db8e6ad..02eddd0 100644 --- a/test/API/H5_api_attribute_test.c +++ b/test/API/H5_api_attribute_test.c @@ -10725,7 +10725,7 @@ test_attribute_many(void) /* Create many attributes */ for (u = 0; u < ATTRIBUTE_MANY_NUMB; u++) { - sprintf(attrname, "many-%06u", u); + snprintf(attrname, sizeof(attrname), "many-%06u", u); if ((attr_id = H5Acreate2(group_id, attrname, attr_dtype, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); diff --git a/test/API/H5_api_dataset_test.c b/test/API/H5_api_dataset_test.c index f02445d..e9ad15c 100644 --- a/test/API/H5_api_dataset_test.c +++ b/test/API/H5_api_dataset_test.c @@ -1218,7 +1218,7 @@ test_create_dataset_random_shapes(void) goto error; } - sprintf(name, "%s%zu", DATASET_SHAPE_TEST_DSET_BASE_NAME, i + 1); + snprintf(name, sizeof(name), "%s%zu", DATASET_SHAPE_TEST_DSET_BASE_NAME, i + 1); if ((dset_id = H5Dcreate2(group_id, name, dset_dtype, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -1316,7 +1316,7 @@ test_create_dataset_predefined_types(void) generate_random_dataspace(DATASET_PREDEFINED_TYPE_TEST_SPACE_RANK, NULL, NULL, false)) < 0) TEST_ERROR; - sprintf(name, "%s%zu", DATASET_PREDEFINED_TYPE_TEST_BASE_NAME, i); + snprintf(name, sizeof(name), "%s%zu", DATASET_PREDEFINED_TYPE_TEST_BASE_NAME, i); if ((dset_id = H5Dcreate2(group_id, name, predefined_type_test_table[i], fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -2154,7 +2154,8 @@ test_create_dataset_creation_properties(void) PART_ERROR(DCPL_alloc_time_test); } - sprintf(name, "%s%zu", DATASET_CREATION_PROPERTIES_TEST_ALLOC_TIMES_BASE_NAME, i); + snprintf(name, sizeof(name), "%s%zu", DATASET_CREATION_PROPERTIES_TEST_ALLOC_TIMES_BASE_NAME, + i); if ((dset_id = H5Dcreate2(group_id, name, dset_dtype, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) { @@ -2230,7 +2231,8 @@ test_create_dataset_creation_properties(void) PART_ERROR(DCPL_attr_crt_order_test); } - sprintf(name, "%s%zu", DATASET_CREATION_PROPERTIES_TEST_CRT_ORDER_BASE_NAME, i); + snprintf(name, sizeof(name), "%s%zu", DATASET_CREATION_PROPERTIES_TEST_CRT_ORDER_BASE_NAME, + i); if ((dset_id = H5Dcreate2(group_id, name, dset_dtype, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) { @@ -2363,7 +2365,8 @@ test_create_dataset_creation_properties(void) PART_ERROR(DCPL_fill_time_property_test); } - sprintf(name, "%s%zu", DATASET_CREATION_PROPERTIES_TEST_FILL_TIMES_BASE_NAME, i); + snprintf(name, sizeof(name), "%s%zu", DATASET_CREATION_PROPERTIES_TEST_FILL_TIMES_BASE_NAME, + i); if ((dset_id = H5Dcreate2(group_id, name, dset_dtype, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) { @@ -2931,7 +2934,7 @@ test_create_dataset_creation_properties(void) } } - sprintf(name, "%s%zu", DATASET_CREATION_PROPERTIES_TEST_LAYOUTS_BASE_NAME, i); + snprintf(name, sizeof(name), "%s%zu", DATASET_CREATION_PROPERTIES_TEST_LAYOUTS_BASE_NAME, i); if ((dset_id = H5Dcreate2(group_id, name, (H5D_COMPACT == layouts[i]) ? compact_dtype : dset_dtype, @@ -3192,7 +3195,7 @@ test_create_many_dataset(void) printf("\n"); for (i = 0; i < DATASET_NUMB; i++) { printf("\r %u/%u", i + 1, DATASET_NUMB); - sprintf(dset_name, "dset_%02u", i); + snprintf(dset_name, sizeof(dset_name), "dset_%02u", i); data = i % 256; if ((dset_id = H5Dcreate2(group_id, dset_name, H5T_NATIVE_UCHAR, dataspace_id, H5P_DEFAULT, diff --git a/test/API/H5_api_file_test.c b/test/API/H5_api_file_test.c index 804b3bd..5b91551 100644 --- a/test/API/H5_api_file_test.c +++ b/test/API/H5_api_file_test.c @@ -948,7 +948,7 @@ test_flush_file(void) } for (u = 0; u < 10; u++) { - sprintf(dset_name, "Dataset %u", u); + snprintf(dset_name, sizeof(dset_name), "Dataset %u", u); if ((dset_id = H5Dcreate2(file_id, dset_name, H5T_STD_U32LE, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { diff --git a/test/API/H5_api_group_test.c b/test/API/H5_api_group_test.c index 4132f64..0203ebe 100644 --- a/test/API/H5_api_group_test.c +++ b/test/API/H5_api_group_test.c @@ -229,7 +229,7 @@ test_create_many_groups(void) printf("\n"); for (i = 0; i < GROUP_NUMB_MANY; i++) { printf("\r %u/%u", i + 1, GROUP_NUMB_MANY); - sprintf(group_name, "group %02u", i); + snprintf(group_name, sizeof(group_name), "group %02u", i); if ((child_group_id = H5Gcreate2(parent_group_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); @@ -342,11 +342,11 @@ create_group_recursive(hid_t parent_gid, unsigned counter) printf("\r %u/%u", counter, GROUP_DEPTH); if (counter == 1) - sprintf(gname, "2nd_child_group"); + snprintf(gname, sizeof(gname), "2nd_child_group"); else if (counter == 2) - sprintf(gname, "3rd_child_group"); + snprintf(gname, sizeof(gname), "3rd_child_group"); else - sprintf(gname, "%dth_child_group", counter + 1); + snprintf(gname, sizeof(gname), "%dth_child_group", counter + 1); if ((child_gid = H5Gcreate2(parent_gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); printf(" couldn't create group '%s'\n", gname); diff --git a/test/filter_plugin.c b/test/filter_plugin.c index 1571bf2..9207d9e 100644 --- a/test/filter_plugin.c +++ b/test/filter_plugin.c @@ -847,10 +847,7 @@ test_creating_groups_using_plugins(hid_t fid) /* Create multiple groups under the top-level group */ for (i = 0; i < N_SUBGROUPS; i++) { - char *sp = subgroup_name; - - sp += snprintf(subgroup_name, sizeof(subgroup_name), SUBGROUP_PREFIX); - sprintf(sp, "%d", i); + snprintf(subgroup_name, sizeof(subgroup_name), SUBGROUP_PREFIX "%d", i); if ((sub_gid = H5Gcreate2(gid, subgroup_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -906,10 +903,7 @@ test_opening_groups_using_plugins(hid_t fid) /* Open all the sub-groups under the top-level group */ for (i = 0; i < N_SUBGROUPS; i++) { - char *sp = subgroup_name; - - sp += snprintf(subgroup_name, sizeof(subgroup_name), SUBGROUP_PREFIX); - sprintf(sp, "%d", i); + snprintf(subgroup_name, sizeof(subgroup_name), SUBGROUP_PREFIX "%d", i); if ((sub_gid = H5Gopen2(gid, subgroup_name, H5P_DEFAULT)) < 0) TEST_ERROR; |