Skip to content
Snippets Groups Projects
Commit 2c7dae11 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

More argument handling updates

(don't check what we expect applications to check).
parent e958a4c7
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,9 @@ static void uncache_entry_or_req LDAP_P(( LDAP *ld, LDAP_CONST char *dn, ber_in
int
ldap_enable_cache( LDAP *ld, long timeout, ber_len_t maxmem )
{
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
#ifndef LDAP_NOCACHE
if ( ld->ld_cache == NULL ) {
if (( ld->ld_cache = (LDAPCache *)LDAP_MALLOC( sizeof( LDAPCache )))
......@@ -62,6 +65,9 @@ ldap_enable_cache( LDAP *ld, long timeout, ber_len_t maxmem )
void
ldap_disable_cache( LDAP *ld )
{
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
#ifndef LDAP_NOCACHE
if ( ld->ld_cache != NULL ) {
ld->ld_cache->lc_enabled = 0;
......@@ -74,6 +80,9 @@ ldap_disable_cache( LDAP *ld )
void
ldap_set_cache_options( LDAP *ld, unsigned long opts )
{
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
#ifndef LDAP_NOCACHE
if ( ld->ld_cache != NULL ) {
ld->ld_cache->lc_options = opts;
......@@ -85,6 +94,9 @@ ldap_set_cache_options( LDAP *ld, unsigned long opts )
void
ldap_destroy_cache( LDAP *ld )
{
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
#ifndef LDAP_NOCACHE
if ( ld->ld_cache != NULL ) {
ldap_flush_cache( ld );
......@@ -102,6 +114,9 @@ ldap_flush_cache( LDAP *ld )
int i;
LDAPMessage *m, *next;
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
#ifdef NEW_LOGGING
LDAP_LOG (( "cache", LDAP_LEVEL_ENTRY, "ldap_flush_cache\n" ));
#else
......@@ -134,6 +149,9 @@ ldap_flush_cache( LDAP *ld )
void
ldap_uncache_request( LDAP *ld, int msgid )
{
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
#ifndef LDAP_NOCACHE
#ifdef NEW_LOGGING
LDAP_LOG (( "cache", LDAP_LEVEL_ARGS,
......@@ -152,6 +170,10 @@ ldap_uncache_request( LDAP *ld, int msgid )
void
ldap_uncache_entry( LDAP *ld, LDAP_CONST char *dn )
{
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
assert( dn != NULL );
#ifndef LDAP_NOCACHE
#ifdef NEW_LOGGING
LDAP_LOG (( "cache", LDAP_LEVEL_ARGS,
......@@ -240,6 +262,9 @@ ldap_add_request_to_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request )
LDAPMessage *new;
ber_len_t len;
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
#ifdef NEW_LOGGING
LDAP_LOG (( "cache", LDAP_LEVEL_ENTRY, "ldap_add_request_to_cache\n" ));
#else
......@@ -288,6 +313,10 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result )
LDAPMessage *m, **mp, *req, *new, *prev;
int err, keep;
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
assert( result != NULL );
#ifdef NEW_LOGGING
LDAP_LOG (( "cache", LDAP_LEVEL_ARGS,
"ldap_add_result_to_cache: id %ld, type %ld\n",
......@@ -447,6 +476,10 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request )
int first, hash;
time_t c_time;
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
assert( request != NULL );
#ifdef NEW_LOGGING
LDAP_LOG (( "cache", LDAP_LEVEL_ENTRY, "ldap_check_cache\n" ));
#else
......
......@@ -131,6 +131,8 @@ ldap_compare(
int msgid;
struct berval bvalue;
assert( value != NULL );
bvalue.bv_val = (char *) value;
bvalue.bv_len = (value == NULL) ? 0 : strlen( value );
......@@ -171,6 +173,8 @@ ldap_compare_s(
{
struct berval bvalue;
assert( value != NULL );
bvalue.bv_val = (char *) value;
bvalue.bv_len = (value == NULL) ? 0 : strlen( value );
......
......@@ -38,6 +38,7 @@ ldap_int_put_controls(
LDAPControl *const *c;
assert( ld != NULL );
assert( LDAP_VALID(ld) );
assert( ber != NULL );
if( ctrls == NULL ) {
......@@ -414,6 +415,7 @@ ldap_create_control(
struct berval *bvalp;
assert( requestOID != NULL );
assert( ber != NULL );
assert( ctrlp != NULL );
ctrl = (LDAPControl *) LDAP_MALLOC( sizeof(LDAPControl) );
......@@ -452,6 +454,7 @@ int ldap_int_client_controls( LDAP *ld, LDAPControl **ctrls )
LDAPControl *const *c;
assert( ld != NULL );
assert( LDAP_VALID(ld) );
if( ctrls == NULL ) {
/* use default server controls */
......
......@@ -41,9 +41,8 @@ int ldap_dn2domain(
char *domain = NULL;
char **dn;
if( dn_in == NULL || domainp == NULL ) {
return -1;
}
assert( dn_in != NULL );
assert( domainp != NULL );
dn = ldap_explode_dn( dn_in, 0 );
......@@ -147,12 +146,12 @@ int ldap_domain2dn(
char *domain, *s, *tok_r, *dn;
size_t loc;
if (domain_in == NULL || dnp == NULL) {
return LDAP_NO_MEMORY;
}
assert( domain_in != NULL );
assert( dnp != NULL );
domain = LDAP_STRDUP(domain_in);
if (domain == NULL) {
return LDAP_NO_MEMORY;
return LDAP_NO_MEMORY;
}
dn = NULL;
loc = 0;
......
......@@ -29,10 +29,6 @@ ldap_first_entry( LDAP *ld, LDAPMessage *chain )
assert( LDAP_VALID( ld ) );
assert( chain != NULL );
if( ld == NULL || chain == NULL ) {
return NULL;
}
return chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY
? chain
: ldap_next_entry( ld, chain );
......@@ -45,11 +41,7 @@ ldap_next_entry( LDAP *ld, LDAPMessage *entry )
assert( LDAP_VALID( ld ) );
assert( entry != NULL );
if ( ld == NULL || entry == NULL ) {
return NULL;
}
for (
for(
entry = entry->lm_chain;
entry != NULL;
entry = entry->lm_chain )
......@@ -70,10 +62,6 @@ ldap_count_entries( LDAP *ld, LDAPMessage *chain )
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
if ( ld == NULL ) {
return -1;
}
for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
if( chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) {
i++;
......
......@@ -24,11 +24,8 @@ ldap_first_message( LDAP *ld, LDAPMessage *chain )
{
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
assert( chain != NULL );
if ( ld == NULL || chain == NULL ) {
return NULL;
}
return chain;
}
......@@ -37,12 +34,9 @@ ldap_next_message( LDAP *ld, LDAPMessage *msg )
{
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
assert( msg != NULL );
if ( ld == NULL || msg == NULL || msg->lm_chain == NULL ) {
return NULL;
}
return( msg->lm_chain );
return msg->lm_chain;
}
int
......@@ -53,10 +47,6 @@ ldap_count_messages( LDAP *ld, LDAPMessage *chain )
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
if ( ld == NULL ) {
return -1;
}
for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
i++;
}
......
......@@ -24,7 +24,7 @@ ldap_first_reference( LDAP *ld, LDAPMessage *chain )
{
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
assert( chain != NULL );
assert( chain != NULL );
return chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE
? chain
......@@ -36,7 +36,7 @@ ldap_next_reference( LDAP *ld, LDAPMessage *ref )
{
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
assert( ref != NULL );
assert( ref != NULL );
for (
ref = ref->lm_chain;
......@@ -58,13 +58,7 @@ ldap_count_references( LDAP *ld, LDAPMessage *chain )
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
assert( chain != NULL );
if ( ld == NULL ) {
return -1;
}
for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
if( chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) {
i++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment