8336289: Obliterate most references to _snprintf in the Windows JDK
Reviewed-by: kbarrett, dholmes, jpai, mullan, djelinski, prr
This commit is contained in:
parent
78f53efcd6
commit
cd9e241f0e
@ -318,7 +318,7 @@ void Win32AttachOperation::complete(jint result, bufferedStream* result_stream)
|
|||||||
BOOL fSuccess;
|
BOOL fSuccess;
|
||||||
|
|
||||||
char msg[32];
|
char msg[32];
|
||||||
_snprintf(msg, sizeof(msg), "%d\n", result);
|
os::snprintf(msg, sizeof(msg), "%d\n", result);
|
||||||
msg[sizeof(msg) - 1] = '\0';
|
msg[sizeof(msg) - 1] = '\0';
|
||||||
|
|
||||||
fSuccess = write_pipe(hPipe, msg, (int)strlen(msg));
|
fSuccess = write_pipe(hPipe, msg, (int)strlen(msg));
|
||||||
|
@ -1776,14 +1776,14 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lib_arch_str != nullptr) {
|
if (lib_arch_str != nullptr) {
|
||||||
::_snprintf(ebuf, ebuflen - 1,
|
os::snprintf(ebuf, ebuflen - 1,
|
||||||
"Can't load %s-bit .dll on a %s-bit platform",
|
"Can't load %s-bit .dll on a %s-bit platform",
|
||||||
lib_arch_str, running_arch_str);
|
lib_arch_str, running_arch_str);
|
||||||
} else {
|
} else {
|
||||||
// don't know what architecture this dll was build for
|
// don't know what architecture this dll was build for
|
||||||
::_snprintf(ebuf, ebuflen - 1,
|
os::snprintf(ebuf, ebuflen - 1,
|
||||||
"Can't load this .dll (machine code=0x%x) on a %s-bit platform",
|
"Can't load this .dll (machine code=0x%x) on a %s-bit platform",
|
||||||
lib_arch, running_arch_str);
|
lib_arch, running_arch_str);
|
||||||
}
|
}
|
||||||
JFR_ONLY(load_event.set_error_msg(ebuf);)
|
JFR_ONLY(load_event.set_error_msg(ebuf);)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -165,7 +165,7 @@ static char* get_user_tmp_dir(const char* user) {
|
|||||||
char* dirname = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
|
char* dirname = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
|
||||||
|
|
||||||
// construct the path name to user specific tmp directory
|
// construct the path name to user specific tmp directory
|
||||||
_snprintf(dirname, nbytes, "%s\\%s_%s", tmpdir, perfdir, user);
|
os::snprintf(dirname, nbytes, "%s\\%s_%s", tmpdir, perfdir, user);
|
||||||
|
|
||||||
return dirname;
|
return dirname;
|
||||||
}
|
}
|
||||||
@ -455,7 +455,7 @@ static char *get_sharedmem_objectname(const char* user, int vmid) {
|
|||||||
//
|
//
|
||||||
nbytes += UINT_CHARS;
|
nbytes += UINT_CHARS;
|
||||||
char* name = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
|
char* name = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
|
||||||
_snprintf(name, nbytes, "%s_%s_%u", PERFDATA_NAME, user, vmid);
|
os::snprintf(name, nbytes, "%s_%s_%u", PERFDATA_NAME, user, vmid);
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -471,7 +471,7 @@ static char* get_sharedmem_filename(const char* dirname, int vmid) {
|
|||||||
size_t nbytes = strlen(dirname) + UINT_CHARS + 2;
|
size_t nbytes = strlen(dirname) + UINT_CHARS + 2;
|
||||||
|
|
||||||
char* name = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
|
char* name = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
|
||||||
_snprintf(name, nbytes, "%s\\%d", dirname, vmid);
|
os::snprintf(name, nbytes, "%s\\%d", dirname, vmid);
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -328,7 +328,7 @@ public:
|
|||||||
printf("*** cannot allocate memory\n");
|
printf("*** cannot allocate memory\n");
|
||||||
doabort();
|
doabort();
|
||||||
}
|
}
|
||||||
_snprintf(cptr, MAX_PATH, "\"%s\" %s", argv[0], cmdline);
|
snprintf(cptr, MAX_PATH, "\"%s\" %s", argv[0], cmdline);
|
||||||
JLI_CmdToArgs(cptr);
|
JLI_CmdToArgs(cptr);
|
||||||
free(cptr);
|
free(cptr);
|
||||||
StdArg *kargv = JLI_GetStdArgs();
|
StdArg *kargv = JLI_GetStdArgs();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -26,11 +26,6 @@
|
|||||||
#include "splashscreen_impl.h"
|
#include "splashscreen_impl.h"
|
||||||
#include "splashscreen_gfx_impl.h"
|
#include "splashscreen_gfx_impl.h"
|
||||||
#define BUFF_SIZE 1024
|
#define BUFF_SIZE 1024
|
||||||
#ifdef _MSC_VER
|
|
||||||
# ifndef snprintf
|
|
||||||
# define snprintf _snprintf
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
int splashIsVisible = 0;
|
int splashIsVisible = 0;
|
||||||
|
|
||||||
Splash *
|
Splash *
|
||||||
|
@ -141,7 +141,7 @@ void AwtDebugSupport::AssertCallback(const char * expr, const char * file, int l
|
|||||||
msgBuffer = (LPSTR)"<Could not get GetLastError() message text>";
|
msgBuffer = (LPSTR)"<Could not get GetLastError() message text>";
|
||||||
}
|
}
|
||||||
// format the assertion message
|
// format the assertion message
|
||||||
_snprintf(assertMsg, ASSERT_MSG_SIZE, AssertFmt, expr, file, line, lastError, msgBuffer);
|
snprintf(assertMsg, ASSERT_MSG_SIZE, AssertFmt, expr, file, line, lastError, msgBuffer);
|
||||||
if (fret != 0) {
|
if (fret != 0) {
|
||||||
LocalFree(msgBuffer);
|
LocalFree(msgBuffer);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -1526,8 +1526,8 @@ BOOL UpdateMessageNumber () {
|
|||||||
size_t messageNumber = g_MessageHistory.GetCurrentMessageIndex() + 1;
|
size_t messageNumber = g_MessageHistory.GetCurrentMessageIndex() + 1;
|
||||||
char text [32] = {0};
|
char text [32] = {0};
|
||||||
if ( 0 != messageCount ) {
|
if ( 0 != messageCount ) {
|
||||||
::_snprintf(text, sizeof(text), "%d of %d", (int)messageNumber,
|
::snprintf(text, sizeof(text), "%d of %d", (int)messageNumber,
|
||||||
(int) messageCount);
|
(int) messageCount);
|
||||||
}
|
}
|
||||||
return ::SetWindowText(dlgItem, text);
|
return ::SetWindowText(dlgItem, text);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -39,7 +39,7 @@ void *p11FindFunction(JNIEnv *env, jlong jHandle, const char *functionName) {
|
|||||||
void *fAddress = GetProcAddress(hModule, functionName);
|
void *fAddress = GetProcAddress(hModule, functionName);
|
||||||
if (fAddress == NULL) {
|
if (fAddress == NULL) {
|
||||||
char errorMessage[256];
|
char errorMessage[256];
|
||||||
_snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName);
|
snprintf(errorMessage, sizeof(errorMessage), "Symbol not found: %s", functionName);
|
||||||
p11ThrowNullPointerException(env, errorMessage);
|
p11ThrowNullPointerException(env, errorMessage);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -33,12 +33,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
// Disable CRT security warning against _snprintf
|
|
||||||
#pragma warning (disable : 4996)
|
|
||||||
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#define vsnprintf _vsnprintf
|
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -56,7 +56,7 @@ static void dll_build_name(char* buffer, size_t buflen,
|
|||||||
path = strtok_s(paths_copy, PATH_SEPARATOR, &next_token);
|
path = strtok_s(paths_copy, PATH_SEPARATOR, &next_token);
|
||||||
|
|
||||||
while (path != NULL) {
|
while (path != NULL) {
|
||||||
size_t result_len = (size_t)_snprintf(buffer, buflen, "%s\\%s.dll", path, fname);
|
size_t result_len = (size_t) snprintf(buffer, buflen, "%s\\%s.dll", path, fname);
|
||||||
if (result_len >= buflen) {
|
if (result_len >= buflen) {
|
||||||
EXIT_ERROR(JVMTI_ERROR_INVALID_LOCATION, "One or more of the library paths supplied to jdwp, "
|
EXIT_ERROR(JVMTI_ERROR_INVALID_LOCATION, "One or more of the library paths supplied to jdwp, "
|
||||||
"likely by sun.boot.library.path, is too long.");
|
"likely by sun.boot.library.path, is too long.");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -34,11 +34,6 @@ typedef unsigned long UNSIGNED_JINT;
|
|||||||
|
|
||||||
#define MAXPATHLEN _MAX_PATH
|
#define MAXPATHLEN _MAX_PATH
|
||||||
|
|
||||||
/* Needed on Windows because names seem to be hidden in stdio.h. */
|
|
||||||
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#define vsnprintf _vsnprintf
|
|
||||||
|
|
||||||
/* On little endian machines, convert java big endian numbers. */
|
/* On little endian machines, convert java big endian numbers. */
|
||||||
|
|
||||||
#define HOST_TO_JAVA_CHAR(x) (((x & 0xff) << 8) | ((x >> 8) & (0xff)))
|
#define HOST_TO_JAVA_CHAR(x) (((x & 0xff) << 8) | ((x >> 8) & (0xff)))
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -436,13 +436,13 @@ makeFullCounterPath(const char* const objectName,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
_snprintf(fullCounterPath,
|
snprintf(fullCounterPath,
|
||||||
fullCounterPathLen,
|
fullCounterPathLen,
|
||||||
PROCESS_OBJECT_INSTANCE_COUNTER_FMT,
|
PROCESS_OBJECT_INSTANCE_COUNTER_FMT,
|
||||||
objectName,
|
objectName,
|
||||||
imageName,
|
imageName,
|
||||||
instance,
|
instance,
|
||||||
counterName);
|
counterName);
|
||||||
} else {
|
} else {
|
||||||
if (instance) {
|
if (instance) {
|
||||||
/*
|
/*
|
||||||
@ -472,18 +472,18 @@ makeFullCounterPath(const char* const objectName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (instance) {
|
if (instance) {
|
||||||
_snprintf(fullCounterPath,
|
snprintf(fullCounterPath,
|
||||||
fullCounterPathLen,
|
fullCounterPathLen,
|
||||||
OBJECT_WITH_INSTANCES_COUNTER_FMT,
|
OBJECT_WITH_INSTANCES_COUNTER_FMT,
|
||||||
objectName,
|
objectName,
|
||||||
instance,
|
instance,
|
||||||
counterName);
|
counterName);
|
||||||
} else {
|
} else {
|
||||||
_snprintf(fullCounterPath,
|
snprintf(fullCounterPath,
|
||||||
fullCounterPathLen,
|
fullCounterPathLen,
|
||||||
OBJECT_COUNTER_FMT,
|
OBJECT_COUNTER_FMT,
|
||||||
objectName,
|
objectName,
|
||||||
counterName);
|
counterName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,10 +719,10 @@ currentQueryIndexForProcess(void) {
|
|||||||
PDH_FMT_COUNTERVALUE counterValue;
|
PDH_FMT_COUNTERVALUE counterValue;
|
||||||
PDH_STATUS res;
|
PDH_STATUS res;
|
||||||
|
|
||||||
_snprintf(fullIDProcessCounterPath,
|
snprintf(fullIDProcessCounterPath,
|
||||||
MAX_PATH,
|
MAX_PATH,
|
||||||
pdhIDProcessCounterFmt,
|
pdhIDProcessCounterFmt,
|
||||||
index);
|
index);
|
||||||
|
|
||||||
if (addCounter(tmpQuery, fullIDProcessCounterPath, &handleCounter) != 0) {
|
if (addCounter(tmpQuery, fullIDProcessCounterPath, &handleCounter) != 0) {
|
||||||
break;
|
break;
|
||||||
@ -1059,13 +1059,13 @@ allocateAndInitializePdhConstants() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* "\Process(java#%d)\ID Process" */
|
/* "\Process(java#%d)\ID Process" */
|
||||||
_snprintf(pdhIDProcessCounterFmt,
|
snprintf(pdhIDProcessCounterFmt,
|
||||||
pdhIDProcessCounterFmtLen,
|
pdhIDProcessCounterFmtLen,
|
||||||
PROCESS_OBJECT_INSTANCE_COUNTER_FMT,
|
PROCESS_OBJECT_INSTANCE_COUNTER_FMT,
|
||||||
pdhLocalizedProcessObject,
|
pdhLocalizedProcessObject,
|
||||||
pdhProcessImageName,
|
pdhProcessImageName,
|
||||||
"%d",
|
"%d",
|
||||||
pdhLocalizedIDProcessCounter);
|
pdhLocalizedIDProcessCounter);
|
||||||
|
|
||||||
pdhIDProcessCounterFmt[pdhIDProcessCounterFmtLen] = '\0';
|
pdhIDProcessCounterFmt[pdhIDProcessCounterFmtLen] = '\0';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user