Skip to content

Commit fa8ea6b

Browse files
author
Alex Menkov
committed
8374168: Resolve disabled warnings in JDWP agent
Reviewed-by: cjplummer, sspitsyn, erikj
1 parent 5fd095f commit fa8ea6b

File tree

11 files changed

+32
-46
lines changed

11 files changed

+32
-46
lines changed

make/modules/jdk.jdwp.agent/Lib.gmk

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,6 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJDWP, \
5454
NAME := jdwp, \
5555
OPTIMIZATION := LOW, \
5656
CFLAGS := -DJDWP_LOGGING $(ICONV_CFLAGS), \
57-
DISABLED_WARNINGS_gcc_eventFilter.c := unused-variable, \
58-
DISABLED_WARNINGS_gcc_SDE.c := unused-function, \
59-
DISABLED_WARNINGS_gcc_threadControl.c := unused-but-set-variable \
60-
unused-variable, \
61-
DISABLED_WARNINGS_gcc_utf_util.c := unused-but-set-variable, \
62-
DISABLED_WARNINGS_clang_error_messages.c := format-nonliteral, \
63-
DISABLED_WARNINGS_clang_eventFilter.c := unused-variable, \
64-
DISABLED_WARNINGS_clang_EventRequestImpl.c := self-assign, \
65-
DISABLED_WARNINGS_clang_inStream.c := sometimes-uninitialized, \
66-
DISABLED_WARNINGS_clang_log_messages.c := format-nonliteral, \
67-
DISABLED_WARNINGS_clang_SDE.c := unused-function, \
68-
DISABLED_WARNINGS_clang_threadControl.c := unused-but-set-variable \
69-
unused-variable, \
70-
DISABLED_WARNINGS_clang_utf_util.c := unused-but-set-variable, \
71-
DISABLED_WARNINGS_microsoft_debugInit.c := 5287, \
7257
LDFLAGS := $(ICONV_LDFLAGS), \
7358
EXTRA_HEADER_DIRS := \
7459
include \

src/jdk.jdwp.agent/share/native/libjdwp/EventRequestImpl.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -84,12 +84,10 @@ readAndSetFilters(JNIEnv *env, PacketInputStream *in, HandlerNode *node,
8484
}
8585

8686
case JDWP_REQUEST_MODIFIER(LocationOnly): {
87-
jbyte tag;
8887
jclass clazz;
8988
jmethodID method;
9089
jlocation location;
91-
tag = inStream_readByte(in); /* not currently used */
92-
tag = tag; /* To shut up lint */
90+
(void)inStream_readByte(in); /* not currently used */
9391
if ( (serror = inStream_error(in)) != JDWP_ERROR(NONE) )
9492
break;
9593
clazz = inStream_readClassRef(env, in);

src/jdk.jdwp.agent/share/native/libjdwp/SDE.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -718,19 +718,6 @@ private jboolean isValid(void);
718718
lineTable[lti].jplsLineInc));
719719
}
720720

721-
private int fileTableIndex(int sti, int fileId) {
722-
int i;
723-
int fileIndexStart = stratumTable[sti].fileIndex;
724-
/* one past end */
725-
int fileIndexEnd = stratumTable[sti+1].fileIndex;
726-
for (i = fileIndexStart; i < fileIndexEnd; ++i) {
727-
if (fileTable[i].fileId == fileId) {
728-
return i;
729-
}
730-
}
731-
return -1;
732-
}
733-
734721
private jboolean isValid(void) {
735722
return sourceMapIsValid;
736723
}

src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ DEF_Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
181181
vmInitialized = JNI_FALSE;
182182
gdata->vmDead = JNI_FALSE;
183183

184-
jvmtiCompileTimeMajorVersion = ( JVMTI_VERSION & JVMTI_VERSION_MASK_MAJOR )
184+
jvmtiCompileTimeMajorVersion = ((unsigned)JVMTI_VERSION & JVMTI_VERSION_MASK_MAJOR)
185185
>> JVMTI_VERSION_SHIFT_MAJOR;
186-
jvmtiCompileTimeMinorVersion = ( JVMTI_VERSION & JVMTI_VERSION_MASK_MINOR )
186+
jvmtiCompileTimeMinorVersion = ((unsigned)JVMTI_VERSION & JVMTI_VERSION_MASK_MINOR)
187187
>> JVMTI_VERSION_SHIFT_MINOR;
188-
jvmtiCompileTimeMicroVersion = ( JVMTI_VERSION & JVMTI_VERSION_MASK_MICRO )
188+
jvmtiCompileTimeMicroVersion = ((unsigned)JVMTI_VERSION & JVMTI_VERSION_MASK_MICRO)
189189
>> JVMTI_VERSION_SHIFT_MICRO;
190190

191191
/* Get the JVMTI Env, IMPORTANT: Do this first! For jvmtiAllocate(). */

src/jdk.jdwp.agent/share/native/libjdwp/error_messages.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -61,6 +61,8 @@
6161
* NOTE: This function is at the lowest level of the call tree.
6262
* Do not use the ERROR* macros here.
6363
*/
64+
65+
ATTRIBUTE_PRINTF(4, 0)
6466
static void
6567
vprint_message(FILE *fp, const char *prefix, const char *suffix,
6668
const char *format, va_list ap)
@@ -84,6 +86,7 @@ vprint_message(FILE *fp, const char *prefix, const char *suffix,
8486
* NOTE: This function is at the lowest level of the call tree.
8587
* Do not use the ERROR* macros here.
8688
*/
89+
ATTRIBUTE_PRINTF(4, 5)
8790
void
8891
print_message(FILE *fp, const char *prefix, const char *suffix,
8992
const char *format, ...)
@@ -96,6 +99,7 @@ print_message(FILE *fp, const char *prefix, const char *suffix,
9699
}
97100

98101
/* Generate error message */
102+
ATTRIBUTE_PRINTF(1, 2)
99103
void
100104
error_message(const char *format, ...)
101105
{
@@ -110,6 +114,7 @@ error_message(const char *format, ...)
110114
}
111115

112116
/* Print plain message to stdout. */
117+
ATTRIBUTE_PRINTF(1, 2)
113118
void
114119
tty_message(const char *format, ...)
115120
{

src/jdk.jdwp.agent/share/native/libjdwp/eventFilter.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -976,7 +976,6 @@ eventFilter_setSourceNameMatchFilter(HandlerNode *node,
976976

977977
jvmtiError eventFilter_setPlatformThreadsOnlyFilter(HandlerNode *node, jint index)
978978
{
979-
PlatformThreadsFilter *filter = &FILTER(node, index).u.PlatformThreadsOnly;
980979
if (index >= FILTER_COUNT(node)) {
981980
return AGENT_ERROR_ILLEGAL_ARGUMENT;
982981
}

src/jdk.jdwp.agent/share/native/libjdwp/inStream.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -470,6 +470,7 @@ inStream_readValue(PacketInputStream *stream)
470470
break;
471471
default:
472472
stream->error = JDWP_ERROR(INVALID_TAG);
473+
value.j = 0L; // to make compiler happy
473474
break;
474475
}
475476
}

src/jdk.jdwp.agent/share/native/libjdwp/log_messages.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -155,6 +155,7 @@ standard_logging_format(FILE *fp,
155155
}
156156

157157
/* End a log entry */
158+
ATTRIBUTE_PRINTF(1, 2)
158159
void
159160
log_message_end(const char *format, ...)
160161
{

src/jdk.jdwp.agent/share/native/libjdwp/threadControl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2667,12 +2667,16 @@ threadControl_setEventMode(jvmtiEventMode mode, EventIndex ei, jthread thread)
26672667

26682668
/*
26692669
* Returns the current thread.
2670+
* Returns NULL on error (JVMTI_ERROR_WRONG_PHASE, JVMTI_ERROR_UNATTACHED_THREAD).
26702671
*/
26712672
jthread
26722673
threadControl_currentThread(void)
26732674
{
26742675
jthread thread = NULL;
26752676
jvmtiError error = JVMTI_FUNC_PTR(gdata->jvmti,GetCurrentThread)(gdata->jvmti, &thread);
2677+
if (error != JVMTI_ERROR_NONE) {
2678+
return NULL;
2679+
}
26762680
return thread;
26772681
}
26782682

@@ -2700,11 +2704,9 @@ threadControl_getFrameGeneration(jthread thread)
27002704
jthread *
27012705
threadControl_allVThreads(jint *numVThreads)
27022706
{
2703-
JNIEnv *env;
27042707
ThreadNode *node;
27052708
jthread* vthreads;
27062709

2707-
env = getEnv();
27082710
debugMonitorEnter(threadLock);
27092711
*numVThreads = numRunningVThreads;
27102712

src/jdk.jdwp.agent/share/native/libjdwp/utf_util.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -173,7 +173,7 @@ int JNICALL utf8mToUtf8sLength(jbyte *string, int length) {
173173

174174
newLength = 0;
175175
for ( i = 0 ; i < length ; i++ ) {
176-
unsigned byte1, byte2, byte3, byte4, byte5, byte6;
176+
unsigned byte1, byte2, byte4, byte5, byte6;
177177

178178
byte1 = (unsigned char)string[i];
179179
if ( (byte1 & 0x80) == 0 ) { /* 1byte encoding */
@@ -196,7 +196,7 @@ int JNICALL utf8mToUtf8sLength(jbyte *string, int length) {
196196
break; /* Error condition */
197197
}
198198
byte2 = (unsigned char)string[++i];
199-
byte3 = (unsigned char)string[++i];
199+
++i; // byte3 is not used
200200
newLength += 3;
201201
/* Possible process a second 3byte encoding */
202202
if ( (i+3) < length && byte1 == 0xED && (byte2 & 0xF0) == 0xA0 ) {

0 commit comments

Comments
 (0)