[flang-commits] [flang] e8fcc47 - Replace sprintf by snprintf
Carlos Eduardo Seo via flang-commits
flang-commits at lists.llvm.org
Thu Jun 29 09:50:02 PDT 2023
Author: Carlos Eduardo Seo
Date: 2023-06-29T16:48:44Z
New Revision: e8fcc475580a3fc9927e76cffe5d8d8b368d6830
URL: https://github.com/llvm/llvm-project/commit/e8fcc475580a3fc9927e76cffe5d8d8b368d6830
DIFF: https://github.com/llvm/llvm-project/commit/e8fcc475580a3fc9927e76cffe5d8d8b368d6830.diff
LOG: Replace sprintf by snprintf
The macOS toolchain deprecated sprintf in favor of snprintf. This was blocking
the build on macOS. Replaced all instances of sprintf by snprintf.
Added:
Modified:
flang/unittests/Decimal/quick-sanity-test.cpp
flang/unittests/Decimal/thorough-test.cpp
Removed:
################################################################################
diff --git a/flang/unittests/Decimal/quick-sanity-test.cpp b/flang/unittests/Decimal/quick-sanity-test.cpp
index ef745df850d39b..74434c1b8f2bd5 100644
--- a/flang/unittests/Decimal/quick-sanity-test.cpp
+++ b/flang/unittests/Decimal/quick-sanity-test.cpp
@@ -53,7 +53,7 @@ void testReadback(float x, int flags) {
++expo;
}
if (q >= buffer && q < buffer + sizeof buffer) {
- std::sprintf(q + result.length, "e%d", expo);
+ std::snprintf(q + result.length, sizeof buffer, "e%d", expo);
}
const char *p{q};
auto rflags{ConvertDecimalToFloat(&p, &y, RoundNearest)};
diff --git a/flang/unittests/Decimal/thorough-test.cpp b/flang/unittests/Decimal/thorough-test.cpp
index f8416bffa71999..2261a1c3b03e97 100644
--- a/flang/unittests/Decimal/thorough-test.cpp
+++ b/flang/unittests/Decimal/thorough-test.cpp
@@ -51,7 +51,7 @@ void testReadback(float x, int flags) {
if (*q == '-' || *q == '+') {
++expo;
}
- std::sprintf(q + result.length, "e%d", expo);
+ std::snprintf(q + result.length, sizeof buffer, "e%d", expo);
}
const char *p{q};
auto rflags{ConvertDecimalToFloat(&p, &y, RoundNearest)};
More information about the flang-commits
mailing list