From 105f199f6b2848ad29a6b9c00e2bbb26cffe63e8 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 30 Jun 2015 10:41:14 -0600 Subject: [PATCH] Fix build on compilers w/o __func__ or __FUNCTION__ --- include/sudo_debug.h | 5 ++++- lib/util/sudo_debug.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/sudo_debug.h b/include/sudo_debug.h index 70619f1c9..938c13744 100644 --- a/include/sudo_debug.h +++ b/include/sudo_debug.h @@ -98,12 +98,15 @@ struct sudo_conf_debug_file_list; * and sets sudo_debug_subsys for sudo_debug_exit(). */ #ifdef HAVE___FUNC__ +# define debug_decl_func(funcname) # define debug_decl_vars(funcname, subsys) \ const int sudo_debug_subsys = (subsys); #else +# define debug_decl_func(funcname) \ + const char __func__[] = #funcname; # define debug_decl_vars(funcname, subsys) \ const int sudo_debug_subsys = (subsys); \ - const char __func__[] = #funcname; + debug_decl_func(funcname); #endif #define debug_decl(funcname, subsys) \ debug_decl_vars((funcname), (subsys)) \ diff --git a/lib/util/sudo_debug.c b/lib/util/sudo_debug.c index b8efb7586..9c884e416 100644 --- a/lib/util/sudo_debug.c +++ b/lib/util/sudo_debug.c @@ -253,6 +253,7 @@ sudo_debug_register_v1(const char *program, const char *const subsystems[], struct sudo_debug_output *output; struct sudo_debug_file *debug_file; int idx, free_idx = -1; + debug_decl_func(sudo_debug_register); if (debug_files == NULL) return SUDO_DEBUG_INSTANCE_INITIALIZER; @@ -357,6 +358,7 @@ sudo_debug_deregister_v1(int idx) { struct sudo_debug_instance *instance; struct sudo_debug_output *output, *next; + debug_decl_func(sudo_debug_deregister); if (idx < 0 || idx > sudo_debug_last_instance) { sudo_warnx_nodebug("%s: invalid instance ID %d, max %d", @@ -577,6 +579,7 @@ sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno, int level char static_buf[1024], *buf = static_buf; struct sudo_debug_instance *instance; struct sudo_debug_output *output; + debug_decl_func(sudo_debug_vprintf2); if (sudo_debug_active_instance == -1) goto out; @@ -667,6 +670,7 @@ sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *con char * const *av; char *cp, static_buf[4096], *buf = static_buf; size_t plen; + debug_decl_func(sudo_debug_execve2); if (sudo_debug_active_instance == -1) goto out; -- 2.50.1