From 6441db83c091772e13f3a2657ee3953713fbb8c0 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 24 Dec 2001 19:21:42 +0000 Subject: [PATCH] Misc cleanup, but doesn't fix tests. --- servers/slapd/entry.c | 1 - servers/slapd/modify.c | 2 +- servers/slapd/tools/slapadd.c | 12 +----------- servers/slapd/tools/slapcommon.c | 18 ++++++++++-------- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index b0f6511219..523bbd79ed 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -256,7 +256,6 @@ str2entry( char *s ) } rc = attr_merge( e, ad, vals ); - if( rc != 0 ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 58e2d9acb4..1bcf5b5c7c 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -530,7 +530,7 @@ int slap_modlist2mods( * and pretty if appropriate */ for( nvals = 0; ml->ml_bvalues[nvals]; nvals++ ) { - struct berval *pval; + struct berval *pval = NULL; if( pretty ) { rc = pretty( ad->ad_type->sat_syntax, ml->ml_bvalues[nvals], &pval ); diff --git a/servers/slapd/tools/slapadd.c b/servers/slapd/tools/slapadd.c index 41c654bb91..6f5ddeb6fa 100644 --- a/servers/slapd/tools/slapadd.c +++ b/servers/slapd/tools/slapadd.c @@ -64,18 +64,8 @@ main( int argc, char **argv ) break; } - /* make sure the DN is valid */ - if( dn_normalize( e->e_ndn ) == NULL || e->e_ndn[0] == '\0' ) { - fprintf( stderr, "%s: invalid dn=\"%s\" (line=%d)\n", - progname, e->e_dn, lineno ); - rc = EXIT_FAILURE; - entry_free( e ); - if( continuemode ) continue; - break; - } - /* make sure the DN is not empty */ - if( e->e_ndn == '\0' ) { + if( !e->e_nname.bv_len ) { fprintf( stderr, "%s: empty dn=\"%s\" (line=%d)\n", progname, e->e_dn, lineno ); rc = EXIT_FAILURE; diff --git a/servers/slapd/tools/slapcommon.c b/servers/slapd/tools/slapcommon.c index 3143550611..7cee79bbb6 100644 --- a/servers/slapd/tools/slapcommon.c +++ b/servers/slapd/tools/slapcommon.c @@ -80,7 +80,7 @@ slap_tool_init( int argc, char **argv ) { char *options; - char *base = NULL; + struct berval base = { 0, NULL }; int rc, i, dbnum; int mode = SLAP_TOOL_MODE; @@ -120,7 +120,8 @@ slap_tool_init( while ( (i = getopt( argc, argv, options )) != EOF ) { switch ( i ) { case 'b': - base = strdup( optarg ); + base.bv_val = strdup( optarg ); + base.bv_len = strlen( optarg ); case 'c': /* enable continue mode */ continuemode++; @@ -157,7 +158,7 @@ slap_tool_init( } } - if ( ( argc != optind ) || (dbnum >= 0 && base != NULL ) ) { + if ( ( argc != optind ) || (dbnum >= 0 && base.bv_val != NULL ) ) { usage( tool ); } @@ -210,17 +211,18 @@ slap_tool_init( exit( EXIT_FAILURE ); } - if( base != NULL ) { - char *tbase = ch_strdup( base ); + if( base.bv_val != NULL ) { + struct berval *nbase = NULL; - if( dn_normalize( tbase ) == NULL ) { + rc = dnNormalize( NULL, &base, &nbase ); + if( rc != LDAP_SUCCESS ) { fprintf( stderr, "%s: slap_init invalid suffix (\"%s\")\n", progname, base ); exit( EXIT_FAILURE ); } - be = select_backend( tbase, 0, 0 ); - free( tbase ); + be = select_backend( nbase->bv_val, 0, 0 ); + ber_bvfree( nbase ); if( be == NULL ) { fprintf( stderr, "%s: slap_init no backend for \"%s\"\n", -- 2.39.5