Commit 81ecb0b1 authored by Hallvard Furuseth's avatar Hallvard Furuseth
Browse files

assert expects int. (int)<nonnull ptr/long> can be 0. Use assert(arg!=0/NULL).

parent c2b65937
......@@ -155,7 +155,7 @@ ber_memfree_x( void *p, void *ctx )
return;
}
assert( ber_int_memory_fns->bmf_free );
assert( ber_int_memory_fns->bmf_free != 0 );
(*ber_int_memory_fns->bmf_free)( p, ctx );
}
......
......@@ -1206,7 +1206,7 @@ int ldap_pvt_sasl_mutex_lock(void *mutex)
return SASL_OK;
}
#else /* !LDAP_DEBUG_R_SASL */
assert( mutex );
assert( mutex != NULL );
#endif /* !LDAP_DEBUG_R_SASL */
return ldap_pvt_thread_mutex_lock( (ldap_pvt_thread_mutex_t *)mutex )
? SASL_FAIL : SASL_OK;
......@@ -1219,7 +1219,7 @@ int ldap_pvt_sasl_mutex_unlock(void *mutex)
return SASL_OK;
}
#else /* !LDAP_DEBUG_R_SASL */
assert( mutex );
assert( mutex != NULL );
#endif /* !LDAP_DEBUG_R_SASL */
return ldap_pvt_thread_mutex_unlock( (ldap_pvt_thread_mutex_t *)mutex )
? SASL_FAIL : SASL_OK;
......@@ -1232,7 +1232,7 @@ void ldap_pvt_sasl_mutex_dispose(void *mutex)
return;
}
#else /* !LDAP_DEBUG_R_SASL */
assert( mutex );
assert( mutex != NULL );
#endif /* !LDAP_DEBUG_R_SASL */
(void) ldap_pvt_thread_mutex_destroy( (ldap_pvt_thread_mutex_t *)mutex );
LDAP_FREE( mutex );
......
......@@ -179,7 +179,7 @@ ldap_perror( LDAP *ld, LDAP_CONST char *str )
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
assert( str );
assert( str != NULL );
e = ldap_int_error( ld->ld_errno );
......
......@@ -358,7 +358,7 @@ ldap_dn_normalize( LDAP_CONST char *dnin,
Debug( LDAP_DEBUG_TRACE, "ldap_dn_normalize\n", 0, 0, 0 );
assert( dnout );
assert( dnout != NULL );
*dnout = NULL;
......@@ -563,8 +563,8 @@ ldapava_new( const struct berval *attr, const struct berval *val,
{
LDAPAVA *ava;
assert( attr );
assert( val );
assert( attr != NULL );
assert( val != NULL );
ava = LDAP_MALLOCX( sizeof( LDAPAVA ) + attr->bv_len + 1, ctx );
......@@ -586,7 +586,7 @@ ldapava_new( const struct berval *attr, const struct berval *val,
void
ldapava_free( LDAPAVA *ava, void *ctx )
{
assert( ava );
assert( ava != NULL );
#if 0
/* ava's private must be freed by caller
......@@ -673,7 +673,7 @@ ldap_str2dn( LDAP_CONST char *str, LDAPDN *dn, unsigned flags )
{
struct berval bv;
assert( str );
assert( str != NULL );
bv.bv_len = strlen( str );
bv.bv_val = (char *) str;
......@@ -700,9 +700,9 @@ ldap_bv2dn_x( struct berval *bvin, LDAPDN *dn, unsigned flags, void *ctx )
char *str, *end;
struct berval bvtmp, *bv = &bvtmp;
assert( bvin );
assert( bvin->bv_val );
assert( dn );
assert( bvin != NULL );
assert( bvin->bv_val != NULL );
assert( dn != NULL );
*bv = *bvin;
str = bv->bv_val;
......@@ -911,7 +911,7 @@ ldap_str2rdn( LDAP_CONST char *str, LDAPRDN *rdn,
{
struct berval bv;
assert( str );
assert( str != NULL );
assert( str[ 0 ] != '\0' ); /* FIXME: is this required? */
bv.bv_len = strlen( str );
......@@ -949,11 +949,11 @@ ldap_bv2rdn_x( struct berval *bv, LDAPRDN *rdn,
char *str;
ber_len_t stoplen;
assert( bv );
assert( bv->bv_len );
assert( bv->bv_val );
assert( bv != NULL );
assert( bv->bv_len != 0 );
assert( bv->bv_val != NULL );
assert( rdn || flags & LDAP_DN_SKIP );
assert( n );
assert( n != NULL );
str = bv->bv_val;
stoplen = bv->bv_len;
......@@ -1435,9 +1435,9 @@ str2strval( const char *str, ber_len_t stoplen, struct berval *val, const char *
const char *p, *end, *startPos, *endPos = NULL;
ber_len_t len, escapes;
assert( str );
assert( val );
assert( next );
assert( str != NULL );
assert( val != NULL );
assert( next != NULL );
*next = NULL;
end = str + stoplen;
......@@ -1581,9 +1581,9 @@ DCE2strval( const char *str, struct berval *val, const char **next, unsigned fla
const char *p, *startPos, *endPos = NULL;
ber_len_t len, escapes;
assert( str );
assert( val );
assert( next );
assert( str != NULL );
assert( val != NULL );
assert( next != NULL );
*next = NULL;
......@@ -1666,9 +1666,9 @@ IA52strval( const char *str, struct berval *val, const char **next, unsigned fla
const char *p, *startPos, *endPos = NULL;
ber_len_t len, escapes;
assert( str );
assert( val );
assert( next );
assert( str != NULL );
assert( val != NULL );
assert( next != NULL );
*next = NULL;
......@@ -1742,9 +1742,9 @@ quotedIA52strval( const char *str, struct berval *val, const char **next, unsign
ber_len_t len;
unsigned escapes = 0;
assert( str );
assert( val );
assert( next );
assert( str != NULL );
assert( val != NULL );
assert( next != NULL );
*next = NULL;
......@@ -1832,8 +1832,8 @@ hexstr2bin( const char *str, char *c )
{
char c1, c2;
assert( str );
assert( c );
assert( str != NULL );
assert( c != NULL );
c1 = str[ 0 ];
c2 = str[ 1 ];
......@@ -1874,9 +1874,9 @@ hexstr2binval( const char *str, struct berval *val, const char **next, unsigned
ber_len_t len;
ber_len_t s, d;
assert( str );
assert( val );
assert( next );
assert( str != NULL );
assert( val != NULL );
assert( next != NULL );
*next = NULL;
......@@ -1976,8 +1976,8 @@ byte2hexpair( const char *val, char *pair )
{
static const char hexdig[] = "0123456789ABCDEF";
assert( val );
assert( pair );
assert( val != NULL );
assert( pair != NULL );
/*
* we assume the string has enough room for the hex encoding
......@@ -1998,8 +1998,8 @@ binval2hexstr( struct berval *val, char *str )
{
ber_len_t s, d;
assert( val );
assert( str );
assert( val != NULL );
assert( str != NULL );
if ( val->bv_len == 0 ) {
return( 0 );
......@@ -2031,8 +2031,8 @@ strval2strlen( struct berval *val, unsigned flags, ber_len_t *len )
int escaped_ascii_len = LDAP_DN_IS_PRETTY( flags ) ? 2 : 3;
#endif /* PRETTY_ESCAPE */
assert( val );
assert( len );
assert( val != NULL );
assert( len != NULL );
*len = 0;
if ( val->bv_len == 0 ) {
......@@ -2109,9 +2109,9 @@ strval2str( struct berval *val, char *str, unsigned flags, ber_len_t *len )
{
ber_len_t s, d, end;
assert( val );
assert( str );
assert( len );
assert( val != NULL );
assert( str != NULL );
assert( len != NULL );
if ( val->bv_len == 0 ) {
*len = 0;
......@@ -2208,8 +2208,8 @@ strval2IA5strlen( struct berval *val, unsigned flags, ber_len_t *len )
ber_len_t l;
char *p;
assert( val );
assert( len );
assert( val != NULL );
assert( len != NULL );
*len = 0;
if ( val->bv_len == 0 ) {
......@@ -2250,9 +2250,9 @@ strval2IA5str( struct berval *val, char *str, unsigned flags, ber_len_t *len )
{
ber_len_t s, d, end;
assert( val );
assert( str );
assert( len );
assert( val != NULL );
assert( str != NULL );
assert( len != NULL );
if ( val->bv_len == 0 ) {
*len = 0;
......@@ -2298,8 +2298,8 @@ strval2DCEstrlen( struct berval *val, unsigned flags, ber_len_t *len )
ber_len_t l;
char *p;
assert( val );
assert( len );
assert( val != NULL );
assert( len != NULL );
*len = 0;
if ( val->bv_len == 0 ) {
......@@ -2338,9 +2338,9 @@ strval2DCEstr( struct berval *val, char *str, unsigned flags, ber_len_t *len )
{
ber_len_t s, d;
assert( val );
assert( str );
assert( len );
assert( val != NULL );
assert( str != NULL );
assert( len != NULL );
if ( val->bv_len == 0 ) {
*len = 0;
......@@ -2384,8 +2384,8 @@ strval2ADstrlen( struct berval *val, unsigned flags, ber_len_t *len )
ber_len_t l;
char *p;
assert( val );
assert( len );
assert( val != NULL );
assert( len != NULL );
*len = 0;
if ( val->bv_len == 0 ) {
......@@ -2424,9 +2424,9 @@ strval2ADstr( struct berval *val, char *str, unsigned flags, ber_len_t *len )
{
ber_len_t s, d;
assert( val );
assert( str );
assert( len );
assert( val != NULL );
assert( str != NULL );
assert( len != NULL );
if ( val->bv_len == 0 ) {
*len = 0;
......@@ -2477,9 +2477,9 @@ dn2domain( LDAPDN dn, struct berval *bv, int pos, int *iRDN )
/* we are guaranteed there's enough memory in str */
/* sanity */
assert( dn );
assert( bv );
assert( iRDN );
assert( dn != NULL );
assert( bv != NULL );
assert( iRDN != NULL );
assert( *iRDN >= 0 );
str = bv->bv_val + pos;
......@@ -2488,10 +2488,10 @@ dn2domain( LDAPDN dn, struct berval *bv, int pos, int *iRDN )
LDAPRDN rdn;
LDAPAVA *ava;
assert( dn[ i ] );
assert( dn[ i ] != NULL );
rdn = dn[ i ];
assert( rdn[ 0 ] );
assert( rdn[ 0 ] != NULL );
ava = rdn[ 0 ];
if ( !LDAP_DN_IS_RDN_DC( rdn ) ) {
......@@ -2678,8 +2678,8 @@ rdn2UFNstrlen( LDAPRDN rdn, unsigned flags, ber_len_t *len )
int iAVA;
ber_len_t l = 0;
assert( rdn );
assert( len );
assert( rdn != NULL );
assert( len != NULL );
*len = 0;
......@@ -2757,8 +2757,8 @@ rdn2ADstrlen( LDAPRDN rdn, unsigned flags, ber_len_t *len )
int iAVA;
ber_len_t l = 0;
assert( rdn );
assert( len );
assert( rdn != NULL );
assert( len != NULL );
*len = 0;
......@@ -2838,7 +2838,7 @@ ldap_rdn2str( LDAPRDN rdn, char **str, unsigned flags )
struct berval bv;
int rc;
assert( str );
assert( str != NULL );
if((flags & LDAP_DN_FORMAT_MASK) == LDAP_DN_FORMAT_LBER) {
return LDAP_PARAM_ERROR;
......@@ -2861,7 +2861,7 @@ ldap_rdn2bv_x( LDAPRDN rdn, struct berval *bv, unsigned flags, void *ctx )
int rc, back;
ber_len_t l;
assert( bv );
assert( bv != NULL );
bv->bv_len = 0;
bv->bv_val = NULL;
......@@ -2971,7 +2971,7 @@ int ldap_dn2str( LDAPDN dn, char **str, unsigned flags )
struct berval bv;
int rc;
assert( str );
assert( str != NULL );
if((flags & LDAP_DN_FORMAT_MASK) == LDAP_DN_FORMAT_LBER) {
return LDAP_PARAM_ERROR;
......@@ -2997,7 +2997,7 @@ int ldap_dn2bv_x( LDAPDN dn, struct berval *bv, unsigned flags, void *ctx )
int ( *sv2l ) ( struct berval *v, unsigned f, ber_len_t *l );
int ( *sv2s ) ( struct berval *v, char *s, unsigned f, ber_len_t *l );
assert( bv );
assert( bv != NULL );
bv->bv_len = 0;
bv->bv_val = NULL;
......@@ -3356,7 +3356,7 @@ ldap_X509dn2bv( void *x509_name, struct berval *bv, LDAPDN_rewrite_func *func,
struct berval Val;
assert( bv );
assert( bv != NULL );
bv->bv_len = 0;
bv->bv_val = NULL;
......
......@@ -138,7 +138,7 @@ ldap_parse_passwordpolicy_control(
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
assert( ctrl );
assert( ctrl != NULL );
/* Create a BerElement from the berval returned in the control. */
ber = ber_init(&ctrl->ldctl_value);
......
......@@ -187,8 +187,8 @@ chkResponseList(
tmp = lm;
}
} else {
assert(lm->lm_chain_tail);
assert(lm->lm_chain_tail->lm_chain);
assert(lm->lm_chain_tail != NULL);
assert(lm->lm_chain_tail->lm_chain != NULL);
if ((lm->lm_chain_tail->lm_chain->lm_msgtype
== LDAP_RES_SEARCH_ENTRY) ||
(lm->lm_chain_tail->lm_chain->lm_msgtype
......@@ -222,7 +222,7 @@ chkResponseList(
if ( all == LDAP_MSG_ONE && lm->lm_chain != NULL ) {
lm->lm_chain->lm_next = lm->lm_next;
lm->lm_chain->lm_chain_tail = ( lm->lm_chain_tail != lm ) ? lm->lm_chain_tail : lm->lm_chain;
assert(lm->lm_chain->lm_chain_tail);
assert(lm->lm_chain->lm_chain_tail != NULL);
lm->lm_chain = NULL;
lm->lm_chain_tail = NULL;
}
......@@ -868,8 +868,8 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
assert(l->lm_chain_tail == l);
l->lm_chain = newmsg;
} else {
assert(l->lm_chain_tail);
assert(l->lm_chain_tail->lm_chain);
assert(l->lm_chain_tail != NULL);
assert(l->lm_chain_tail->lm_chain != NULL);
if ((l->lm_chain_tail->lm_chain->lm_msgtype
== LDAP_RES_SEARCH_ENTRY) ||
(l->lm_chain_tail->lm_chain->lm_msgtype
......
......@@ -126,7 +126,7 @@ ldap_pvt_str2upperbv( char *str, struct berval *bv )
{
char *s = NULL;
assert( bv );
assert( bv != NULL );
/* to upper */
if ( str ) {
......@@ -161,7 +161,7 @@ ldap_pvt_str2lowerbv( char *str, struct berval *bv )
{
char *s = NULL;
assert( bv );
assert( bv != NULL );
/* to lower */
if ( str ) {
......
......@@ -53,7 +53,7 @@ static const char* skip_url_prefix LDAP_P((
int ldap_pvt_url_scheme2proto( const char *scheme )
{
assert( scheme );
assert( scheme != NULL );
if( scheme == NULL ) {
return -1;
......@@ -81,7 +81,7 @@ int ldap_pvt_url_scheme2proto( const char *scheme )
int ldap_pvt_url_scheme_port( const char *scheme, int port )
{
assert( scheme );
assert( scheme != NULL );
if( port ) return port;
if( scheme == NULL ) return port;
......@@ -110,7 +110,7 @@ int ldap_pvt_url_scheme_port( const char *scheme, int port )
int
ldap_pvt_url_scheme2tls( const char *scheme )
{
assert( scheme );
assert( scheme != NULL );
if( scheme == NULL ) {
return -1;
......@@ -804,7 +804,7 @@ ldap_url_parse_ext( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
return LDAP_URL_ERR_BADSCHEME;
}
assert( scheme );
assert( scheme != NULL );
/* make working copy of the remainder of the URL */
url = LDAP_STRDUP( url_tmp );
......
......@@ -389,9 +389,9 @@ ldif_must_b64_encode_register( LDAP_CONST char *name, LDAP_CONST char *oid )
int i;
ber_len_t len;
assert( must_b64_encode );
assert( name );
assert( oid );
assert( must_b64_encode != NULL );
assert( name != NULL );
assert( oid != NULL );
len = strlen( name );
......@@ -444,7 +444,7 @@ ldif_must_b64_encode_release( void )
{
int i;
assert( must_b64_encode );
assert( must_b64_encode != NULL );
if ( must_b64_encode == default_must_b64_encode ) {
return;
......@@ -470,8 +470,8 @@ ldif_must_b64_encode( LDAP_CONST char *s )
int i;
struct berval bv;
assert( must_b64_encode );
assert( s );
assert( must_b64_encode != NULL );
assert( s != NULL );
ber_str2bv( s, 0, 0, &bv );
......
......@@ -433,7 +433,7 @@ rewrite_context_free(
{
struct rewrite_context *context = (struct rewrite_context *)tmp;
assert( tmp );
assert( tmp != NULL );
rewrite_context_destroy( &context );
}
......@@ -446,12 +446,12 @@ rewrite_context_destroy(
struct rewrite_context *context;
struct rewrite_rule *r;
assert( pcontext );
assert( *pcontext );
assert( pcontext != NULL );
assert( *pcontext != NULL );
context = *pcontext;
assert( context->lc_rule );
assert( context->lc_rule != NULL );
for ( r = context->lc_rule->lr_next; r; ) {
struct rewrite_rule *cr = r;
......@@ -463,7 +463,7 @@ rewrite_context_destroy(
free( context->lc_rule );
context->lc_rule = NULL;
assert( context->lc_name );
assert( context->lc_name != NULL );
free( context->lc_name );
context->lc_name = NULL;
......
......@@ -339,8 +339,8 @@ map_ldap_destroy(
{
struct ldap_map_data *data;
assert( pmap );
assert( *pmap );
assert( pmap != NULL );
assert( *pmap != NULL );
data = ( struct ldap_map_data * )(*pmap)->lb_private;
......
......@@ -438,7 +438,7 @@ rewrite_builtin_map_free(
{
struct rewrite_builtin_map *map = ( struct rewrite_builtin_map * )tmp;
assert( map );
assert( map != NULL );
switch ( map->lb_type ) {
case REWRITE_BUILTIN_MAP_LDAP:
......@@ -461,8 +461,8 @@ rewrite_map_destroy(
{
struct rewrite_map *map;
assert( pmap );
assert( *pmap );
assert( pmap != NULL );
assert( *pmap != NULL );
map = *pmap;
......
......@@ -72,8 +72,8 @@ destroy_action(
{
struct rewrite_action *action;
assert( paction );
assert( *paction );
assert( paction != NULL );
assert( *paction != NULL );
action = *paction;
......@@ -462,8 +462,8 @@ rewrite_rule_destroy(
struct rewrite_rule *rule;
struct rewrite_action *action;
assert( prule );
assert( *prule );
assert( prule != NULL );
assert( *prule != NULL );
rule = *prule;
......
......@@ -177,7 +177,7 @@ rewrite_session_return(
struct rewrite_session *session
)
{
assert( session );
assert( session != NULL );
ldap_pvt_thread_mutex_unlock( &session->ls_mutex );
}