From 5a7af5bb7779e3fcd4a325d9b41affcdf3d6f209 Mon Sep 17 00:00:00 2001 From: Chenna Keshava B S <21219765+ckeshava@users.noreply.github.com> Date: Mon, 15 Jan 2024 22:32:52 -0800 Subject: [PATCH] fix: clang warning about deprecated sprintf usage (#4747) Resolves a warning that was emitted from the clang compiler. Switches usage of the sprintf function to the recommended snprintf function. Warning was observed in Apple clang version 15.0.0 (clang-1500.0.40.1). Fix #4569 --- src/ripple/json/impl/json_reader.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ripple/json/impl/json_reader.cpp b/src/ripple/json/impl/json_reader.cpp index e4124e9bc8f..299accd84a8 100644 --- a/src/ripple/json/impl/json_reader.cpp +++ b/src/ripple/json/impl/json_reader.cpp @@ -922,10 +922,8 @@ Reader::getLocationLineAndColumn(Location location) const { int line, column; getLocationLineAndColumn(location, line, column); - constexpr std::size_t n = 18 + 16 + 16 + 1; - char buffer[n]; - snprintf(buffer, n, "Line %d, Column %d", line, column); - return buffer; + return "Line " + std::to_string(line) + ", Column " + + std::to_string(column); } std::string