From 8fd082e6e6337cb6e480d7235c25d89f50bebc0e Mon Sep 17 00:00:00 2001 From: chrysn Date: Fri, 8 Mar 2024 17:28:28 +0100 Subject: [PATCH] thread/name: Avoid calling C function known to return 0 --- src/thread/riot_c.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/thread/riot_c.rs b/src/thread/riot_c.rs index 4a93e5cb..0d116476 100644 --- a/src/thread/riot_c.rs +++ b/src/thread/riot_c.rs @@ -106,6 +106,11 @@ impl KernelPID { } pub fn get_name(&self) -> Option<&str> { + // Shortcut through an otherwise unoptimizable function + if !cfg!(riot_develhelp) { + return None; + } + let ptr = unsafe { raw::thread_getname(self.0) }; // If the thread stops, the name might be not valid any more, but then again the getname