From 0c1773f25d0658ccc1473858e2e49069c198f808 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 19 Nov 2025 16:18:27 -0600 Subject: [PATCH] Clang warnings: sprintf() => epicsSnprintf() --- src/factory/FieldCreateFactory.cpp | 7 +++++-- testApp/pv/performstruct.cpp | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/factory/FieldCreateFactory.cpp b/src/factory/FieldCreateFactory.cpp index 6c5f9b0..561e8ee 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 7abf1a8..0b78ac0 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();