Skip to content

8299378: sprintf is deprecated in Xcode 14 #2661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/hotspot/gtest/logging/test_logDecorators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "jvm.h"
#include "logging/logDecorators.hpp"
#include "runtime/os.hpp"
#include "unittest.hpp"

static LogDecorators::Decorator decorator_array[] = {
Expand Down Expand Up @@ -173,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]));
Expand Down
5 changes: 3 additions & 2 deletions test/hotspot/gtest/logging/test_logMessageTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down