From: Pierangelo Masarati Date: Mon, 5 Dec 2005 10:39:38 +0000 (+0000) Subject: fix compilation without debugging (ITS#4245) X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~647 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2422e6aaab84a963593b445a50e5c85010fe6913;p=openldap fix compilation without debugging (ITS#4245) --- diff --git a/servers/slapd/main.c b/servers/slapd/main.c index ec4b40ab28..a24c0d8fe2 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -389,22 +389,27 @@ int main( int argc, char **argv ) LDAP_STAILQ_INSERT_TAIL( &slap_sync_cookie, scp, sc_next ); break; - case 'd': /* set debug level and 'do not detach' flag */ + case 'd': { /* set debug level and 'do not detach' flag */ + int level = 0; + no_detach = 1; #ifdef LDAP_DEBUG if ( optarg != NULL && optarg[ 0 ] != '-' && !isdigit( optarg[ 0 ] ) ) { - int level, i, goterr = 0; + int i, goterr = 0; char **levels; levels = ldap_str2charray( optarg, "," ); for ( i = 0; levels[ i ] != NULL; i++ ) { + level = 0; + if ( str2loglevel( levels[ i ], &level ) ) { fprintf( stderr, "unrecognized log level " "\"%s\"\n", levels[ i ] ); goterr = 1; + /* but keep parsing... */ } else { slap_debug |= level; @@ -418,8 +423,6 @@ int main( int argc, char **argv ) } } else { - int level; - if ( lutil_atoix( &level, optarg, 0 ) != 0 ) { fprintf( stderr, "unrecognized log level " @@ -433,7 +436,7 @@ int main( int argc, char **argv ) fputs( "must compile with LDAP_DEBUG for debugging\n", stderr ); #endif - break; + } break; case 'f': /* read config file */ configfile = ch_strdup( optarg ); diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index dc8ff261b3..8d0e032f6d 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -262,25 +262,31 @@ slap_tool_init( continuemode++; break; - case 'd': /* turn on debugging */ + case 'd': { /* turn on debugging */ + int level = 0; + #ifdef LDAP_DEBUG if ( optarg != NULL && optarg[ 0 ] != '-' && !isdigit( optarg[ 0 ] ) ) { - int level, i, goterr = 0; + int i, goterr = 0; char **levels; levels = ldap_str2charray( optarg, "," ); for ( i = 0; levels[ i ] != NULL; i++ ) { + level = 0; + if ( str2loglevel( levels[ i ], &level ) ) { fprintf( stderr, "unrecognized log level " "\"%s\"\n", levels[ i ] ); goterr = 1; + /* but keep parsing... */ } else { - if ( level ) { + if ( level != 0 ) { slap_debug |= level; + } else { /* allow to reset log level */ slap_debug = 0; @@ -295,8 +301,6 @@ slap_tool_init( } } else { - int level; - if ( lutil_atoix( &level, optarg, 0 ) != 0 ) { fprintf( stderr, "unrecognized log level " @@ -304,8 +308,9 @@ slap_tool_init( usage( tool, progname ); } - if ( level ) { + if ( level != 0 ) { slap_debug |= level; + } else { /* allow to reset log level */ slap_debug = 0; @@ -316,7 +321,7 @@ slap_tool_init( fputs( "must compile with LDAP_DEBUG for debugging\n", stderr ); #endif - break; + } break; case 'D': ber_str2bv( optarg, 0, 1, &authcDN );