From e7c5bf45f753ad6459c666a4dd4a31197b69e05e Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Thu, 10 Oct 2024 07:21:05 +0000 Subject: [PATCH] 8341722: Fix some warnings as errors when building on Linux with toolchain clang Reviewed-by: cjplummer, lucy --- make/modules/jdk.hotspot.agent/Lib.gmk | 2 -- .../linux/native/libsaproc/LinuxDebuggerLocal.cpp | 1 - src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c | 4 ++-- src/jdk.jpackage/share/native/common/Log.cpp | 4 ---- test/hotspot/gtest/runtime/test_os_linux.cpp | 4 ++-- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/make/modules/jdk.hotspot.agent/Lib.gmk b/make/modules/jdk.hotspot.agent/Lib.gmk index f0ede594d0c..12f1c1f2a90 100644 --- a/make/modules/jdk.hotspot.agent/Lib.gmk +++ b/make/modules/jdk.hotspot.agent/Lib.gmk @@ -59,9 +59,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBSAPROC, \ OPTIMIZATION := HIGH, \ EXTRA_HEADER_DIRS := java.base:libjvm, \ DISABLED_WARNINGS_gcc := sign-compare, \ - DISABLED_WARNINGS_gcc_LinuxDebuggerLocal.cpp := unused-variable, \ DISABLED_WARNINGS_gcc_ps_core.c := pointer-arith, \ - DISABLED_WARNINGS_gcc_symtab.c := unused-but-set-variable, \ DISABLED_WARNINGS_clang := sign-compare, \ DISABLED_WARNINGS_clang_libproc_impl.c := format-nonliteral, \ DISABLED_WARNINGS_clang_MacosxDebuggerLocal.m := unused-variable, \ diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.cpp b/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.cpp index 962b1ae5172..0ad95d0eac7 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.cpp +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.cpp @@ -420,7 +420,6 @@ JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLo jboolean isCopy; jlongArray array; jlong *regs; - int i; struct ps_prochandle* ph = get_proc_handle(env, this_obj); if (get_lwp_regs(ph, lwp_id, &gregs) != true) { diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c b/src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c index d3b4d3d1af9..c36b9e5707e 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c @@ -356,7 +356,6 @@ static struct symtab* build_symtab_internal(int fd, const char *filename, bool t if (shdr->sh_type == sym_section) { ELF_SYM *syms; - int rslt; size_t size, n, j, htab_sz; // FIXME: there could be multiple data buffers associated with the @@ -390,7 +389,8 @@ static struct symtab* build_symtab_internal(int fd, const char *filename, bool t goto bad; } - rslt = hcreate_r(htab_sz, symtab->hash_table); + // int rslt = + hcreate_r(htab_sz, symtab->hash_table); // guarantee(rslt, "unexpected failure: hcreate_r"); // shdr->sh_link points to the section that contains the actual strings diff --git a/src/jdk.jpackage/share/native/common/Log.cpp b/src/jdk.jpackage/share/native/common/Log.cpp index 66154ee8247..8227bb1cce4 100644 --- a/src/jdk.jpackage/share/native/common/Log.cpp +++ b/src/jdk.jpackage/share/native/common/Log.cpp @@ -40,10 +40,6 @@ namespace { // variables are initialized if any. This will result in AV. To avoid such // use cases keep logging module free from static variables that require // initialization with functions called by CRT. - // - - // by default log everything - const Logger::LogLevel defaultLogLevel = Logger::LOG_TRACE; char defaultLogAppenderMemory[sizeof(StreamLogAppender)] = {}; diff --git a/test/hotspot/gtest/runtime/test_os_linux.cpp b/test/hotspot/gtest/runtime/test_os_linux.cpp index 69c3d991b2a..387940afdf2 100644 --- a/test/hotspot/gtest/runtime/test_os_linux.cpp +++ b/test/hotspot/gtest/runtime/test_os_linux.cpp @@ -360,10 +360,10 @@ TEST_VM(os_linux, pretouch_thp_and_use_concurrent) { EXPECT_TRUE(os::commit_memory(heap, size, false)); { - auto pretouch = [heap, size](Thread*, int) { + auto pretouch = [heap](Thread*, int) { os::pretouch_memory(heap, heap + size, os::vm_page_size()); }; - auto useMemory = [heap, size](Thread*, int) { + auto useMemory = [heap](Thread*, int) { int* iptr = reinterpret_cast(heap); for (int i = 0; i < 1000; i++) *iptr++ = i; };