From: Kurt Zeilenga Date: Thu, 26 Jul 2001 01:08:00 +0000 (+0000) Subject: Misc cleanup of asserts X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1199 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d4df1af5907f55662efad3a6429ea1f29d310b3d;p=openldap Misc cleanup of asserts --- diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 7e14971f02..a0b1b3d70b 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -132,13 +132,13 @@ int octetStringIndexer( digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); - /* we should have at least one value at this point */ - assert( values != NULL && values[0] != NULL ); - for( i=0; values[i] != NULL; i++ ) { /* just count them */ } + /* we should have at least one value at this point */ + assert( i > 0 ); + keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); slen = strlen( syntax->ssyn_oid ); @@ -853,7 +853,6 @@ approxIndexer( return LDAP_SUCCESS; } - int approxFilter( slap_mask_t use, @@ -968,8 +967,10 @@ approxIndexer( char *s; for( i=0; values[i] != NULL; i++ ) { - /* just count them */ + /* empty - just count them */ } + + /* we should have at least one value at this point */ assert( i > 0 ); keys = (struct berval **)ch_malloc( sizeof( struct berval * ) * (i+1) ); @@ -1204,13 +1205,13 @@ int caseExactIndexer( digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); - /* we should have at least one value at this point */ - assert( values != NULL && values[0] != NULL ); - for( i=0; values[i] != NULL; i++ ) { - /* just count them */ + /* empty - just count them */ } + /* we should have at least one value at this point */ + assert( i > 0 ); + keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); slen = strlen( syntax->ssyn_oid ); @@ -1320,15 +1321,15 @@ int caseExactSubstringsIndexer( digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); - /* we should have at least one value at this point */ - assert( values != NULL && values[0] != NULL ); - nkeys=0; - /* create normalized copy of values */ for( i=0; values[i] != NULL; i++ ) { - /* empty */ + /* empty - just count them */ } + + /* we should have at least one value at this point */ + assert( i > 0 ); + nvalues = ch_malloc( sizeof( struct berval * ) * (i+1) ); for( i=0; values[i] != NULL; i++ ) { nvalues[i] = ber_bvstr( UTF8normalize( values[i]->bv_val, @@ -1829,13 +1830,13 @@ int caseIgnoreIndexer( digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); - /* we should have at least one value at this point */ - assert( values != NULL && values[0] != NULL ); - for( i=0; values[i] != NULL; i++ ) { - /* just count them */ + /* empty - just count them */ } + /* we should have at least one value at this point */ + assert( i > 0 ); + keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); slen = strlen( syntax->ssyn_oid ); @@ -1944,15 +1945,15 @@ int caseIgnoreSubstringsIndexer( digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); - /* we should have at least one value at this point */ - assert( values != NULL && values[0] != NULL ); - nkeys=0; - /* create normalized copy of values */ for( i=0; values[i] != NULL; i++ ) { - /* empty */ + /* empty - just count them */ } + + /* we should have at least one value at this point */ + assert( i > 0 ); + nvalues = ch_malloc( sizeof( struct berval * ) * (i+1) ); for( i=0; values[i] != NULL; i++ ) { nvalues[i] = ber_bvstr( UTF8normalize( values[i]->bv_val, @@ -2674,13 +2675,13 @@ int caseExactIA5Indexer( digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); - /* we should have at least one value at this point */ - assert( values != NULL && values[0] != NULL ); - for( i=0; values[i] != NULL; i++ ) { - /* just count them */ + /* empty - just count them */ } + /* we should have at least one value at this point */ + assert( i > 0 ); + keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); slen = strlen( syntax->ssyn_oid );