From c789ca6944649d4573fe80fee6076f34ce4fa601 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Mon, 11 May 2026 16:28:13 +0300 Subject: [PATCH] PS-10970 fix clang volatile warnings https://perconadev.atlassian.net/browse/PS-10970 Fix Clang volatile deprecation warnings in `src/linuxthreads.cc`, and silence the related empty-struct C/C++ compatibility warning in `src/elfcore.cc`. Also enable the appropriate compiler-specific C++ warning in `src/CMakeLists.txt` (`-Wdeprecated-volatile` for Clang/AppleClang, `-Wvolatile` for GCC). A broader `-Wall` cleanup is intentionally out of scope for this PR, since it introduces a larger set of unrelated legacy warnings and would make this change much less focused and riskier to review. --- src/CMakeLists.txt | 7 ++++++- src/elfcore.cc | 3 +++ src/linuxthreads.cc | 10 +++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7c7efa6..35e468b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,3 @@ - add_library( coredumper STATIC @@ -18,6 +17,12 @@ set_target_properties( "../include/coredumper/coredumper.h" ) +target_compile_options( + coredumper PRIVATE + $<$:-Wdeprecated-volatile> + $<$:-Wvolatile> +) + target_link_libraries(coredumper ${CMAKE_THREAD_LIBS_INIT}) export(TARGETS coredumper FILE "coredumper.cmake") diff --git a/src/elfcore.cc b/src/elfcore.cc index c6a436d..de8af0e 100644 --- a/src/elfcore.cc +++ b/src/elfcore.cc @@ -101,6 +101,7 @@ typedef struct fpxregs { /* SSE registers */ #define FPREGS fpxregs #else typedef struct fpxregs { /* x86-64 stores FPU registers in SSE struct */ + uint8_t unused; } fpxregs; typedef struct fpregs { /* FPU registers */ #define FPREGS fpregs @@ -123,6 +124,7 @@ typedef struct fpregs { /* FPU registers */ #define regs i386_regs /* General purpose registers */ #elif defined(__ARM_ARCH_3__) typedef struct fpxregs { /* No extended FPU registers on ARM */ + uint8_t unused; } fpxregs; typedef struct fpregs { /* FPU registers */ struct fp_reg { @@ -142,6 +144,7 @@ typedef struct fpregs { /* FPU registers */ #define regs arm_regs /* General purpose registers */ #elif defined(__mips__) typedef struct fpxregs { /* No extended FPU registers on MIPS */ + uint8_t unused; } fpxregs; typedef struct fpregs { uint64_t fpuregs[32]; diff --git a/src/linuxthreads.cc b/src/linuxthreads.cc index 7eba5fa..b6e208f 100644 --- a/src/linuxthreads.cc +++ b/src/linuxthreads.cc @@ -187,12 +187,14 @@ static volatile int *sig_pids, sig_num_threads, sig_proc, sig_marker; static void SignalHandler(int signum, siginfo_t *si, void *data) { if (sig_pids != NULL) { if (signum == SIGABRT) { - while (sig_num_threads-- > 0) { + while (sig_num_threads > 0) { + const int next_thread = sig_num_threads - 1; + sig_num_threads = next_thread; /* Not sure if sched_yield is really necessary here, but it does not */ /* hurt, and it might be necessary for the same reasons that we have */ /* to do so in sys_ptrace_detach(). */ sys_sched_yield(); - sys_ptrace(PTRACE_KILL, sig_pids[sig_num_threads], 0, 0); + sys_ptrace(PTRACE_KILL, sig_pids[next_thread], 0, 0); } } else if (sig_num_threads > 0) { ResumeAllProcessThreads(sig_num_threads, (int *)sig_pids); @@ -306,7 +308,9 @@ static void ListerThread(struct ListerParams *args) { * check there first, and then fall back on the older naming * convention if necessary. */ - if ((sig_proc = proc = c_open(*proc_path, O_RDONLY | O_DIRECTORY, 0)) < 0) { + proc = c_open(*proc_path, O_RDONLY | O_DIRECTORY, 0); + sig_proc = proc; + if (proc < 0) { if (*++proc_path != NULL) continue; goto failure; }