diff --git a/src/factory/FieldCreateFactory.cpp b/src/factory/FieldCreateFactory.cpp index 6c5f9b0d..561e8ee4 100644 --- a/src/factory/FieldCreateFactory.cpp +++ b/src/factory/FieldCreateFactory.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -378,7 +379,8 @@ BoundedScalarArray::BoundedScalarArray(ScalarType elementType, size_t size) string BoundedScalarArray::getID() const { char buffer[32]; - sprintf(buffer, "%s<%zu>", ScalarTypeFunc::name(getElementType()), size); + epicsSnprintf(buffer, sizeof(buffer), "%s<%lu>", + ScalarTypeFunc::name(getElementType()), (unsigned long) size); return string(buffer); } @@ -403,7 +405,8 @@ FixedScalarArray::FixedScalarArray(ScalarType elementType, size_t size) string FixedScalarArray::getID() const { char buffer[32]; - sprintf(buffer, "%s[%zu]", ScalarTypeFunc::name(getElementType()), size); + epicsSnprintf(buffer, sizeof(buffer), "%s[%lu]", + ScalarTypeFunc::name(getElementType()), (unsigned long) size); return string(buffer); } diff --git a/testApp/pv/performstruct.cpp b/testApp/pv/performstruct.cpp index 7abf1a8b..0b78ac03 100644 --- a/testApp/pv/performstruct.cpp +++ b/testApp/pv/performstruct.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -54,7 +55,7 @@ void buildMiss() for(size_t i=0; i<1000; i++) { // unique name each time to (partially) defeat caching char buf[10]; - sprintf(buf, "field%zu", i); + epicsSnprintf(buf, sizeof(buf), "field%lu", (unsigned long) i); record.start();