Skip to content

Commit 504d517

Browse files
committed
8281525: Enable Zc:strictStrings flag in Visual Studio build
Backport-of: 23995f822e540d799eb4bbc969229422257fbb08
1 parent 471239e commit 504d517

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

make/autoconf/flags-cflags.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,8 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
544544
TOOLCHAIN_CFLAGS_JVM="-qtbtable=full -qtune=balanced \
545545
-qalias=noansi -qstrict -qtls=default -qnortti -qnoeh -qignerrno -qstackprotect"
546546
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
547-
TOOLCHAIN_CFLAGS_JVM="-nologo -MD -MP"
548-
TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:wchar_t-"
547+
TOOLCHAIN_CFLAGS_JVM="-nologo -MD -Zc:strictStrings -MP"
548+
TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:strictStrings -Zc:wchar_t-"
549549
fi
550550
551551
# CFLAGS C language level for JDK sources (hotspot only uses C++)

src/hotspot/os/windows/os_windows.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4547,7 +4547,7 @@ static errno_t get_full_path(LPCWSTR unicode_path, LPWSTR* full_path) {
45474547
return ERROR_SUCCESS;
45484548
}
45494549

4550-
static void set_path_prefix(char* buf, LPWSTR* prefix, int* prefix_off, bool* needs_fullpath) {
4550+
static void set_path_prefix(char* buf, LPCWSTR* prefix, int* prefix_off, bool* needs_fullpath) {
45514551
*prefix_off = 0;
45524552
*needs_fullpath = true;
45534553

@@ -4583,7 +4583,7 @@ static wchar_t* wide_abs_unc_path(char const* path, errno_t & err, int additiona
45834583
strncpy(buf, path, buf_len);
45844584
os::native_path(buf);
45854585

4586-
LPWSTR prefix = NULL;
4586+
LPCWSTR prefix = NULL;
45874587
int prefix_off = 0;
45884588
bool needs_fullpath = true;
45894589
set_path_prefix(buf, &prefix, &prefix_off, &needs_fullpath);

src/java.security.jgss/windows/native/libsspi_bridge/sspi.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ seconds_until(int inputIsUTC, TimeStamp *time)
139139
}
140140

141141
static void
142-
show_time(char* label, TimeStamp* ts)
142+
show_time(const char* label, TimeStamp* ts)
143143
{
144144
if (trace) {
145145
SYSTEMTIME stLocal;
@@ -286,7 +286,7 @@ get_full_name(WCHAR* input)
286286
}
287287

288288
// Always use the default domain
289-
WCHAR* realm = _wgetenv(L"USERDNSDOMAIN");
289+
const WCHAR* realm = _wgetenv(L"USERDNSDOMAIN");
290290
if (realm == NULL) {
291291
realm = L"";
292292
}
@@ -653,7 +653,7 @@ gss_acquire_cred(OM_uint32 *minor_status,
653653
}
654654
ss = AcquireCredentialsHandle(
655655
NULL,
656-
L"Kerberos",
656+
(LPWSTR)L"Kerberos",
657657
cred_usage == 0 ? SECPKG_CRED_BOTH :
658658
(cred_usage == 1 ? SECPKG_CRED_OUTBOUND : SECPKG_CRED_INBOUND),
659659
NULL,
@@ -683,7 +683,7 @@ gss_acquire_cred(OM_uint32 *minor_status,
683683
auth.PackageListLength = 8;
684684
ss = AcquireCredentialsHandle(
685685
NULL,
686-
L"Negotiate",
686+
(LPWSTR)L"Negotiate",
687687
cred_usage == 0 ? SECPKG_CRED_BOTH :
688688
(cred_usage == 1 ? SECPKG_CRED_OUTBOUND : SECPKG_CRED_INBOUND),
689689
NULL,
@@ -945,7 +945,7 @@ gss_init_sec_context(OM_uint32 *minor_status,
945945
auth.PackageListLength = 8;
946946
ss = AcquireCredentialsHandle(
947947
NULL,
948-
isSPNEGO ? L"Negotiate" : L"Kerberos",
948+
(LPWSTR)(isSPNEGO ? L"Negotiate" : L"Kerberos"),
949949
SECPKG_CRED_OUTBOUND,
950950
NULL,
951951
isSPNEGO ? &auth : NULL,

src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ DEF_STATIC_JNI_OnLoad
8787

8888
void showProperty(NCRYPT_HANDLE hKey);
8989

90-
void dump(LPSTR title, PBYTE data, DWORD len)
90+
void dump(LPCSTR title, PBYTE data, DWORD len)
9191
{
9292
if (trace) {
9393
printf("==== %s ====\n", title);
@@ -572,7 +572,7 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_CKeyStore_loadKeysOrCertificateC
572572
// Build certificate chain by using system certificate store.
573573
// Add cert chain into collection for any key usage.
574574
//
575-
if (GetCertificateChain(OID_EKU_ANY, pCertContext, &pCertChainContext))
575+
if (GetCertificateChain((LPSTR)OID_EKU_ANY, pCertContext, &pCertChainContext))
576576
{
577577
for (DWORD i = 0; i < pCertChainContext->cChain; i++)
578578
{
@@ -1310,7 +1310,7 @@ void showProperty(NCRYPT_HANDLE hKey) {
13101310
BCryptBuffer bb;
13111311
bb.BufferType = NCRYPTBUFFER_PKCS_SECRET;
13121312
bb.cbBuffer = 18;
1313-
bb.pvBuffer = L"changeit";
1313+
bb.pvBuffer = (LPWSTR)L"changeit";
13141314
BCryptBufferDesc bbd;
13151315
bbd.ulVersion = 0;
13161316
bbd.cBuffers = 1;

src/jdk.jpackage/windows/native/libwixhelper/libwixhelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extern "C" {
5959
DWORD cchSize = 0;
6060

6161
UINT result = MsiGetProperty(hInstall, TEXT("INSTALLDIR"),
62-
TEXT(""), &cchSize);
62+
(LPTSTR)TEXT(""), &cchSize);
6363
if (result == ERROR_MORE_DATA) {
6464
cchSize = cchSize + 1; // NULL termination
6565
szValue = new TCHAR[cchSize];

test/hotspot/gtest/runtime/test_os_windows.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static void delete_rel_file_w(const wchar_t* path) {
177177
EXPECT_TRUE(result) << "Failed to delete file \"" << path << "\": " << GetLastError();
178178
}
179179

180-
static bool convert_to_cstring(char* c_str, size_t size, wchar_t* w_str) {
180+
static bool convert_to_cstring(char* c_str, size_t size, const wchar_t* w_str) {
181181
size_t converted;
182182
errno_t err = wcstombs_s(&converted, c_str, size, w_str, size - 1);
183183
EXPECT_EQ(err, ERROR_SUCCESS) << "Could not convert \"" << w_str << "\" to c-string";
@@ -307,7 +307,7 @@ static void check_file_impl(wchar_t* path) {
307307
}
308308
}
309309

310-
static void check_file_not_present_impl(wchar_t* path) {
310+
static void check_file_not_present_impl(const wchar_t* path) {
311311
char buf[JVM_MAXPATHLEN];
312312

313313
if (convert_to_cstring(buf, JVM_MAXPATHLEN, path)) {
@@ -361,7 +361,7 @@ static void check_file(wchar_t* path) {
361361
}
362362
}
363363

364-
static void check_file_not_present(wchar_t* path) {
364+
static void check_file_not_present(const wchar_t* path) {
365365
check_file_not_present_impl(path);
366366

367367
for (int i = 0; mods_filter != Allow_None && i < mods_per_path; ++i) {
@@ -455,7 +455,7 @@ static void bench_path(wchar_t* path) {
455455
}
456456
}
457457

458-
static void print_attr_result_for_path(wchar_t* path) {
458+
static void print_attr_result_for_path(const wchar_t* path) {
459459
WIN32_FILE_ATTRIBUTE_DATA file_data;
460460
struct stat st;
461461
char buf[JVM_MAXPATHLEN];
@@ -476,7 +476,7 @@ static void print_attr_result_for_path(wchar_t* path) {
476476
}
477477
}
478478

479-
static void print_attr_result(wchar_t* format, ...) {
479+
static void print_attr_result(const wchar_t* format, ...) {
480480
va_list argptr;
481481
wchar_t buf[JVM_MAXPATHLEN];
482482

@@ -513,10 +513,10 @@ TEST_VM(os_windows, handle_long_paths) {
513513
static wchar_t root_dir_path[JVM_MAXPATHLEN];
514514
static wchar_t root_rel_dir_path[JVM_MAXPATHLEN];
515515

516-
wchar_t* dir_prefix = L"os_windows_long_paths_dir_";
517-
wchar_t* empty_dir_name = L"empty_directory_with_long_path";
518-
wchar_t* not_empty_dir_name = L"not_empty_directory_with_long_path";
519-
wchar_t* file_name = L"file";
516+
const wchar_t* dir_prefix = L"os_windows_long_paths_dir_";
517+
const wchar_t* empty_dir_name = L"empty_directory_with_long_path";
518+
const wchar_t* not_empty_dir_name = L"not_empty_directory_with_long_path";
519+
const wchar_t* file_name = L"file";
520520
wchar_t dir_letter;
521521
WIN32_FILE_ATTRIBUTE_DATA file_data;
522522
bool can_test_unc = false;
@@ -683,7 +683,7 @@ TEST_VM(os_windows, handle_long_paths) {
683683
// The other drive letter should not overwrite the original one.
684684
if (dir_letter) {
685685
static wchar_t tmp[JVM_MAXPATHLEN];
686-
wchar_t* other_letter = dir_letter == L'D' ? L"C" : L"D";
686+
const wchar_t* other_letter = dir_letter == L'D' ? L"C" : L"D";
687687
wsprintfW(tmp, L"%2ls\\..\\%ls:%ls", nearly_long_file_path, other_letter, nearly_long_file_path + 2);
688688
check_file_not_present(tmp);
689689
wsprintfW(tmp, L"%2ls\\..\\%ls:%ls", file_path, other_letter, file_path + 2);

0 commit comments

Comments
 (0)