summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2014-07-29 15:02:22 +0000
committerMichael Adam <obnox@samba.org>2014-07-31 18:49:47 +0200
commit15b0f57696cf8c1ae1c8760008b414f9a456bc49 (patch)
treed7b4095ec7ab09124829c979c749936eb2975eaa /lib
parent0753c1bec1ff5888068eeba5878c460ce07cef2a (diff)
downloadsamba-15b0f57696cf8c1ae1c8760008b414f9a456bc49.tar.gz
debug: Simplify dbghdrclass with an early return
No code change, visible with "git diff -w" Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/util/debug.c84
1 files changed, 43 insertions, 41 deletions
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 3524a9a58c0..6dbf906177d 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -969,6 +969,8 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func)
{
/* Ensure we don't lose any real errno value. */
int old_errno = errno;
+ bool verbose = false;
+ char header_str[200];
if( format_pos ) {
/* This is a fudge. If there is stuff sitting in the format_bufr, then
@@ -994,53 +996,53 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func)
/* Print the header if timestamps are turned on. If parameters are
* not yet loaded, then default to timestamps on.
*/
- if( state.settings.timestamp_logs || state.settings.debug_prefix_timestamp) {
- bool verbose = false;
- char header_str[200];
+ if (!(state.settings.timestamp_logs ||
+ state.settings.debug_prefix_timestamp)) {
+ return true;
+ }
- header_str[0] = '\0';
+ header_str[0] = '\0';
- if (unlikely(DEBUGLEVEL_CLASS[ cls ] >= 10)) {
- verbose = true;
- }
+ if (unlikely(DEBUGLEVEL_CLASS[ cls ] >= 10)) {
+ verbose = true;
+ }
- if (verbose || state.settings.debug_pid)
- slprintf(header_str,sizeof(header_str)-1,", pid=%u",(unsigned int)getpid());
+ if (verbose || state.settings.debug_pid)
+ slprintf(header_str,sizeof(header_str)-1,", pid=%u",(unsigned int)getpid());
- if (verbose || state.settings.debug_uid) {
- size_t hs_len = strlen(header_str);
- slprintf(header_str + hs_len,
- sizeof(header_str) - 1 - hs_len,
- ", effective(%u, %u), real(%u, %u)",
- (unsigned int)geteuid(), (unsigned int)getegid(),
- (unsigned int)getuid(), (unsigned int)getgid());
- }
+ if (verbose || state.settings.debug_uid) {
+ size_t hs_len = strlen(header_str);
+ slprintf(header_str + hs_len,
+ sizeof(header_str) - 1 - hs_len,
+ ", effective(%u, %u), real(%u, %u)",
+ (unsigned int)geteuid(), (unsigned int)getegid(),
+ (unsigned int)getuid(), (unsigned int)getgid());
+ }
- if ((verbose || state.settings.debug_class)
- && (cls != DBGC_ALL)) {
- size_t hs_len = strlen(header_str);
- slprintf(header_str + hs_len,
- sizeof(header_str) -1 - hs_len,
- ", class=%s",
- classname_table[cls]);
- }
+ if ((verbose || state.settings.debug_class)
+ && (cls != DBGC_ALL)) {
+ size_t hs_len = strlen(header_str);
+ slprintf(header_str + hs_len,
+ sizeof(header_str) -1 - hs_len,
+ ", class=%s",
+ classname_table[cls]);
+ }
- /* Print it all out at once to prevent split syslog output. */
- if( state.settings.debug_prefix_timestamp ) {
- char *time_str = current_timestring(NULL,
- state.settings.debug_hires_timestamp);
- (void)Debug1( "[%s, %2d%s] ",
- time_str,
- level, header_str);
- talloc_free(time_str);
- } else {
- char *time_str = current_timestring(NULL,
- state.settings.debug_hires_timestamp);
- (void)Debug1( "[%s, %2d%s] %s(%s)\n",
- time_str,
- level, header_str, location, func );
- talloc_free(time_str);
- }
+ /* Print it all out at once to prevent split syslog output. */
+ if( state.settings.debug_prefix_timestamp ) {
+ char *time_str = current_timestring(NULL,
+ state.settings.debug_hires_timestamp);
+ (void)Debug1( "[%s, %2d%s] ",
+ time_str,
+ level, header_str);
+ talloc_free(time_str);
+ } else {
+ char *time_str = current_timestring(NULL,
+ state.settings.debug_hires_timestamp);
+ (void)Debug1( "[%s, %2d%s] %s(%s)\n",
+ time_str,
+ level, header_str, location, func );
+ talloc_free(time_str);
}
errno = old_errno;