Commit f8ebef07 authored by Howard Chu's avatar Howard Chu
Browse files

ITS#2496 use SLAP_PTRCMP for pointer comparisons

parent e73b0733
......@@ -29,7 +29,7 @@ ainfo_type_cmp(
{
const AttributeDescription *desc = v_desc;
const AttrInfo *a = v_a;
return desc - a->ai_desc;
return SLAP_PTRCMP(desc, a->ai_desc);
}
static int
......@@ -39,7 +39,7 @@ ainfo_cmp(
)
{
const AttrInfo *a = v_a, *b = v_b;
return a->ai_desc - b->ai_desc;
return SLAP_PTRCMP(a->ai_desc, b->ai_desc);
}
void
......
......@@ -122,8 +122,10 @@ ldap_back_bind(
}
if ( li->savecred ) {
if ( lc->cred.bv_val )
if ( lc->cred.bv_val ) {
memset( lc->cred.bv_val, 0, lc->cred.bv_len );
ch_free( lc->cred.bv_val );
}
ber_dupbv( &lc->cred, cred );
ldap_set_rebind_proc( lc->ld, ldap_back_rebind, lc );
}
......@@ -154,7 +156,7 @@ ldap_back_conn_cmp(
const struct ldapconn *lc1 = (const struct ldapconn *)c1;
const struct ldapconn *lc2 = (const struct ldapconn *)c2;
return ( ( lc1->conn < lc2->conn ) ? -1 : ( ( lc1->conn > lc2-> conn ) ? 1 : 0 ) );
return SLAP_PTRCMP(lc1->conn, lc2->conn);
}
/*
......
......@@ -29,7 +29,7 @@ ainfo_type_cmp(
{
const AttributeDescription *desc = v_desc;
const AttrInfo *a = v_a;
return desc - a->ai_desc;
return SLAP_PTRCMP(desc, a->ai_desc);
}
static int
......@@ -39,7 +39,7 @@ ainfo_cmp(
)
{
const AttrInfo *a = v_a, *b = v_b;
return a->ai_desc - b->ai_desc;
return SLAP_PTRCMP(a->ai_desc, b->ai_desc);
}
void
......
......@@ -97,8 +97,7 @@ meta_back_conn_cmp(
struct metaconn *lc1 = ( struct metaconn * )c1;
struct metaconn *lc2 = ( struct metaconn * )c2;
return ( ( lc1->conn < lc2->conn ) ? -1 :
( ( lc1->conn > lc2-> conn ) ? 1 : 0 ) );
return SLAP_PTRCMP( lc1->conn, lc2->conn );
}
/*
......
......@@ -29,7 +29,7 @@ static int
backsql_cmp_oc( const void *v_m1, const void *v_m2 )
{
const backsql_oc_map_rec *m1 = v_m1, *m2 = v_m2;
return ( m1->oc < m2->oc ? -1 : ( m1->oc > m2->oc ? 1 : 0 ) );
return SLAP_PTRCMP( m1->oc, m2->oc );
}
static int
......@@ -46,7 +46,7 @@ static int
backsql_cmp_attr( const void *v_m1, const void *v_m2 )
{
const backsql_at_map_rec *m1 = v_m1, *m2 = v_m2;
return ( m1->ad < m2->ad ? -1 : ( m1->ad > m2->ad ? 1 : 0 ) );
return SLAP_PTRCMP( m1->ad, m2->ad );
}
static int
......
......@@ -385,7 +385,7 @@ entry_free( Entry *e )
int
entry_cmp( Entry *e1, Entry *e2 )
{
return( e1 < e2 ? -1 : (e1 > e2 ? 1 : 0) );
return SLAP_PTRCMP( e1, e2 );
}
int
......@@ -393,9 +393,8 @@ entry_dn_cmp( const void *v_e1, const void *v_e2 )
{
/* compare their normalized UPPERCASED dn's */
const Entry *e1 = v_e1, *e2 = v_e2;
int rc = e1->e_nname.bv_len - e2->e_nname.bv_len;
if (rc) return rc;
return( strcmp( e1->e_ndn, e2->e_ndn ) );
return ber_bvcmp( &e1->e_nname, &e2->e_nname );
}
int
......
......@@ -1081,6 +1081,9 @@ LDAP_SLAPD_F (int) value_add_one LDAP_P((
BerVarray *vals,
struct berval *addval ));
/* assumes (x) > (y) returns 1 if true, 0 otherwise */
#define SLAP_PTRCMP(x, y) ((x) < (y) ? -1 : (x) > (y))
/*
* Other...
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment