Bug Summary

File:jdk/src/java.management/share/native/libmanagement/VMManagementImpl.c
Warning:line 67, column 10
Value stored to 'ret' during its initialization is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name VMManagementImpl.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mthread-model posix -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base/linux -I /home/daniel/Projects/java/jdk/src/java.base/share/native/libjava -I /home/daniel/Projects/java/jdk/src/java.base/unix/native/libjava -I /home/daniel/Projects/java/jdk/src/hotspot/share/include -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix/include -D LIBC=gnu -D _GNU_SOURCE -D _REENTRANT -D _LARGEFILE64_SOURCE -D LINUX -D DEBUG -D _LITTLE_ENDIAN -D ARCH="amd64" -D amd64 -D _LP64=1 -I /home/daniel/Projects/java/jdk/src/java.management/share/native/libmanagement -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/headers/java.management -D _FORTIFY_SOURCE=2 -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-unused -std=c99 -fdebug-compilation-dir /home/daniel/Projects/java/jdk/make -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -stack-protector 1 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /home/daniel/Projects/java/scan/2021-12-21-193737-8510-1 -x c /home/daniel/Projects/java/jdk/src/java.management/share/native/libmanagement/VMManagementImpl.c
1/*
2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26#include <jni.h>
27#include <stdlib.h>
28#include "jvm.h"
29#include "management.h"
30#include "sun_management_VMManagementImpl.h"
31
32#define MAX_VERSION_LEN20 20
33
34JNIEXPORT__attribute__((visibility("default"))) jstring JNICALL
35Java_sun_management_VMManagementImpl_getVersion0
36 (JNIEnv *env, jclass dummy)
37{
38 char buf[MAX_VERSION_LEN20];
39 jstring version_string = NULL((void*)0);
40
41 unsigned int major = ((unsigned int) jmm_version & 0x0FFF0000) >> 16;
42 unsigned int minor = ((unsigned int) jmm_version & 0xFF00) >> 8;
43
44 // for internal use
45 unsigned int micro = (unsigned int) jmm_version & 0xFF;
46
47 sprintf(buf, "%d.%d", major, minor)__builtin___sprintf_chk (buf, 2 - 1, __builtin_object_size (buf
, 2 > 1), "%d.%d", major, minor)
;
48 version_string = (*env)->NewStringUTF(env, buf);
49 return version_string;
50}
51
52static void setStaticBooleanField
53 (JNIEnv* env, jclass cls, const char* name, jboolean value)
54{
55 jfieldID fid;
56 fid = (*env)->GetStaticFieldID(env, cls, name, "Z");
57 if (fid != 0) {
58 (*env)->SetStaticBooleanField(env, cls, fid, value);
59 }
60}
61
62JNIEXPORT__attribute__((visibility("default"))) void JNICALL
63Java_sun_management_VMManagementImpl_initOptionalSupportFields
64 (JNIEnv *env, jclass cls)
65{
66 jmmOptionalSupport mos;
67 jint ret = jmm_interface->GetOptionalSupport(env, &mos);
Value stored to 'ret' during its initialization is never read
68
69 jboolean value;
70
71 value = mos.isCompilationTimeMonitoringSupported;
72 setStaticBooleanField(env, cls, "compTimeMonitoringSupport", value);
73
74 value = mos.isThreadContentionMonitoringSupported;
75 setStaticBooleanField(env, cls, "threadContentionMonitoringSupport", value);
76
77 value = mos.isCurrentThreadCpuTimeSupported;
78 setStaticBooleanField(env, cls, "currentThreadCpuTimeSupport", value);
79
80 value = mos.isOtherThreadCpuTimeSupported;
81 setStaticBooleanField(env, cls, "otherThreadCpuTimeSupport", value);
82
83 if (jmm_version >= JMM_VERSION_1_1) {
84 value = mos.isObjectMonitorUsageSupported;
85 setStaticBooleanField(env, cls, "objectMonitorUsageSupport", value);
86
87 value = mos.isSynchronizerUsageSupported;
88 setStaticBooleanField(env, cls, "synchronizerUsageSupport", value);
89 } else {
90 setStaticBooleanField(env, cls, "objectMonitorUsageSupport", JNI_FALSE0);
91 setStaticBooleanField(env, cls, "synchronizerUsageSupport", JNI_FALSE0);
92 }
93
94 value = mos.isThreadAllocatedMemorySupported;
95 setStaticBooleanField(env, cls, "threadAllocatedMemorySupport", value);
96
97 value = mos.isRemoteDiagnosticCommandsSupported;
98 setStaticBooleanField(env, cls, "remoteDiagnosticCommandsSupport", value);
99}
100
101JNIEXPORT__attribute__((visibility("default"))) jobjectArray JNICALL
102Java_sun_management_VMManagementImpl_getVmArguments0
103 (JNIEnv *env, jobject dummy)
104{
105 return JVM_GetVmArguments(env);
106}
107
108JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
109Java_sun_management_VMManagementImpl_getTotalClassCount
110 (JNIEnv *env, jobject dummy)
111{
112 /* JMM_CLASS_LOADED_COUNT is the total number of classes loaded */
113 jlong count = jmm_interface->GetLongAttribute(env, NULL((void*)0),
114 JMM_CLASS_LOADED_COUNT);
115 return count;
116}
117
118JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
119Java_sun_management_VMManagementImpl_getUnloadedClassCount
120 (JNIEnv *env, jobject dummy)
121{
122 /* JMM_CLASS_UNLOADED_COUNT is the total number of classes unloaded */
123 jlong count = jmm_interface->GetLongAttribute(env, NULL((void*)0),
124 JMM_CLASS_UNLOADED_COUNT);
125 return count;
126}
127
128JNIEXPORT__attribute__((visibility("default"))) jboolean JNICALL
129Java_sun_management_VMManagementImpl_getVerboseGC
130 (JNIEnv *env, jobject dummy)
131{
132 return jmm_interface->GetBoolAttribute(env, JMM_VERBOSE_GC);
133}
134
135JNIEXPORT__attribute__((visibility("default"))) jboolean JNICALL
136Java_sun_management_VMManagementImpl_getVerboseClass
137 (JNIEnv *env, jobject dummy)
138{
139 return jmm_interface->GetBoolAttribute(env, JMM_VERBOSE_CLASS);
140}
141
142JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
143Java_sun_management_VMManagementImpl_getTotalThreadCount
144 (JNIEnv *env, jobject dummy)
145{
146 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
147 JMM_THREAD_TOTAL_COUNT);
148}
149
150JNIEXPORT__attribute__((visibility("default"))) jint JNICALL
151Java_sun_management_VMManagementImpl_getLiveThreadCount
152 (JNIEnv *env, jobject dummy)
153{
154 jlong count = jmm_interface->GetLongAttribute(env, NULL((void*)0),
155 JMM_THREAD_LIVE_COUNT);
156 return (jint) count;
157}
158
159JNIEXPORT__attribute__((visibility("default"))) jint JNICALL
160Java_sun_management_VMManagementImpl_getPeakThreadCount
161 (JNIEnv *env, jobject dummy)
162{
163 jlong count = jmm_interface->GetLongAttribute(env, NULL((void*)0),
164 JMM_THREAD_PEAK_COUNT);
165 return (jint) count;
166}
167
168JNIEXPORT__attribute__((visibility("default"))) jint JNICALL
169Java_sun_management_VMManagementImpl_getDaemonThreadCount
170 (JNIEnv *env, jobject dummy)
171{
172 jlong count = jmm_interface->GetLongAttribute(env, NULL((void*)0),
173 JMM_THREAD_DAEMON_COUNT);
174 return (jint) count;
175}
176
177JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
178Java_sun_management_VMManagementImpl_getTotalCompileTime
179 (JNIEnv *env, jobject dummy)
180{
181 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
182 JMM_COMPILE_TOTAL_TIME_MS);
183}
184
185JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
186Java_sun_management_VMManagementImpl_getStartupTime
187 (JNIEnv *env, jobject dummy)
188{
189 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
190 JMM_JVM_INIT_DONE_TIME_MS);
191}
192
193JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
194Java_sun_management_VMManagementImpl_getUptime0
195 (JNIEnv *env, jobject dummy)
196{
197 return jmm_interface->GetLongAttribute(env, NULL((void*)0), JMM_JVM_UPTIME_MS);
198}
199
200JNIEXPORT__attribute__((visibility("default"))) jboolean JNICALL
201Java_sun_management_VMManagementImpl_isThreadContentionMonitoringEnabled
202 (JNIEnv *env, jobject dummy)
203{
204 return jmm_interface->GetBoolAttribute(env,
205 JMM_THREAD_CONTENTION_MONITORING);
206}
207
208JNIEXPORT__attribute__((visibility("default"))) jboolean JNICALL
209Java_sun_management_VMManagementImpl_isThreadCpuTimeEnabled
210 (JNIEnv *env, jobject dummy)
211{
212 return jmm_interface->GetBoolAttribute(env, JMM_THREAD_CPU_TIME);
213}
214
215JNIEXPORT__attribute__((visibility("default"))) jboolean JNICALL
216Java_sun_management_VMManagementImpl_isThreadAllocatedMemoryEnabled
217 (JNIEnv *env, jobject dummy)
218{
219 return jmm_interface->GetBoolAttribute(env, JMM_THREAD_ALLOCATED_MEMORY);
220}
221
222JNIEXPORT__attribute__((visibility("default"))) jint JNICALL
223Java_sun_management_VMManagementImpl_getProcessId
224 (JNIEnv *env, jobject dummy)
225{
226 jlong pid = jmm_interface->GetLongAttribute(env, NULL((void*)0),
227 JMM_OS_PROCESS_ID);
228 return (jint) pid;
229}
230
231JNIEXPORT__attribute__((visibility("default"))) jint JNICALL
232Java_sun_management_VMManagementImpl_getAvailableProcessors
233 (JNIEnv *env, jobject dummy)
234{
235 return JVM_ActiveProcessorCount();
236}
237
238JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
239Java_sun_management_VMManagementImpl_getSafepointCount
240 (JNIEnv *env, jobject dummy)
241{
242 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
243 JMM_SAFEPOINT_COUNT);
244}
245
246JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
247Java_sun_management_VMManagementImpl_getTotalSafepointTime
248 (JNIEnv *env, jobject dummy)
249{
250 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
251 JMM_TOTAL_STOPPED_TIME_MS);
252}
253
254JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
255Java_sun_management_VMManagementImpl_getSafepointSyncTime
256 (JNIEnv *env, jobject dummy)
257{
258 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
259 JMM_TOTAL_SAFEPOINTSYNC_TIME_MS);
260}
261
262JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
263Java_sun_management_VMManagementImpl_getTotalApplicationNonStoppedTime
264 (JNIEnv *env, jobject dummy)
265{
266 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
267 JMM_TOTAL_APP_TIME_MS);
268}
269
270JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
271Java_sun_management_VMManagementImpl_getLoadedClassSize
272 (JNIEnv *env, jobject dummy)
273{
274 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
275 JMM_CLASS_LOADED_BYTES);
276}
277
278JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
279Java_sun_management_VMManagementImpl_getUnloadedClassSize
280 (JNIEnv *env, jobject dummy)
281{
282 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
283 JMM_CLASS_UNLOADED_BYTES);
284}
285JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
286Java_sun_management_VMManagementImpl_getClassLoadingTime
287 (JNIEnv *env, jobject dummy)
288{
289 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
290 JMM_TOTAL_CLASSLOAD_TIME_MS);
291}
292
293
294JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
295Java_sun_management_VMManagementImpl_getMethodDataSize
296 (JNIEnv *env, jobject dummy)
297{
298 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
299 JMM_METHOD_DATA_SIZE_BYTES);
300}
301
302JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
303Java_sun_management_VMManagementImpl_getInitializedClassCount
304 (JNIEnv *env, jobject dummy)
305{
306 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
307 JMM_CLASS_INIT_TOTAL_COUNT);
308}
309
310JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
311Java_sun_management_VMManagementImpl_getClassInitializationTime
312 (JNIEnv *env, jobject dummy)
313{
314 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
315 JMM_CLASS_INIT_TOTAL_TIME_MS);
316}
317
318JNIEXPORT__attribute__((visibility("default"))) jlong JNICALL
319Java_sun_management_VMManagementImpl_getClassVerificationTime
320 (JNIEnv *env, jobject dummy)
321{
322 return jmm_interface->GetLongAttribute(env, NULL((void*)0),
323 JMM_CLASS_VERIFY_TOTAL_TIME_MS);
324}