summaryrefslogtreecommitdiffstats
path: root/c++/test
diff options
context:
space:
mode:
Diffstat (limited to 'c++/test')
-rw-r--r--c++/test/tattr.cpp8
-rw-r--r--c++/test/th5s.cpp2
-rw-r--r--c++/test/titerate.cpp2
-rw-r--r--c++/test/tvlstr.cpp10
4 files changed, 11 insertions, 11 deletions
diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp
index adaa237..bd6a8c0 100644
--- a/c++/test/tattr.cpp
+++ b/c++/test/tattr.cpp
@@ -93,7 +93,7 @@ struct attr4_struct {
const H5std_string ATTR5_NAME("Attr5");
const int ATTR5_RANK = 0;
-float attr_data5 = (float)-5.123; // Test data for 5th attribute
+float attr_data5 = -5.123F; // Test data for 5th attribute
/* Info for another attribute */
const H5std_string ATTR1A_NAME("Attr1_a");
@@ -1741,7 +1741,7 @@ test_attr_dense_create(FileCreatPropList &fcpl, FileAccPropList &fapl)
unsigned attr_num;
for (attr_num = 0; attr_num < max_compact; attr_num++) {
// Create attribute
- sprintf(attr_name, "attr %02u", attr_num);
+ snprintf(attr_name, sizeof(attr_name), "attr %02u", attr_num);
Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space);
// Write data to the attribute
@@ -1753,7 +1753,7 @@ test_attr_dense_create(FileCreatPropList &fcpl, FileAccPropList &fapl)
{ // Add one more attribute, to push into "dense" storage
// Create another attribute
- sprintf(attr_name, "attr %02u", attr_num);
+ snprintf(attr_name, sizeof(attr_name), "attr %02u", attr_num);
Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space);
// Write data to the attribute
@@ -1763,7 +1763,7 @@ test_attr_dense_create(FileCreatPropList &fcpl, FileAccPropList &fapl)
// Attempt to add attribute again, which should fail
try {
// Create another attribute
- sprintf(attr_name, "attr %02u", attr_num);
+ snprintf(attr_name, sizeof(attr_name), "attr %02u", attr_num);
Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space);
// continuation here, that means no exception has been thrown
diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp
index 9952e68..9dd92fa 100644
--- a/c++/test/th5s.cpp
+++ b/c++/test/th5s.cpp
@@ -73,7 +73,7 @@ struct space4_struct {
unsigned u;
float f;
char c2;
-} space4_data = {'v', 987123, (float)-3.14, 'g'}; /* Test data for 4th dataspace */
+} space4_data = {'v', 987123, -3.14F, 'g'}; /* Test data for 4th dataspace */
/* Null dataspace */
int space5_data = 7;
diff --git a/c++/test/titerate.cpp b/c++/test/titerate.cpp
index 7fb64c4..5b8039f 100644
--- a/c++/test/titerate.cpp
+++ b/c++/test/titerate.cpp
@@ -161,7 +161,7 @@ test_iter_group(FileAccPropList &fapl)
DataSpace filespace;
for (i = 0; i < NDATASETS; i++) {
- sprintf(name, "Dataset %d", i);
+ snprintf(name, sizeof(name), "Dataset %d", i);
// Create a dataset in the file
DataSet dataset = file.createDataSet(name, datatype, filespace);
diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp
index b371518..7a7b854 100644
--- a/c++/test/tvlstr.cpp
+++ b/c++/test/tvlstr.cpp
@@ -911,32 +911,32 @@ test_vl_rewrite()
int i;
char name[256]; // Buffer for names & data
for (i = 0; i < REWRITE_NDATASETS; i++) {
- sprintf(name, "/set_%d", i);
+ snprintf(name, sizeof(name), "/set_%d", i);
write_scalar_dset(file1, type, space, name, name);
}
// Effectively copy data from file 1 to 2.
for (i = 0; i < REWRITE_NDATASETS; i++) {
- sprintf(name, "/set_%d", i);
+ snprintf(name, sizeof(name), "/set_%d", i);
read_scalar_dset(file1, type, space, name, name);
write_scalar_dset(file2, type, space, name, name);
}
// Read back from file 2.
for (i = 0; i < REWRITE_NDATASETS; i++) {
- sprintf(name, "/set_%d", i);
+ snprintf(name, sizeof(name), "/set_%d", i);
read_scalar_dset(file2, type, space, name, name);
}
// Remove from file 2.
for (i = 0; i < REWRITE_NDATASETS; i++) {
- sprintf(name, "/set_%d", i);
+ snprintf(name, sizeof(name), "/set_%d", i);
file2.unlink(name);
}
// Effectively copy from file 1 to file 2.
for (i = 0; i < REWRITE_NDATASETS; i++) {
- sprintf(name, "/set_%d", i);
+ snprintf(name, sizeof(name), "/set_%d", i);
read_scalar_dset(file1, type, space, name, name);
write_scalar_dset(file2, type, space, name, name);
}