Skip to content

8342868: Errors related to unused code on Windows after 8339120 in core libs #21654

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions src/java.base/share/native/libzip/zip_util.c
Copy link
Member

Choose a reason for hiding this comment

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

Not my area but this fix looks reasonable.

Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,9 @@ readCEN(jzfile *zip, jint knownTotal)
jlong offset;
#endif
unsigned char endbuf[ENDHDR];
#ifdef USE_MMAP
jint endhdrlen = ENDHDR;
#endif
jzcell *entries;
jint *table;

Expand All @@ -606,7 +608,9 @@ readCEN(jzfile *zip, jint knownTotal)
cenoff = ZIP64_ENDOFF(end64buf);
total = (jint)ZIP64_ENDTOT(end64buf);
endpos = end64pos;
#ifdef USE_MMAP
endhdrlen = ZIP64_ENDHDR;
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -965,8 +965,9 @@ void getNumberPart(const jchar * langtag, const jint numberStyle, WCHAR * number
void getFixPart(const jchar * langtag, const jint numberStyle, BOOL positive, BOOL prefix, WCHAR * ret) {
DWORD pattern = 0;
int style = numberStyle;
int got = 0;
// int got = 0;

/*
Copy link
Member

Choose a reason for hiding this comment

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

Don't understand this one at all - what did gcc actually complain about here? This code all seems used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The warning received is that got is set but not used - I had a look at getLocaleInfoWrapper and it seems like it has no side effects, its only purpose is to return a value, which is the variable got in this case. I'm pretty certain got not being used is a bug, and that it is needed somewhere, but someone forgot to hook it up to whatever needs it

Copy link
Member

Choose a reason for hiding this comment

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

It does seem a bug, where the return value is not handled correctly. Can you please file a separate bug?

Copy link
Member

@justin-curtis-lu justin-curtis-lu Oct 30, 2024

Choose a reason for hiding this comment

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

I had a look at getLocaleInfoWrapper and it seems like it has no side effects, its only purpose is to return a value

While got is not needed here, I am not convinced that getLocaleInfoWrapper is not used, so we shouldn't comment out all of the code, but rather just remove got. getLocaleInfoWrapper updates the outbound variable pattern (see https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getlocaleinfoex), which is used to get the right string pattern from fixes.

Usually, based on got, appropriate action is taken, but that's not needed in this case, because pattern is either updated or remains its fallback 0 value. So I presume that is why got is ignored in this case.

We could just add that got removal to this patch, what do you think @naotoj?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, Justin. That is correct. Only pattern is relevant here. No need to check got so it can safely be removed.

if (positive) {
if (style == sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_CURRENCY) {
got = getLocaleInfoWrapper(langtag,
Expand All @@ -992,6 +993,7 @@ void getFixPart(const jchar * langtag, const jint numberStyle, BOOL positive, BO
(LPWSTR)&pattern, sizeof(pattern));
}
}
*/

if (numberStyle == sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_INTEGER) {
style = sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_NUMBER;
Expand Down
6 changes: 3 additions & 3 deletions src/java.base/windows/native/libjava/TimeZone_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static int getWinTimeZone(char *winZoneName, size_t winZoneNameBufSize)
WCHAR stdNameInReg[MAX_ZONE_CHAR];
TziValue tempTzi;
WCHAR *stdNamePtr = tzi.StandardName;
int onlyMapID;
// int onlyMapID;
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this became unused with JDK-8209167, so deleting it seems fine to me.


timeType = GetTimeZoneInformation(&tzi);
if (timeType == TIME_ZONE_ID_INVALID) {
Expand Down Expand Up @@ -304,7 +304,7 @@ static int getWinTimeZone(char *winZoneName, size_t winZoneNameBufSize)
* Compare to the "Std" value of each subkey and find the entry that
* matches the current control panel setting.
*/
onlyMapID = 0;
// onlyMapID = 0;
for (i = 0; i < nSubKeys; ++i) {
DWORD size = sizeof(subKeyName);
ret = RegEnumKeyEx(hKey, i, subKeyName, &size, NULL, NULL, NULL, NULL);
Expand All @@ -325,7 +325,7 @@ static int getWinTimeZone(char *winZoneName, size_t winZoneNameBufSize)
* entry in the Time Zones registry.
*/
RegCloseKey(hSubKey);
onlyMapID = 1;
// onlyMapID = 1;
ret = RegOpenKeyExW(hKey, stdNamePtr, 0, KEY_READ, (PHKEY)&hSubKey);
if (ret != ERROR_SUCCESS) {
goto err;
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/windows/native/libnet/NTLMAuthSequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static jfieldID ntlm_ctxHandleID;
static jfieldID ntlm_crdHandleID;
static jfieldID status_seqCompleteID;

static HINSTANCE lib = NULL;
// static HINSTANCE lib = NULL;
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this became unused with JDK-7030256, so removal seems fine.


JNIEXPORT void JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_initFirst
(JNIEnv *env, jclass authseq_clazz, jclass status_clazz)
Expand Down