From: Pierangelo Masarati Date: Tue, 4 Mar 2003 09:46:48 +0000 (+0000) Subject: more improvements ... X-Git-Tag: NO_SLAP_OP_BLOCKS~189 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4a658ee581130c31ff1a2139c418165a353a1252;p=openldap more improvements ... --- diff --git a/servers/slapd/tools/slapcommon.c b/servers/slapd/tools/slapcommon.c index 8bb70bf7d9..519d1f8c66 100644 --- a/servers/slapd/tools/slapcommon.c +++ b/servers/slapd/tools/slapcommon.c @@ -255,6 +255,11 @@ slap_tool_init( } } else if ( dbnum == -1 ) { + if ( nbackends <= 0 ) { + fprintf( stderr, "No available databases\n" ); + exit( EXIT_FAILURE ); + } + be = &backends[dbnum=0]; /* If just doing the first by default and it is a * glue subordinate, find the master. @@ -268,12 +273,7 @@ slap_tool_init( } - if ( dbnum < 0 ) { - fprintf( stderr, "No available database\n" ); - exit( EXIT_FAILURE ); - } - - if ( dbnum > (nbackends-1) ) { + if ( dbnum >= nbackends ) { fprintf( stderr, "Available database(s) " "do not allow %s\n", name ); exit( EXIT_FAILURE ); @@ -283,11 +283,11 @@ slap_tool_init( #ifdef NEW_LOGGING LDAP_LOG( BACKEND, ERR, "The first database does not allow %s; using the first available one (%d)\n", - name, (int)(be - &backends[0]) + 1, 0 ); + name, dbnum + 1, 0 ); #else Debug( LDAP_DEBUG_ANY, "The first database does not allow %s; using the first available one (%d)\n", - name, (int)(be - &backends[0]) + 1, 0 ); + name, dbnum + 1, 0 ); #endif }