]> git.sur5r.net Git - openldap/commitdiff
fix compilation without debugging (ITS#4245)
authorPierangelo Masarati <ando@openldap.org>
Mon, 5 Dec 2005 10:39:38 +0000 (10:39 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 5 Dec 2005 10:39:38 +0000 (10:39 +0000)
servers/slapd/main.c
servers/slapd/slapcommon.c

index ec4b40ab28138b39f1eafde90005631a202db67f..a24c0d8fe2d7698355ec28e02cfbe6f6dda655f2 100644 (file)
@@ -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 );
index dc8ff261b3adc162bae7068e400c1e643ac43149..8d0e032f6d0725784a013edb4ec2aaee13bd0be4 100644 (file)
@@ -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 );