[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha7-1610-g524a79b

Andrew Bartlett abartlet at samba.org
Thu May 14 00:35:04 GMT 2009


The branch, master has been updated
       via  524a79b73509a356293603af83b01c98e6175a9a (commit)
       via  aa5cee228875ebd6e2af57f9b3e42a9ceef621ea (commit)
       via  6df4aece1df6f0e24f75736999cda4b33d2d3750 (commit)
       via  5182b10b7a78df787ab229715c741c8240bc448f (commit)
       via  a89bee4c98819567c6e15c0cae32372e32e118f5 (commit)
      from  a13ba4347f92afc63497991210bc59e6bd2434d0 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 524a79b73509a356293603af83b01c98e6175a9a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu May 14 05:51:40 2009 +1000

    s4:nbtd Use str_list_make_single() to turn iname->wins_server into a list

commit aa5cee228875ebd6e2af57f9b3e42a9ceef621ea
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed May 13 22:20:10 2009 +1000

    s4:libnet Use str_list_make_single() in resolv code

commit 6df4aece1df6f0e24f75736999cda4b33d2d3750
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed May 13 17:13:57 2009 +1000

    dsdb:schema Use str_list_make_empty() to create an empty list

commit 5182b10b7a78df787ab229715c741c8240bc448f
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed May 13 16:54:44 2009 +1000

    s4:torture Use str_list_make_single where appropriate

commit a89bee4c98819567c6e15c0cae32372e32e118f5
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed May 13 16:49:34 2009 +1000

    Add new functions and tests: str_list_make_empty(), str_list_make_single()

-----------------------------------------------------------------------

Summary of changes:
 lib/util/tests/strlist.c               |   34 ++++++++++++++++++++++++++
 lib/util/util.h                        |   10 +++++++
 lib/util/util_strlist.c                |   41 ++++++++++++++++++++++++++++++++
 source4/dsdb/schema/schema_inferiors.c |   10 ++++----
 source4/libnet/libnet_lookup.c         |    2 +-
 source4/nbt_server/wins/winsclient.c   |    2 +-
 source4/torture/nbt/wins.c             |   20 +++++++-------
 7 files changed, 102 insertions(+), 17 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/tests/strlist.c b/lib/util/tests/strlist.c
index 8605102..3f6cf27 100644
--- a/lib/util/tests/strlist.c
+++ b/lib/util/tests/strlist.c
@@ -87,6 +87,38 @@ static bool test_list_copy(struct torture_context *tctx)
 	return true;
 }
 
+static bool test_list_make_empty(struct torture_context *tctx)
+{
+	char **result;
+
+	result = str_list_make_empty(tctx);
+	torture_assert(tctx, result, "str_list_make_empty() must not return NULL");
+	torture_assert(tctx, result[0] == NULL, "first element in str_list_make_empty() result must be NULL");
+
+	result = str_list_make(tctx, NULL, NULL);
+	torture_assert(tctx, result, "str_list_make() must not return NULL");
+	torture_assert(tctx, result[0] == NULL, "first element in str_list_make(ctx, NULL, NULL) result must be NULL");
+	
+	result = str_list_make(tctx, "", NULL);
+	torture_assert(tctx, result, "str_list_make() must not return NULL");
+	torture_assert(tctx, result[0] == NULL, "first element in str_list_make(ctx, "", NULL) result must be NULL");
+	
+	return true;
+}
+
+static bool test_list_make_single(struct torture_context *tctx)
+{
+	char **result;
+
+	result = str_list_make_single(tctx, "foo");
+
+	torture_assert(tctx, result, "str_list_make_single() must not return NULL");
+	torture_assert_str_equal(tctx, result[0], "foo", "element 0");
+	torture_assert(tctx, result[1] == NULL, "second element in result must be NULL");
+	
+	return true;
+}
+
 struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx)
 {
 	struct torture_suite *suite = torture_suite_create(mem_ctx, "STRLIST");
@@ -98,6 +130,8 @@ struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx)
 	}
 
 	torture_suite_add_simple_test(suite, "list_copy", test_list_copy);
+	torture_suite_add_simple_test(suite, "make_empty", test_list_make_empty);
+	torture_suite_add_simple_test(suite, "make_single", test_list_make_single);
 
 	return suite;
 }
diff --git a/lib/util/util.h b/lib/util/util.h
index f4c2b83..dab5ff9 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -397,6 +397,16 @@ _PUBLIC_ bool strequal(const char *s1, const char *s2);
 #endif
 
 /**
+  build an empty (only NULL terminated) list of strings (for expansion with str_list_add() etc)
+*/
+_PUBLIC_ char **str_list_make_empty(TALLOC_CTX *mem_ctx);
+
+/**
+  place the only element 'entry' into a new, NULL terminated string list
+*/
+_PUBLIC_ char **str_list_make_single(TALLOC_CTX *mem_ctx, const char *entry);
+
+/**
   build a null terminated list of strings from a input string and a
   separator list. The separator list must contain characters less than
   or equal to 0x2f for this to work correctly on multi-byte strings
diff --git a/lib/util/util_strlist.c b/lib/util/util_strlist.c
index 6936f18..2fcbe18 100644
--- a/lib/util/util_strlist.c
+++ b/lib/util/util_strlist.c
@@ -29,6 +29,47 @@
  */
 
 /**
+  build an empty (only NULL terminated) list of strings (for expansion with str_list_add() etc)
+*/
+_PUBLIC_ char **str_list_make_empty(TALLOC_CTX *mem_ctx)
+{
+	int num_elements = 0;
+	char **ret = NULL;
+
+	ret = talloc_array(mem_ctx, char *, 1);
+	if (ret == NULL) {
+		return NULL;
+	}
+
+	ret[0] = NULL;
+
+	return ret;
+}
+
+/**
+  place the only element 'entry' into a new, NULL terminated string list
+*/
+_PUBLIC_ char **str_list_make_single(TALLOC_CTX *mem_ctx, const char *entry)
+{
+	int num_elements = 0;
+	char **ret = NULL;
+
+	ret = talloc_array(mem_ctx, char *, 2);
+	if (ret == NULL) {
+		return NULL;
+	}
+
+	ret[0] = talloc_strdup(ret, entry);
+	if (!ret[0]) {
+		talloc_free(ret);
+		return NULL;
+	}
+	ret[1] = NULL;
+
+	return ret;
+}
+
+/**
   build a null terminated list of strings from a input string and a
   separator list. The separator list must contain characters less than
   or equal to 0x2f for this to work correctly on multi-byte strings
diff --git a/source4/dsdb/schema/schema_inferiors.c b/source4/dsdb/schema/schema_inferiors.c
index 28f44ab..fc1845b 100644
--- a/source4/dsdb/schema/schema_inferiors.c
+++ b/source4/dsdb/schema/schema_inferiors.c
@@ -42,7 +42,7 @@ static char **schema_supclasses(struct dsdb_schema *schema, struct dsdb_class *s
 		return schema_class->supclasses;
 	}
 
-	list = str_list_make(schema_class, NULL, NULL);
+	list = str_list_make_empty(schema_class);
 	if (list == NULL) {
 		DEBUG(0,(__location__ " out of memory\n"));
 		return NULL;
@@ -76,7 +76,7 @@ static char **schema_supclasses(struct dsdb_schema *schema, struct dsdb_class *s
  */
 static char **schema_subclasses(struct dsdb_schema *schema, TALLOC_CTX *mem_ctx, char **oclist)
 {
-	char **list = str_list_make(mem_ctx, NULL, NULL);
+	char **list = str_list_make_empty(mem_ctx);
 	int i;
 
 	for (i=0; oclist && oclist[i]; i++) {
@@ -94,7 +94,7 @@ static char **schema_posssuperiors(struct dsdb_schema *schema,
 				   struct dsdb_class *schema_class)
 {
 	if (schema_class->posssuperiors == NULL) {
-		char **list2 = str_list_make(schema_class, NULL, NULL);
+		char **list2 = str_list_make_empty(schema_class);
 		char **list3;
 		int i;
 
@@ -134,7 +134,7 @@ static void schema_create_subclasses(struct dsdb_schema *schema)
 		struct dsdb_class *schema_class2 = dsdb_class_by_lDAPDisplayName(schema, schema_class->subClassOf);
 		if (schema_class != schema_class2) {
 			if (schema_class2->subclasses_direct == NULL) {
-				schema_class2->subclasses_direct = str_list_make(schema_class2, NULL, NULL);
+				schema_class2->subclasses_direct = str_list_make_empty(schema_class2);
 			}
 			schema_class2->subclasses_direct = str_list_add_const(schema_class2->subclasses_direct, 
 									schema_class->lDAPDisplayName);
@@ -157,7 +157,7 @@ static void schema_fill_possible_inferiors(struct dsdb_schema *schema, struct ds
 		    && c2->objectClassCategory != 3
 		    && str_list_check(superiors, schema_class->lDAPDisplayName)) {
 			if (schema_class->possibleInferiors == NULL) {
-				schema_class->possibleInferiors = str_list_make(schema_class, NULL, NULL);
+				schema_class->possibleInferiors = str_list_make_empty(schema_class);
 			}
 			schema_class->possibleInferiors = str_list_add_const(schema_class->possibleInferiors,
 								       c2->lDAPDisplayName);
diff --git a/source4/libnet/libnet_lookup.c b/source4/libnet/libnet_lookup.c
index fc30782..ab26814 100644
--- a/source4/libnet/libnet_lookup.c
+++ b/source4/libnet/libnet_lookup.c
@@ -129,7 +129,7 @@ NTSTATUS libnet_Lookup_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
 	if (NT_STATUS_IS_OK(status)) {
 		s = talloc_get_type(c->private_data, struct lookup_state);
 
-		io->out.address = (const char **)str_list_make(mem_ctx, s->address, NULL);
+		io->out.address = (const char **)str_list_make_single(mem_ctx, s->address);
 		NT_STATUS_HAVE_NO_MEMORY(io->out.address);
 	}
 
diff --git a/source4/nbt_server/wins/winsclient.c b/source4/nbt_server/wins/winsclient.c
index 2546a26..94c354a 100644
--- a/source4/nbt_server/wins/winsclient.c
+++ b/source4/nbt_server/wins/winsclient.c
@@ -140,7 +140,7 @@ static void nbtd_wins_refresh(struct tevent_context *ev, struct tevent_timer *te
 
 	/* setup a wins name refresh request */
 	io.in.name            = iname->name;
-	io.in.wins_servers    = (const char **)str_list_make(tmp_ctx, iname->wins_server, NULL);
+	io.in.wins_servers    = (const char **)str_list_make_single(tmp_ctx, iname->wins_server);
 	io.in.wins_port       = lp_nbt_port(iface->nbtsrv->task->lp_ctx);
 	io.in.addresses       = nbtd_address_list(iface, tmp_ctx);
 	io.in.nb_flags        = iname->nb_flags;
diff --git a/source4/torture/nbt/wins.c b/source4/torture/nbt/wins.c
index c581a69..8c29f7e 100644
--- a/source4/torture/nbt/wins.c
+++ b/source4/torture/nbt/wins.c
@@ -117,8 +117,8 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
 		torture_comment(tctx, "register the name with a wrong address (makes the next request slow!)\n");
 		io.in.name = *name;
 		io.in.wins_port = lp_nbt_port(tctx->lp_ctx);
-		io.in.wins_servers = str_list_make(tctx, address, NULL);
-		io.in.addresses = str_list_make(tctx, "127.64.64.1", NULL);
+		io.in.wins_servers = str_list_make_single(tctx, address);
+		io.in.addresses = str_list_make_single(tctx, "127.64.64.1");
 		io.in.nb_flags = nb_flags;
 		io.in.ttl = 300000;
 
@@ -189,8 +189,8 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
 	torture_comment(tctx, "register the name correct address\n");
 	io.in.name = *name;
 	io.in.wins_port = lp_nbt_port(tctx->lp_ctx);
-	io.in.wins_servers = (const char **)str_list_make(tctx, address, NULL);
-	io.in.addresses = (const char **)str_list_make(tctx, myaddress, NULL);
+	io.in.wins_servers = (const char **)str_list_make_single(tctx, address);
+	io.in.addresses = (const char **)str_list_make_single(tctx, myaddress);
 	io.in.nb_flags = nb_flags;
 	io.in.ttl = 300000;
 	
@@ -262,8 +262,8 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
 	torture_comment(tctx, "refresh the name\n");
 	refresh.in.name = *name;
 	refresh.in.wins_port = lp_nbt_port(tctx->lp_ctx);
-	refresh.in.wins_servers = (const char **)str_list_make(tctx, address, NULL);
-	refresh.in.addresses = (const char **)str_list_make(tctx, myaddress, NULL);
+	refresh.in.wins_servers = (const char **)str_list_make_single(tctx, address);
+	refresh.in.addresses = (const char **)str_list_make_single(tctx, myaddress);
 	refresh.in.nb_flags = nb_flags;
 	refresh.in.ttl = 12345;
 	
@@ -311,8 +311,8 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
 		torture_comment(tctx, "register the name with a wrong address (makes the next request slow!)\n");
 		io.in.name = *name;
 		io.in.wins_port = lp_nbt_port(tctx->lp_ctx);
-		io.in.wins_servers = str_list_make(tctx, address, NULL);
-		io.in.addresses = str_list_make(tctx, "127.64.64.1", NULL);
+		io.in.wins_servers = str_list_make_single(tctx, address);
+		io.in.addresses = str_list_make_single(tctx, "127.64.64.1");
 		io.in.nb_flags = nb_flags;
 		io.in.ttl = 300000;
 	
@@ -333,8 +333,8 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
 	torture_comment(tctx, "refresh the name with the correct address\n");
 	refresh.in.name = *name;
 	refresh.in.wins_port = lp_nbt_port(tctx->lp_ctx);
-	refresh.in.wins_servers = str_list_make(tctx, address, NULL);
-	refresh.in.addresses = str_list_make(tctx, myaddress, NULL);
+	refresh.in.wins_servers = str_list_make_single(tctx, address);
+	refresh.in.addresses = str_list_make_single(tctx, myaddress);
 	refresh.in.nb_flags = nb_flags;
 	refresh.in.ttl = 12345;
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list