From 6bac96b0bd845f5445869531968d14529480f1e5 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sat, 26 Jan 2002 08:44:59 +0000 Subject: [PATCH] Changed dnParent to void instead of int. (It always returned success...) --- servers/slapd/back-bdb/add.c | 6 +---- servers/slapd/back-bdb/delete.c | 6 +---- servers/slapd/back-bdb/dn2id.c | 40 ++++------------------------ servers/slapd/back-bdb/modrdn.c | 12 ++------- servers/slapd/back-bdb/search.c | 7 +++-- servers/slapd/back-bdb/tools.c | 17 ++---------- servers/slapd/back-ldbm/add.c | 3 +-- servers/slapd/back-ldbm/delete.c | 4 +-- servers/slapd/back-ldbm/dn2id.c | 45 ++++++++++++++------------------ servers/slapd/backglue.c | 10 ++----- servers/slapd/dn.c | 6 ++--- servers/slapd/proto-slap.h | 2 +- 12 files changed, 43 insertions(+), 115 deletions(-) diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index af4f37a46a..1a8a66acc5 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -107,11 +107,7 @@ retry: /* transaction retry */ if ( be_issuffix( be, &e->e_nname ) ) { pdn = slap_empty_bv; } else { - rc = dnParent( &e->e_nname, &pdn ); - if ( rc != LDAP_SUCCESS ) { - text = "internal error"; - goto return_results; - } + dnParent( &e->e_nname, &pdn ); } if( pdn.bv_len != 0 ) { diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 7658c84fc1..1e38499fdf 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -82,11 +82,7 @@ retry: /* transaction retry */ op->o_private = &opinfo; if ( !be_issuffix( be, ndn ) ) { - rc = dnParent( ndn, &pdn ); - if ( rc != LDAP_SUCCESS ) { - text = "internal error"; - goto return_results; - } + dnParent( ndn, &pdn ); } if( pdn.bv_len != 0 ) { diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 33fb362256..b0bef02a1d 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -64,13 +64,7 @@ bdb_dn2id_add( goto done; } - rc = dnParent( &ptr, &pdn ); - if ( rc != LDAP_SUCCESS ) { - Debug( LDAP_DEBUG_ANY, - "=> bdb_dn2id_add: dnParent(\"%s\") failed\n", - ptr.bv_val, 0, 0 ); - goto done; - } + dnParent( &ptr, &pdn ); key.size = pdn.bv_len + 2; pdn.bv_val[-1] = DN_ONE_PREFIX; @@ -98,13 +92,7 @@ bdb_dn2id_add( ptr.bv_val, rc, 0 ); break; } - rc = dnParent( &ptr, &pdn ); - if ( rc != LDAP_SUCCESS ) { - Debug( LDAP_DEBUG_ANY, - "=> bdb_dn2id_add: dnParent(\"%s\") failed\n", - ptr.bv_val, 0, 0 ); - goto done; - } + dnParent( &ptr, &pdn ); key.size = pdn.bv_len + 2; key.data = pdn.bv_val - 1; @@ -163,13 +151,7 @@ bdb_dn2id_delete( goto done; } - rc = dnParent( &ptr, &pdn ); - if ( rc != LDAP_SUCCESS ) { - Debug( LDAP_DEBUG_ANY, - "=> bdb_dn2id_delete: dnParent(\"%s\") failed\n", - ptr.bv_val, 0, 0 ); - goto done; - } + dnParent( &ptr, &pdn ); key.size = pdn.bv_len + 2; pdn.bv_val[-1] = DN_ONE_PREFIX; @@ -196,13 +178,7 @@ bdb_dn2id_delete( ptr.bv_val, rc, 0 ); goto done; } - rc = dnParent( &ptr, &pdn ); - if ( rc != LDAP_SUCCESS ) { - Debug( LDAP_DEBUG_ANY, - "=> bdb_dn2id_delete: dnParent(\"%s\") failed\n", - ptr.bv_val, 0, 0 ); - goto done; - } + dnParent( &ptr, &pdn ); key.size = pdn.bv_len + 2; key.data = pdn.bv_val - 1; @@ -319,13 +295,7 @@ bdb_dn2id_matched( struct berval pdn; if ( ! be_issuffix( be, &dn ) ) { - rc = dnParent( &dn, &pdn ); - if ( rc != LDAP_SUCCESS ) { - Debug( LDAP_DEBUG_TRACE, - "<= bdb_dn2id_matched: dnParent(\"%s\") failed\n", - dn.bv_val, 0, 0 ); - break; - } + dnParent( &dn, &pdn ); } else { Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_matched: no match\n", diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 45f25b557f..f83fd79e9a 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -173,11 +173,7 @@ retry: /* transaction retry */ if ( be_issuffix( be, &e->e_nname ) ) { p_ndn = slap_empty_bv; } else { - rc = dnParent( &e->e_nname, &p_ndn ); - if ( rc != LDAP_SUCCESS ) { - text = "internal error"; - goto return_results; - } + dnParent( &e->e_nname, &p_ndn ); } np_ndn = &p_ndn; if ( p_ndn.bv_len != 0 ) { @@ -224,11 +220,7 @@ retry: /* transaction retry */ if ( p_ndn.bv_val == slap_empty_bv.bv_val ) { p_dn = slap_empty_bv; } else { - rc = dnParent( &e->e_name, &p_dn ); - if ( rc != LDAP_SUCCESS ) { - text = "internal error"; - goto return_results; - } + dnParent( &e->e_name, &p_dn ); } Debug( LDAP_DEBUG_TRACE, diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 239a70de7f..f4ee315c1b 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -354,10 +354,9 @@ bdb_search( if( scope & LDAP_SCOPE_ONELEVEL ) { struct berval pdn; - if ( dnParent( &e->e_nname, &pdn ) == LDAP_SUCCESS ) { - if ( ber_bvcmp( pdn, &realbase ) ) { - goto loop_continue; - } + dnParent( &e->e_nname, &pdn ): + if ( ber_bvcmp( pdn, &realbase ) ) { + goto loop_continue; } } else if ( dnIsSuffix( &e->e_nname, &realbase ) ) { diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index 1612db3b31..a1323405e1 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -158,14 +158,7 @@ ID bdb_tool_entry_put( if ( be_issuffix( be, &e->e_nname ) ) { pdn = slap_empty_bv; } else { - rc = dnParent( &e->e_nname, &pdn ); - if ( rc != LDAP_SUCCESS ) { - Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_put: " - "dnParent(\"%s\") failed\n", - e->e_nname.bv_val, 0, 0 ); - - goto done; - } + dnParent( &e->e_nname, &pdn ); } rc = bdb_dn2id_add( be, tid, &pdn, e ); if( rc != 0 ) { @@ -273,13 +266,7 @@ int bdb_tool_entry_reindex( if ( be_issuffix( be, &e->e_nname ) ) { pdn = slap_empty_bv; } else { - rc = dnParent( &e->e_nname, &pdn ); - if ( rc != LDAP_SUCCESS ) { - Debug( LDAP_DEBUG_ANY, "=> bdb_tool_entry_reindex: " - "dnParent(\"%s\") failed\n", - e->e_nname.bv_val, 0, 0 ); - goto done; - } + dnParent( &e->e_nname, &pdn ); } rc = bdb_dn2id_add( be, tid, &pdn, e ); if( rc != 0 && rc != DB_KEYEXIST ) { diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index d6e4b300eb..997e969f1d 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -83,8 +83,7 @@ ldbm_back_add( if ( be_issuffix( be, &e->e_nname ) ) { pdn = slap_empty_bv; } else { - rc = dnParent( &e->e_nname, &pdn ); - /* dnParent always returns success */ + dnParent( &e->e_nname, &pdn ); } if( pdn.bv_len ) { diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index adb1ff6b72..a3b5ebe902 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -115,8 +115,8 @@ ldbm_back_delete( } /* delete from parent's id2children entry */ - if( !be_issuffix( be, &e->e_nname ) && dnParent( &e->e_nname, &pdn ) == LDAP_SUCCESS - && pdn.bv_len ) { + if( !be_issuffix( be, &e->e_nname ) && (dnParent( &e->e_nname, &pdn ), + pdn.bv_len) ) { if( (p = dn2entry_w( be, &pdn, NULL )) == NULL) { #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_ERR, diff --git a/servers/slapd/back-ldbm/dn2id.c b/servers/slapd/back-ldbm/dn2id.c index 64be1196bf..152ab7a7e3 100644 --- a/servers/slapd/back-ldbm/dn2id.c +++ b/servers/slapd/back-ldbm/dn2id.c @@ -74,17 +74,15 @@ dn2id_add( ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); if ( rc != -1 ) { - rc = dnParent( &ptr, &pdn ); - - if( rc == LDAP_SUCCESS ) { - pdn.bv_val[-1] = DN_ONE_PREFIX; - key.dsize = pdn.bv_len + 2; - key.dptr = pdn.bv_val - 1; - ptr = pdn; - ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex ); - rc = idl_insert_key( be, db, key, id ); - ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); - } + dnParent( &ptr, &pdn ); + + pdn.bv_val[-1] = DN_ONE_PREFIX; + key.dsize = pdn.bv_len + 2; + key.dptr = pdn.bv_val - 1; + ptr = pdn; + ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex ); + rc = idl_insert_key( be, db, key, id ); + ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); } } @@ -96,7 +94,7 @@ dn2id_add( ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); if( rc != 0 ) break; - rc = dnParent( &ptr, &pdn ); + dnParent( &ptr, &pdn ); key.dsize = pdn.bv_len + 2; key.dptr = pdn.bv_val - 1; ptr = pdn; @@ -314,18 +312,16 @@ dn2id_delete( (void) idl_delete_key( be, db, key, id ); ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); - rc = dnParent( &ptr, &pdn ); + dnParent( &ptr, &pdn ); - if( rc == LDAP_SUCCESS ) { - pdn.bv_val[-1] = DN_ONE_PREFIX; - key.dsize = pdn.bv_len + 2; - key.dptr = pdn.bv_val - 1; - ptr = pdn; + pdn.bv_val[-1] = DN_ONE_PREFIX; + key.dsize = pdn.bv_len + 2; + key.dptr = pdn.bv_val - 1; + ptr = pdn; - ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex ); - (void) idl_delete_key( be, db, key, id ); - ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); - } + ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex ); + (void) idl_delete_key( be, db, key, id ); + ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); } while ( rc != -1 && !be_issuffix( be, &ptr )) { @@ -335,7 +331,7 @@ dn2id_delete( (void) idl_delete_key( be, db, key, id ); ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex ); - rc = dnParent( &ptr, &pdn ); + dnParent( &ptr, &pdn ); key.dsize = pdn.bv_len + 2; key.dptr = pdn.bv_val - 1; ptr = pdn; @@ -415,8 +411,7 @@ dn2entry_rw( if( matched == NULL ) return NULL; /* entry does not exist - see how much of the dn does exist */ - if ( !be_issuffix( be, dn ) && dnParent( dn, &pdn ) == LDAP_SUCCESS - && pdn.bv_len ) { + if ( !be_issuffix( be, dn ) && (dnParent( dn, &pdn ), pdn.bv_len) ) { /* get entry with reader lock */ if ( (e = dn2entry_r( be, &pdn, matched )) != NULL ) { *matched = e; diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index e25275e2dd..61bdf574d5 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -884,10 +884,7 @@ glue_sub_init( ) gi->nodes * sizeof(gluenode)); } gi->n[gi->nodes].be = be; - if ( dnParent( be->be_nsuffix[0], &gi->n[gi->nodes].pdn ) - != LDAP_SUCCESS ) { - return -1; - } + dnParent( be->be_nsuffix[0], &gi->n[gi->nodes].pdn ); gi->nodes++; } if (gi) { @@ -895,10 +892,7 @@ glue_sub_init( ) gi = (glueinfo *)ch_realloc(gi, sizeof(glueinfo) + gi->nodes * sizeof(gluenode)); gi->n[gi->nodes].be = gi->be; - if ( dnParent( b1->be_nsuffix[0], &gi->n[gi->nodes].pdn ) - != LDAP_SUCCESS ) { - return -1; - } + dnParent( b1->be_nsuffix[0], &gi->n[gi->nodes].pdn ); gi->nodes++; b1->be_private = gi; b1->bd_info = bi; diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 9fa1b4a746..632b77b1ac 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -564,7 +564,7 @@ dnMatch( * note: the incoming dn is assumed to be normalized/prettyfied, * so that escaped rdn/ava separators are in '\'+hexpair form */ -int +void dnParent( struct berval *dn, struct berval *pdn ) @@ -576,7 +576,7 @@ dnParent( /* one-level dn */ if ( p == NULL ) { *pdn = slap_empty_bv; - return LDAP_SUCCESS; + return; } assert( DN_SEPARATOR( p[ 0 ] ) ); @@ -586,7 +586,7 @@ dnParent( pdn->bv_val = p; pdn->bv_len = dn->bv_len - (p - dn->bv_val); - return LDAP_SUCCESS; + return; } #ifdef SLAP_DN_MIGRATION diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 7465a0de30..98a880be92 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -404,7 +404,7 @@ LDAP_SLAPD_F (void) build_new_dn LDAP_P(( struct berval * parent_dn, struct berval * newrdn )); -LDAP_SLAPD_F (int) dnParent LDAP_P(( struct berval *dn, struct berval *pdn )); +LDAP_SLAPD_F (void) dnParent LDAP_P(( struct berval *dn, struct berval *pdn )); #ifdef HAVE_CYRUS_SASL #define SLAP_DN_MIGRATION 1 -- 2.39.5