svn commit: samba r23551 - in branches/SAMBA_4_0/source: lib/registry lib/util librpc/rpc rpc_server/epmapper torture/basic

abartlet at samba.org abartlet at samba.org
Wed Jun 20 04:15:42 GMT 2007


Author: abartlet
Date: 2007-06-20 04:15:39 +0000 (Wed, 20 Jun 2007)
New Revision: 23551

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23551

Log:
Change data_blob_equal to data_blob_cmp, suitable for sorting with qsort().

Andrew Bartlett

Modified:
   branches/SAMBA_4_0/source/lib/registry/patchfile.c
   branches/SAMBA_4_0/source/lib/util/data_blob.c
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc.c
   branches/SAMBA_4_0/source/rpc_server/epmapper/rpc_epmapper.c
   branches/SAMBA_4_0/source/torture/basic/aliases.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/registry/patchfile.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/patchfile.c	2007-06-20 01:26:18 UTC (rev 23550)
+++ branches/SAMBA_4_0/source/lib/registry/patchfile.c	2007-06-20 04:15:39 UTC (rev 23551)
@@ -125,7 +125,7 @@
 			return error2;
 		}
 
-		if (W_ERROR_IS_OK(error2) && data_blob_equal(&v1->data, &v2->data))
+		if (W_ERROR_IS_OK(error2) && data_blob_cmp(&v1->data, &v2->data) == 0)
 			continue;
 
 		thiskey = diff_find_add_key(diff, oldkey->path);

Modified: branches/SAMBA_4_0/source/lib/util/data_blob.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util/data_blob.c	2007-06-20 01:26:18 UTC (rev 23550)
+++ branches/SAMBA_4_0/source/lib/util/data_blob.c	2007-06-20 04:15:39 UTC (rev 23551)
@@ -130,21 +130,23 @@
 /**
 check if two data blobs are equal
 **/
-_PUBLIC_ BOOL data_blob_equal(const DATA_BLOB *d1, const DATA_BLOB *d2)
+_PUBLIC_ int data_blob_cmp(const DATA_BLOB *d1, const DATA_BLOB *d2)
 {
-	if (d1->length != d2->length) {
-		return False;
+	int ret;
+	if (d1->data == NULL && d2->data != NULL) {
+		return -1;
 	}
+	if (d1->data != NULL && d2->data == NULL) {
+		return 1;
+	}
 	if (d1->data == d2->data) {
-		return True;
+		return d1->length - d2->length;
 	}
-	if (d1->data == NULL || d2->data == NULL) {
-		return False;
+	ret = memcmp(d1->data, d2->data, MIN(d1->length, d2->length));
+	if (ret == 0) {
+		return d1->length - d2->length;
 	}
-	if (memcmp(d1->data, d2->data, d1->length) == 0) {
-		return True;
-	}
-	return False;
+	return ret;
 }
 
 /**

Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc.c	2007-06-20 01:26:18 UTC (rev 23550)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc.c	2007-06-20 04:15:39 UTC (rev 23551)
@@ -1193,7 +1193,7 @@
 
 	blob2 = ndr_push_blob(push);
 
-	if (!data_blob_equal(&blob, &blob2)) {
+	if (data_blob_cmp(&blob, &blob2) != 0) {
 		DEBUG(3,("original:\n"));
 		dump_data(3, blob.data, blob.length);
 		DEBUG(3,("secondary:\n"));
@@ -1276,7 +1276,7 @@
 
 	blob2 = ndr_push_blob(push);
 
-	if (!data_blob_equal(&blob, &blob2)) {
+	if (data_blob_cmp(&blob, &blob2) != 0) {
 		DEBUG(3,("original:\n"));
 		dump_data(3, blob.data, blob.length);
 		DEBUG(3,("secondary:\n"));

Modified: branches/SAMBA_4_0/source/rpc_server/epmapper/rpc_epmapper.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/epmapper/rpc_epmapper.c	2007-06-20 01:26:18 UTC (rev 23550)
+++ branches/SAMBA_4_0/source/rpc_server/epmapper/rpc_epmapper.c	2007-06-20 04:15:39 UTC (rev 23551)
@@ -218,8 +218,8 @@
 
 	for (i=0;i<count;i++) {
 		if (
-			!data_blob_equal(&r->in.map_tower->tower.floors[0].lhs.lhs_data, 
-			&eps[i].ep.floors[0].lhs.lhs_data) 
+			data_blob_cmp(&r->in.map_tower->tower.floors[0].lhs.lhs_data, 
+			&eps[i].ep.floors[0].lhs.lhs_data) != 0 
 			|| transport != dcerpc_transport_by_tower(&eps[i].ep)) {
 			continue;
 		}

Modified: branches/SAMBA_4_0/source/torture/basic/aliases.c
===================================================================
--- branches/SAMBA_4_0/source/torture/basic/aliases.c	2007-06-20 01:26:18 UTC (rev 23550)
+++ branches/SAMBA_4_0/source/torture/basic/aliases.c	2007-06-20 04:15:39 UTC (rev 23551)
@@ -68,8 +68,8 @@
 	for (t2b=alias_blobs; t2b; t2b=t2b->next) {
 		for (t2b2=alias_blobs; t2b2; t2b2=t2b2->next) {
 			if (t2b->level >= t2b2->level) continue;
-			if (data_blob_equal(&t2b->params, &t2b2->params) &&
-			    data_blob_equal(&t2b->data, &t2b2->data)) {
+			if (data_blob_cmp(&t2b->params, &t2b2->params) == 0 &&
+			    data_blob_cmp(&t2b->data, &t2b2->data) == 0) {
 				torture_comment(tctx, 
 				"\tLevel %u (0x%x) and level %u (0x%x) are possible aliases\n", 
 				       t2b->level, t2b->level, t2b2->level, t2b2->level);



More information about the samba-cvs mailing list