Skip to content

Commit

Permalink
8299378: sprintf is deprecated in Xcode 14
Browse files Browse the repository at this point in the history
Reviewed-by: sgehwolf, andrew
Backport-of: 38cfc591725de478879266584280562f0ba4b42f
  • Loading branch information
gdams committed Jul 5, 2024
1 parent e191f94 commit 8d974ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

1 comment on commit 8d974ea

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.