]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
backtrace: Only define print_sourceline() and esc() if actually used
authorTobias Brunner <tobias@strongswan.org>
Mon, 3 Oct 2022 12:06:35 +0000 (14:06 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 3 Oct 2022 15:36:17 +0000 (17:36 +0200)
src/libstrongswan/utils/backtrace.c

index 432d501c95e05997e6fcd97b56a00897a1f14f04..b93be1ed6f5c1d7be3e32a25bf39239458610455 100644 (file)
@@ -97,6 +97,9 @@ static void println(FILE *file, char *format, ...)
        va_end(args);
 }
 
+#if ((defined(HAVE_BACKTRACE) || defined(HAVE_LIBUNWIND_H)) && \
+         defined(HAVE_DLADDR)) || defined(WIN32)
+
 /**
  * Same as tty_escape_get(), but for a potentially NULL FILE*
  */
@@ -109,6 +112,8 @@ static inline char* esc(FILE *file, tty_escape_t escape)
        return "";
 }
 
+#endif /* HAVE_BACKTRACE/HAVE_LIBUNWIND_H/WIN32 */
+
 #ifdef HAVE_DBGHELP
 
 #include <dbghelp.h>
@@ -408,6 +413,8 @@ static void print_sourceline(FILE *file, char *filename, void *ptr, void *base)
 void backtrace_init() {}
 void backtrace_deinit() {}
 
+#if defined(HAVE_BACKTRACE) || defined(HAVE_LIBUNWIND_H) || defined(WIN32)
+
 /**
  * Print the source file with line number to file, slow addr2line variant
  */
@@ -444,6 +451,8 @@ static void print_sourceline(FILE *file, char *filename, void *ptr, void* base)
        }
 }
 
+#endif /* HAVE_BACKTRACE/HAVE_LIBUNWIND_H/WIN32 */
+
 #endif /* HAVE_BFD_H */
 
 #else /* !HAVE_DLADDR && !HAVE_DBGHELP */
@@ -572,7 +581,7 @@ METHOD(backtrace_t, log_, void,
 #endif /* HAVE_BFD_H */
                }
                else
-#endif /* HAVE_DLADDR/HAVE_DBGHELP */
+#endif /* HAVE_DLADDR/HAVE_DBGHELP/WIN32 */
                {
 #ifdef HAVE_BACKTRACE
                        if (!strings)