From: Pierangelo Masarati Date: Fri, 18 Apr 2003 17:16:48 +0000 (+0000) Subject: use SLAP_PTRCMP X-Git-Tag: OPENLDAP_REL_ENG_2_2_0ALPHA~313 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=629885a269e086b0685aaec4ae12a71356f4a455;p=openldap use SLAP_PTRCMP --- diff --git a/servers/slapd/back-bdb/attr.c b/servers/slapd/back-bdb/attr.c index 6fbee25672..65a8cc215d 100644 --- a/servers/slapd/back-bdb/attr.c +++ b/servers/slapd/back-bdb/attr.c @@ -29,7 +29,7 @@ ainfo_type_cmp( { const AttributeDescription *desc = v_desc; const AttrInfo *a = v_a; - return (unsigned)desc - (unsigned)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 (unsigned)a->ai_desc - (unsigned)b->ai_desc; + return SLAP_PTRCMP(a->ai_desc, b->ai_desc); } void diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index 4ddaa1a793..73a86b3270 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -163,7 +163,7 @@ ldap_back_conn_cmp( /* For shared sessions, conn is NULL. Only explicitly * bound sessions will have non-NULL conn. */ - return (unsigned)lc1->conn - (unsigned)lc2->conn; + return SLAP_PTRCMP(lc1->conn, lc2->conn); } /* diff --git a/servers/slapd/back-ldbm/attr.c b/servers/slapd/back-ldbm/attr.c index 42ad3389b6..22f15d41f8 100644 --- a/servers/slapd/back-ldbm/attr.c +++ b/servers/slapd/back-ldbm/attr.c @@ -29,7 +29,7 @@ ainfo_type_cmp( { const AttributeDescription *desc = v_desc; const AttrInfo *a = v_a; - return (unsigned)desc - (unsigned)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 (unsigned)a->ai_desc - (unsigned)b->ai_desc; + return SLAP_PTRCMP(a->ai_desc, b->ai_desc); } void diff --git a/servers/slapd/back-meta/conn.c b/servers/slapd/back-meta/conn.c index ddc1031e66..b2f9f0969b 100644 --- a/servers/slapd/back-meta/conn.c +++ b/servers/slapd/back-meta/conn.c @@ -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 ); } /* diff --git a/servers/slapd/back-sql/schema-map.c b/servers/slapd/back-sql/schema-map.c index a4404c5b48..2d16f88c11 100644 --- a/servers/slapd/back-sql/schema-map.c +++ b/servers/slapd/back-sql/schema-map.c @@ -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 diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 61749ad06b..7f28205e3d 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -422,7 +422,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 @@ -430,9 +430,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 diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index fb4cceb805..fb52a43140 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1023,6 +1023,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... */