ot-br-posix: reference sCrashCallback on non-glibc

backtrace.cpp sets sCrashCallback but only reads it back inside a
glibc-only execinfo backtrace path, so on musl (no backtrace()) clang
flags it as -Wunused-but-set-variable under -Werror. Reference it in
the non-glibc branch too.

AI-Generated: Uses Claude Code

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
Khem Raj committed 2026-09-29 15:35:17 -07:00
1 parent 760441e7fd
commit 9a16e39dff
2 files changed
+35

No files matched your search

@@ -0,0 +1,34 @@
From: Khem Raj <khem.raj@oss.qualcomm.com>
Date: Tue, 29 Sep 2026 01:57:51 +0000
Subject: [PATCH] posix/backtrace: Reference sCrashCallback on non-glibc,
non-Android builds
sCrashCallback is set unconditionally by otSysRegisterCrashCallback()
whenever OPENTHREAD_POSIX_CONFIG_BACKTRACE_ENABLE is set, but it is
only read from signalCritical(), which is compiled solely under the
`OPENTHREAD_POSIX_CONFIG_ANDROID_ENABLE || defined(__GLIBC__)` branch.
On musl (neither Android nor glibc) that branch is replaced by an
empty platformBacktraceInit() stub, so the variable is set but never
used, which clang's -Wunused-but-set-global (promoted to -Werror)
turns into a hard build failure. Use the existing OT_UNUSED_VARIABLE()
idiom already used elsewhere in this file (e.g. in signalCritical())
to acknowledge the variable on this code path too.
Upstream-Status: Pending
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
src/posix/platform/backtrace.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/posix/platform/backtrace.cpp b/src/posix/platform/backtrace.cpp
index 1111111..2222222 100644
--- a/src/posix/platform/backtrace.cpp
+++ b/src/posix/platform/backtrace.cpp
@@ -185,6 +185,6 @@ void platformBacktraceInit(void)
}
}
#else // OPENTHREAD_POSIX_CONFIG_ANDROID_ENABLE || defined(__GLIBC__)
-void platformBacktraceInit(void) {}
+void platformBacktraceInit(void) { OT_UNUSED_VARIABLE(sCrashCallback); }
#endif // OPENTHREAD_POSIX_CONFIG_ANDROID_ENABLE || defined(__GLIBC__)
#endif // OPENTHREAD_POSIX_CONFIG_BACKTRACE_ENABLE
@@ -17,6 +17,7 @@ SRC_URI = "gitsm://github.com/openthread/ot-br-posix.git;protocol=https;branch=m
file://0001-cmake-Disable-nonnull-compare-warning-on-gcc.patch \
file://default-cxx-std.patch \
file://0001-x509_crt-Zero-initialize-mbedtls_x509_time-at-declar.patch;patchdir=third_party/openthread/repo \
file://0001-posix-backtrace-Reference-sCrashCallback-on-non-gli.patch;patchdir=third_party/openthread/repo \
"
SYSTEMD_SERVICE:${PN} = "otbr-agent.service"