From 2cba90fecac266f90d26a3f7bf5602761f4028df Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Thu, 15 Feb 2024 02:59:32 +0300 Subject: json: use snprintf Brew clang complains about deprecated sprintf. Change-Id: I814b2ba4bf37616ff98aeef81efd6965ee680073 Reviewed-by: Christian Kandeler --- src/shared/json/json.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/json/json.cpp b/src/shared/json/json.cpp index 7ab85cba5..0ea6e8fd0 100644 --- a/src/shared/json/json.cpp +++ b/src/shared/json/json.cpp @@ -3757,7 +3757,7 @@ static void valueToJson(const Base *b, const Value &v, std::string &json, int in // +2 to format to ensure the expected precision const int n = std::numeric_limits::digits10 + 2; char buf[30] = {0}; - std::sprintf(buf, "%.*g", n, d); + std::snprintf(buf, sizeof(buf), "%.*g", n, d); // Hack: if (buf[0] == '-' && buf[1] == '0' && buf[2] == '\0') json += "0"; -- cgit v1.2.3