diff mbox series

[meta-oe,1/2] dlt-daemon: Fix build with clang-23

Message ID 20260910052133.2153716-1-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-oe,1/2] dlt-daemon: Fix build with clang-23 | expand

Commit Message

Khem Raj Sept. 10, 2026, 5:21 a.m. UTC
clang 23 added -Wunused-but-set-global, enabled by -Wall, and the build
uses -Werror -Wfatal-errors, so this is now a hard failure:

  src/lib/dlt_user.c:132:20: fatal error: variable
    'dlt_user_housekeeper_exit_requested' set but not used
    [-Wunused-but-set-global]
    132 | static atomic_bool dlt_user_housekeeper_exit_requested = false;

The diagnostic is pointing at a real bug: dlt_user_atexit_handler() sets
the flag to "Signal housekeeper thread to exit", but nothing ever reads
it, so the housekeeper thread only ever stops when dlt_stop_threads()
cancels it. Not fixed upstream, master still has the same dead store.

Add a patch checking the flag in the housekeeper loop condition. Leaving
the loop that way is equivalent to being cancelled, pthread_cleanup_pop(1)
at the end of the function runs dlt_user_cleanup_handler() either way.

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...t_user_housekeeper_exit_requested-in.patch | 43 +++++++++++++++++++
 .../dlt-daemon/dlt-daemon_3.0.0.bb            |  1 +
 2 files changed, 44 insertions(+)
 create mode 100644 meta-oe/recipes-extended/dlt-daemon/dlt-daemon/0001-dlt_user-Honor-dlt_user_housekeeper_exit_requested-in.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-extended/dlt-daemon/dlt-daemon/0001-dlt_user-Honor-dlt_user_housekeeper_exit_requested-in.patch b/meta-oe/recipes-extended/dlt-daemon/dlt-daemon/0001-dlt_user-Honor-dlt_user_housekeeper_exit_requested-in.patch
new file mode 100644
index 0000000000..a3adbd9d76
--- /dev/null
+++ b/meta-oe/recipes-extended/dlt-daemon/dlt-daemon/0001-dlt_user-Honor-dlt_user_housekeeper_exit_requested-in.patch
@@ -0,0 +1,43 @@ 
+From 9ddee0a5f46a1d7fea81228e6905ebc485e678a7 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 9 Sep 2026 20:24:55 -0700
+Subject: [PATCH] dlt_user: Honor dlt_user_housekeeper_exit_requested in
+ housekeeper loop
+
+dlt_user_atexit_handler() sets dlt_user_housekeeper_exit_requested to
+signal the housekeeper thread to exit, but nothing ever reads the flag,
+so the housekeeper thread keeps running until dlt_stop_threads() cancels
+it with pthread_cancel().
+
+clang 23 added -Wunused-but-set-global (enabled by -Wall) which spots
+this dead store, and since the build uses -Werror -Wfatal-errors it is
+now a hard build failure:
+
+  src/lib/dlt_user.c:132:20: fatal error: variable
+    'dlt_user_housekeeper_exit_requested' set but not used
+    [-Wunused-but-set-global]
+    132 | static atomic_bool dlt_user_housekeeper_exit_requested = false;
+
+Check the flag in the housekeeper loop condition, which is what the
+"Signal housekeeper thread to exit" comment intends. Leaving the loop
+this way is equivalent to being cancelled: pthread_cleanup_pop(1) at the
+end of the function runs dlt_user_cleanup_handler() either way.
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/lib/dlt_user.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
+index daf5e8b..9fa2906 100644
+--- a/src/lib/dlt_user.c
++++ b/src/lib/dlt_user.c
+@@ -4850,7 +4850,7 @@ void *dlt_user_housekeeperthread_function(void *ptr)
+
+     pthread_mutex_unlock(&dlt_housekeeper_running_mutex);
+
+-    while (in_loop) {
++    while (in_loop && !dlt_user_housekeeper_exit_requested) {
+         /* Check for new messages from DLT daemon */
+         if (!dlt_user.disable_injection_msg)
+             if (dlt_user_log_check_user_message() < DLT_RETURN_OK)
diff --git a/meta-oe/recipes-extended/dlt-daemon/dlt-daemon_3.0.0.bb b/meta-oe/recipes-extended/dlt-daemon/dlt-daemon_3.0.0.bb
index 6de62c2a3d..79f28c2901 100644
--- a/meta-oe/recipes-extended/dlt-daemon/dlt-daemon_3.0.0.bb
+++ b/meta-oe/recipes-extended/dlt-daemon/dlt-daemon_3.0.0.bb
@@ -26,6 +26,7 @@  SRC_URI = "git://github.com/COVESA/${BPN}.git;protocol=https;branch=master \
            file://0001-warnings-Fix-clang-generated-warnings.patch \
            file://0001-dlt-daemon.c-fix-wrong-len.patch \
            file://char_conversion.patch \
+           file://0001-dlt_user-Honor-dlt_user_housekeeper_exit_requested-in.patch \
            "
 SRCREV = "f595ea29d1007ca1c3b2d1fd3a88adf7d3db6320"