From 983ab1d16374a7c3fbcfcd0e10b166f99b22703c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 2 May 2014 05:25:57 -0600 Subject: [PATCH] Avoid unused variable warning if auditing is not supported. --- plugins/sudoers/audit.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins/sudoers/audit.c b/plugins/sudoers/audit.c index 300f89ed0..d1ca77128 100644 --- a/plugins/sudoers/audit.c +++ b/plugins/sudoers/audit.c @@ -70,15 +70,17 @@ audit_success(char *exec_args[]) int audit_failure(char *exec_args[], char const *const fmt, ...) { - va_list ap; - int oldlocale; int rc = 0; debug_decl(audit_success, SUDO_DEBUG_AUDIT) - /* Audit error messages should be in the sudoers locale. */ - sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale); - +#if defined(HAVE_BSM_AUDIT) || defined(HAVE_LINUX_AUDIT) if (exec_args != NULL) { + va_list ap; + int oldlocale; + + /* Audit error messages should be in the sudoers locale. */ + sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale); + #ifdef HAVE_BSM_AUDIT va_start(ap, fmt); if (bsm_audit_failure(exec_args, _(fmt), ap) == -1) @@ -91,9 +93,10 @@ audit_failure(char *exec_args[], char const *const fmt, ...) rc = -1; va_end(ap); #endif - } - sudoers_setlocale(oldlocale, NULL); + sudoers_setlocale(oldlocale, NULL); + } +#endif /* HAVE_BSM_AUDIT || HAVE_LINUX_AUDIT */ debug_return_int(rc); }