8299378: sprintf is deprecated in Xcode 14
Reviewed-by: kbarrett, dholmes
This commit is contained in:
parent
ea25a561c5
commit
38cfc59172
@ -174,7 +174,7 @@ TEST(LogDecorators, combine_with) {
|
||||
|
||||
// Select first and third decorator for dec1
|
||||
char input[64];
|
||||
sprintf(input, "%s,%s", decorator_name_array[0], decorator_name_array[3]);
|
||||
os::snprintf_checked(input, sizeof(input), "%s,%s", decorator_name_array[0], decorator_name_array[3]);
|
||||
dec1.parse(input);
|
||||
EXPECT_TRUE(dec1.is_decorator(decorator_array[0]));
|
||||
EXPECT_TRUE(dec1.is_decorator(decorator_array[3]));
|
||||
|
@ -146,11 +146,12 @@ TEST_VM_F(LogMessageTest, long_message) {
|
||||
char* data = NEW_C_HEAP_ARRAY(char, size, mtLogging);
|
||||
|
||||
// fill buffer with start_marker...some data...end_marker
|
||||
sprintf(data, "%s", start_marker);
|
||||
os::snprintf_checked(data, size, "%s", start_marker);
|
||||
for (size_t i = strlen(start_marker); i < size; i++) {
|
||||
data[i] = '0' + (i % 10);
|
||||
}
|
||||
sprintf(data + size - strlen(end_marker) - 1, "%s", end_marker);
|
||||
size_t remaining_size = strlen(end_marker) + 1;
|
||||
os::snprintf_checked(data + size - remaining_size, remaining_size, "%s", end_marker);
|
||||
|
||||
msg.trace("%s", data); // Adds a newline, making the message exactly 10K in length.
|
||||
_log.write(msg);
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
#include "utilities/unsigned5.hpp"
|
||||
#include "unittest.hpp"
|
||||
|
||||
@ -251,7 +252,7 @@ TEST_VM(unsigned5, reader) {
|
||||
printer.print_on(&st, 4, "(", ")");
|
||||
std::string st_s(st.base(), st.size());
|
||||
char buf2[sizeof(stbuf)];
|
||||
sprintf(buf2, "(%d %d %d %d)", ints[0], ints[1], ints[2], ints[3]);
|
||||
os::snprintf_checked(buf2, sizeof(buf2), "(%d %d %d %d)", ints[0], ints[1], ints[2], ints[3]);
|
||||
std::string exp_s(buf2, strlen(buf2));
|
||||
ASSERT_EQ(exp_s, st_s);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user