From f7df0ef751c81a7576c829c3194120423def382d Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Thu, 15 May 2025 19:35:43 +0100 Subject: [PATCH] coap_debug.c: Allow compilation with thread-safe not enabled If COAP_THREAD_NUM_LOGGING was set, but COAP_THREAD_SAFE was not, compilation errors occurred. --- src/coap_debug.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/coap_debug.c b/src/coap_debug.c index e2cbec9a..6ab6adae 100644 --- a/src/coap_debug.c +++ b/src/coap_debug.c @@ -1288,10 +1288,12 @@ coap_set_log_handler(coap_log_handler_t handler) { log_handler = handler; } +#if COAP_THREAD_SAFE && COAP_THREAD_NUM_LOGGING /* Visible to only this thread */ extern COAP_THREAD_LOCAL_VAR uint32_t thread_no; /* Visible across all threads */ extern uint32_t max_thread_no; +#endif /* COAP_THREAD_SAFE && COAP_THREAD_NUM_LOGGING */ void coap_log_impl(coap_log_t level, const char *format, ...) { @@ -1331,12 +1333,12 @@ coap_log_impl(coap_log_t level, const char *format, ...) { if (len) fprintf(log_fd, "%.*s ", (int)len, timebuf); -#if COAP_THREAD_NUM_LOGGING +#if COAP_THREAD_SAFE && COAP_THREAD_NUM_LOGGING if (thread_no == 0) { thread_no = ++max_thread_no; } fprintf(log_fd, "%2d ", thread_no); -#endif /* COAP_THREAD_NUM_LOGGING */ +#endif /* COAP_THREAD_SAFE && COAP_THREAD_NUM_LOGGING */ fprintf(log_fd, "%s ", coap_log_level_desc(level));