aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2017-07-14 10:34:48 +0200
committerAndreas Schneider <asn@samba.org>2017-07-14 15:20:09 +0200
commit4cbcf1fd1746bbc2e933401628a2cb71c0f1c45d (patch)
tree03f24330a2326018afc380c2304c41e0fb73ce25
parentc59500ee54aa95ebbc43c43ada06eeab41267cd7 (diff)
downloaduid_wrapper-4cbcf1fd1746bbc2e933401628a2cb71c0f1c45d.tar.gz
uid_wrapper-4cbcf1fd1746bbc2e933401628a2cb71c0f1c45d.tar.xz
uid_wrapper-4cbcf1fd1746bbc2e933401628a2cb71c0f1c45d.zip
uwrap: Do an early return if log level doesn't match
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r--src/uid_wrapper.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index a2ddd8b..0e9be96 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -142,40 +142,42 @@ static void uwrap_log(enum uwrap_dbglvl_e dbglvl, const char *function, const ch
va_list va;
const char *d;
unsigned int lvl = 0;
+ const char *prefix = "UWRAP";
d = getenv("UID_WRAPPER_DEBUGLEVEL");
if (d != NULL) {
lvl = atoi(d);
}
+ if (lvl < dbglvl) {
+ return;
+ }
+
va_start(va, format);
vsnprintf(buffer, sizeof(buffer), format, va);
va_end(va);
- if (lvl >= dbglvl) {
- const char *prefix = "UWRAP";
- switch (dbglvl) {
- case UWRAP_LOG_ERROR:
- prefix = "UWRAP_ERROR";
- break;
- case UWRAP_LOG_WARN:
- prefix = "UWRAP_WARN";
- break;
- case UWRAP_LOG_DEBUG:
- prefix = "UWRAP_DEBUG";
- break;
- case UWRAP_LOG_TRACE:
- prefix = "UWRAP_TRACE";
- break;
- }
-
- fprintf(stderr,
- "%s(%d) - %s: %s\n",
- prefix,
- (int)getpid(),
- function,
- buffer);
+ switch (dbglvl) {
+ case UWRAP_LOG_ERROR:
+ prefix = "UWRAP_ERROR";
+ break;
+ case UWRAP_LOG_WARN:
+ prefix = "UWRAP_WARN";
+ break;
+ case UWRAP_LOG_DEBUG:
+ prefix = "UWRAP_DEBUG";
+ break;
+ case UWRAP_LOG_TRACE:
+ prefix = "UWRAP_TRACE";
+ break;
}
+
+ fprintf(stderr,
+ "%s(%d) - %s: %s\n",
+ prefix,
+ (int)getpid(),
+ function,
+ buffer);
}
/*****************