andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From e10be9d331082ba331bc1f8f0fe161445cf41faa Mon Sep 17 00:00:00 2001
dc8c34
From: Noriko Hosoi <nhosoi@redhat.com>
dc8c34
Date: Mon, 29 Jul 2013 09:34:50 -0700
dc8c34
Subject: [PATCH 83/99] Ticket #47378 - fix recent compiler warnings
dc8c34
dc8c34
Description: This patch removes unused function compare_entries
dc8c34
in back-ldbm/sort.c.
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/47378
dc8c34
(cherry picked from commit 9737076aa97622ac5f25d59e86b350050e700f60)
dc8c34
(cherry picked from commit e0dad88902a3c4bd625c149e0f6b10f976c57a7a)
dc8c34
---
dc8c34
 ldap/servers/slapd/back-ldbm/sort.c | 139 +-----------------------------------
dc8c34
 1 file changed, 2 insertions(+), 137 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/slapd/back-ldbm/sort.c b/ldap/servers/slapd/back-ldbm/sort.c
dc8c34
index 6984467..7768737 100644
dc8c34
--- a/ldap/servers/slapd/back-ldbm/sort.c
dc8c34
+++ b/ldap/servers/slapd/back-ldbm/sort.c
dc8c34
@@ -469,141 +469,6 @@ int sort_attr_compare(struct berval ** value_a, struct berval ** value_b, value_
dc8c34
 
dc8c34
 }
dc8c34
 
dc8c34
-
dc8c34
-#if 0
dc8c34
-/* USE THE _SV VERSION NOW */
dc8c34
-
dc8c34
-/* Comparison routine, called by qsort.
dc8c34
- * The job here is to return the correct value
dc8c34
- * for the operation a < b
dc8c34
- * Returns:
dc8c34
- * <0 when  a < b
dc8c34
- * 0  when a == b
dc8c34
- * >0 when a > b
dc8c34
- */
dc8c34
-static int compare_entries(ID *id_a, ID *id_b, sort_spec *s,baggage_carrier *bc, int *error)
dc8c34
-{
dc8c34
-	/* We get passed the IDs, but need to fetch the entries in order to
dc8c34
-	 * perform the comparison .
dc8c34
-	 */
dc8c34
-	struct backentry *a = NULL;
dc8c34
-	struct backentry *b = NULL;
dc8c34
-	int result = 0;
dc8c34
-	sort_spec_thing *this_one = NULL;
dc8c34
-	int return_value = -1;
dc8c34
-	backend *be = bc->be;
dc8c34
-	ldbm_instance *inst = (ldbm_instance *) be->be_instance_info;
dc8c34
-	int err;
dc8c34
-
dc8c34
-	*error = 1;
dc8c34
-	a = id2entry(be,*id_a,NULL,&err;;
dc8c34
-	if (NULL == a) {
dc8c34
-		if (0 != err ) {
dc8c34
-			LDAPDebug(LDAP_DEBUG_ANY,"compare_entries db err %d\n",err,0,0);
dc8c34
-		}
dc8c34
-		/* Were up a creek without paddle here */
dc8c34
-		/* Best to log error and set some flag */
dc8c34
-		return 0;
dc8c34
-	}
dc8c34
-	b = id2entry(be,*id_b,NULL,&err;;
dc8c34
-	if (NULL == b) {
dc8c34
-		if (0 != err ) {
dc8c34
-			LDAPDebug(LDAP_DEBUG_ANY,"compare_entries db err %d\n",err,0,0);
dc8c34
-		}
dc8c34
-		return 0;
dc8c34
-	}
dc8c34
-	/* OK, now we have the entries, so we work our way down the attribute list comparing as we go */
dc8c34
-	for (this_one = (sort_spec_thing*)s; this_one ; this_one = this_one->next) {
dc8c34
-
dc8c34
-		char *type = this_one->type;
dc8c34
-		int order = this_one->order;
dc8c34
-		Slapi_Attr *attr_a = NULL;
dc8c34
-		Slapi_Attr *attr_b = NULL;
dc8c34
-		struct berval **value_a = NULL;
dc8c34
-		struct berval **value_b = NULL;
dc8c34
-
dc8c34
-		/* Get the two attribute values from the entries */
dc8c34
-		return_value = slapi_entry_attr_find(a->ep_entry,type,&attr_a);
dc8c34
-		return_value = slapi_entry_attr_find(b->ep_entry,type,&attr_b);
dc8c34
-		/* What do we do if one or more of the entries lacks this attribute ? */
dc8c34
-		/* if one lacks the attribute */
dc8c34
-		if (NULL == attr_a) {
dc8c34
-			/* then if the other does too, they're equal */
dc8c34
-			if (NULL == attr_b) {
dc8c34
-				result = 0;
dc8c34
-				continue;
dc8c34
-			} else
dc8c34
-			{
dc8c34
-				/* If one has the attribute, and the other
dc8c34
-				 * doesn't, the missing attribute is the
dc8c34
-				 * LARGER one.  (bug #108154)  -robey
dc8c34
-				 */
dc8c34
-				result = 1;
dc8c34
-				break;
dc8c34
-			}
dc8c34
-		}
dc8c34
-		if (NULL == attr_b) {
dc8c34
-			result = -1;
dc8c34
-			break;
dc8c34
-		}
dc8c34
-		/* Somewhere in here, we need to go sideways for match rule case 
dc8c34
-		 * we need to call the match rule plugin to get the attribute values
dc8c34
-		 * converted into ordering keys. Then we proceed as usual to use those,
dc8c34
-		 * but ensuring that we don't leak memory anywhere. This works as follows:
dc8c34
-		 * the code assumes that the attrs are references into the entry, so 
dc8c34
-		 * doesn't try to free them. We need to note at the right place that
dc8c34
-		 * we're on the matchrule path, and accordingly free the keys---this turns out
dc8c34
-		 * to be when we free the indexer */ 
dc8c34
-		if (NULL == s->matchrule) {
dc8c34
-			/* Non-match rule case */
dc8c34
-		    /* xxxPINAKI
dc8c34
-		       needs modification
dc8c34
-		       
dc8c34
-			value_a = attr_a->a_vals;
dc8c34
-			value_b = attr_b->a_vals;
dc8c34
-			*/
dc8c34
-		} else {
dc8c34
-			/* Match rule case */
dc8c34
-			struct berval **actual_value_b = NULL;
dc8c34
-			struct berval **temp_value = NULL;
dc8c34
-
dc8c34
-			/* xxxPINAKI
dc8c34
-			   needs modification
dc8c34
-			struct berval **actual_value_a = NULL;
dc8c34
-			   
dc8c34
-			actual_value_a = attr_a->a_vals;
dc8c34
-			actual_value_b = attr_b->a_vals;
dc8c34
-			matchrule_values_to_keys(s->mr_pb,actual_value_a,&temp_value);
dc8c34
-			*/
dc8c34
-			/* Now copy it, so the second call doesn't crap on it */
dc8c34
-			value_a = slapi_ch_bvecdup(temp_value); /* Really, we'd prefer to not call the chXXX variant...*/
dc8c34
-			matchrule_values_to_keys(s->mr_pb,actual_value_b,&value_b);
dc8c34
-		}
dc8c34
-		/* Compare them */
dc8c34
-		if (!order) {
dc8c34
-			result = sort_attr_compare(value_a, value_b, s->compare_fn);
dc8c34
-		} else {
dc8c34
-			/* If reverse, invert the sense of the comparison */
dc8c34
-			result = sort_attr_compare(value_b, value_a, s->compare_fn);
dc8c34
-		}
dc8c34
-		/* Time to free up the attribute allocated above */
dc8c34
-		if (NULL != s->matchrule) {
dc8c34
-			ber_bvecfree(value_a);
dc8c34
-		}
dc8c34
-		/* Are they equal ? */
dc8c34
-		if (0 != result) {
dc8c34
-			/* If not, we're done */
dc8c34
-			break;
dc8c34
-		} 
dc8c34
-		/* If so, proceed to the next attribute for comparison */
dc8c34
-	}
dc8c34
-	CACHE_RETURN(&inst->inst_cache,&a);
dc8c34
-	CACHE_RETURN(&inst->inst_cache,&b);
dc8c34
-	*error = 0;
dc8c34
-	return result;
dc8c34
-}
dc8c34
-#endif
dc8c34
-
dc8c34
 /* Comparison routine, called by qsort.
dc8c34
  * The job here is to return the correct value
dc8c34
  * for the operation a < b
dc8c34
@@ -631,7 +496,7 @@ static int compare_entries_sv(ID *id_a, ID *id_b, sort_spec *s,baggage_carrier *
dc8c34
 	a = id2entry(be,*id_a,&txn,&err;;
dc8c34
 	if (NULL == a) {
dc8c34
 		if (0 != err ) {
dc8c34
-			LDAPDebug(LDAP_DEBUG_TRACE,"compare_entries db err %d\n",err,0,0);
dc8c34
+			LDAPDebug(LDAP_DEBUG_TRACE,"compare_entries_sv db err %d\n",err,0,0);
dc8c34
 		}
dc8c34
 		/* Were up a creek without paddle here */
dc8c34
 		/* Best to log error and set some flag */
dc8c34
@@ -640,7 +505,7 @@ static int compare_entries_sv(ID *id_a, ID *id_b, sort_spec *s,baggage_carrier *
dc8c34
 	b = id2entry(be,*id_b,&txn,&err;;
dc8c34
 	if (NULL == b) {
dc8c34
 		if (0 != err ) {
dc8c34
-			LDAPDebug(LDAP_DEBUG_TRACE,"compare_entries db err %d\n",err,0,0);
dc8c34
+			LDAPDebug(LDAP_DEBUG_TRACE,"compare_entries_sv db err %d\n",err,0,0);
dc8c34
 		}
dc8c34
 		CACHE_RETURN(&inst->inst_cache,&a);
dc8c34
 		return 0;
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34