[SCM] Samba Shared Repository - branch master updated

Matthias Dieter Wallnöfer mdw at samba.org
Mon Mar 8 05:49:48 MST 2010


The branch, master has been updated
       via  4e16a28... LDB:common - Change counters to "unsigned" where appropriate
      from  30ff229... s4:LDB TDB index code - reintroduce accidentally removed code part

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


- Log -----------------------------------------------------------------
commit 4e16a285c7c34732ba95fb5ec201e6f11cf88bef
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Fri Nov 6 18:35:17 2009 +0100

    LDB:common - Change counters to "unsigned" where appropriate
    
    To count LDB objects use variables of type "unsigned (int)" or "long long int"
    on binary or downto searches.
    
    To count characters in strings use "size_t".
    
    To calculate differences between pointers use "ptrdiff_t".

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

Summary of changes:
 source4/lib/ldb/common/attrib_handlers.c |    4 +-
 source4/lib/ldb/common/ldb.c             |    4 +-
 source4/lib/ldb/common/ldb_attributes.c  |   15 +++++----
 source4/lib/ldb/common/ldb_controls.c    |   14 ++++----
 source4/lib/ldb/common/ldb_dn.c          |   46 +++++++++++++++++-------------
 source4/lib/ldb/common/ldb_ldif.c        |    2 +-
 source4/lib/ldb/common/ldb_match.c       |    4 +-
 source4/lib/ldb/common/ldb_modules.c     |   12 ++++----
 source4/lib/ldb/common/ldb_msg.c         |   20 +++++++------
 source4/lib/ldb/common/ldb_parse.c       |   16 +++++-----
 source4/lib/ldb/common/ldb_utf8.c        |    6 ++--
 11 files changed, 76 insertions(+), 67 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/lib/ldb/common/attrib_handlers.c b/source4/lib/ldb/common/attrib_handlers.c
index 4647075..2a2bd08 100644
--- a/source4/lib/ldb/common/attrib_handlers.c
+++ b/source4/lib/ldb/common/attrib_handlers.c
@@ -55,7 +55,7 @@ int ldb_handler_fold(struct ldb_context *ldb, void *mem_ctx,
 			    const struct ldb_val *in, struct ldb_val *out)
 {
 	char *s, *t;
-	int l;
+	size_t l;
 
 	if (!in || !out || !(in->data)) {
 		return -1;
@@ -456,7 +456,7 @@ static const struct ldb_schema_syntax ldb_standard_syntaxes[] = {
 const struct ldb_schema_syntax *ldb_standard_syntax_by_name(struct ldb_context *ldb,
 							    const char *syntax)
 {
-	int i;
+	unsigned int i;
 	unsigned num_handlers = sizeof(ldb_standard_syntaxes)/sizeof(ldb_standard_syntaxes[0]);
 	/* TODO: should be replaced with a binary search */
 	for (i=0;i<num_handlers;i++) {
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 94fd6cd..bbb3b79 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -665,7 +665,7 @@ int ldb_request_get_status(struct ldb_request *req)
 static void ldb_trace_request(struct ldb_context *ldb, struct ldb_request *req)
 {
 	TALLOC_CTX *tmp_ctx = talloc_new(req);
-	int i;
+	unsigned int i;
 
 	switch (req->operation) {
 	case LDB_SEARCH:
@@ -845,7 +845,7 @@ int ldb_search_default_callback(struct ldb_request *req,
 				struct ldb_reply *ares)
 {
 	struct ldb_result *res;
-	int n;
+	unsigned int n;
 
 	res = talloc_get_type(req->context, struct ldb_result);
 
diff --git a/source4/lib/ldb/common/ldb_attributes.c b/source4/lib/ldb/common/ldb_attributes.c
index 79c5dd6..13f4d32 100644
--- a/source4/lib/ldb/common/ldb_attributes.c
+++ b/source4/lib/ldb/common/ldb_attributes.c
@@ -49,7 +49,7 @@ int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb,
 					 unsigned flags,
 					 const struct ldb_schema_syntax *syntax)
 {
-	int i, n;
+	unsigned int i, n;
 	struct ldb_schema_attribute *a;
 
 	if (!syntax) {
@@ -122,7 +122,9 @@ static const struct ldb_schema_attribute *ldb_schema_attribute_by_name_internal(
 	struct ldb_context *ldb,
 	const char *name)
 {
-	int i, e, b = 0, r;
+	/* for binary search we need signed variables */
+	long long int i, e, b = 0;
+	int r;
 	const struct ldb_schema_attribute *def = &ldb_attribute_default;
 
 	/* as handlers are sorted, '*' must be the first if present */
@@ -135,7 +137,6 @@ static const struct ldb_schema_attribute *ldb_schema_attribute_by_name_internal(
 	e = ldb->schema.num_attributes - 1;
 
 	while (b <= e) {
-
 		i = (b + e) / 2;
 
 		r = ldb_attr_cmp(name, ldb->schema.attributes[i].name);
@@ -179,7 +180,7 @@ const struct ldb_schema_attribute *ldb_schema_attribute_by_name(struct ldb_conte
 void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name)
 {
 	const struct ldb_schema_attribute *a;
-	int i;
+	ptrdiff_t i;
 
 	a = ldb_schema_attribute_by_name_internal(ldb, name);
 	if (a == NULL || a->name == NULL) {
@@ -232,7 +233,7 @@ int ldb_setup_wellknown_attributes(struct ldb_context *ldb)
 		{ "ou", LDB_SYNTAX_DIRECTORY_STRING },
 		{ "objectClass", LDB_SYNTAX_OBJECTCLASS }
 	};
-	int i;
+	unsigned int i;
 	int ret;
 
 	for (i=0;i<ARRAY_SIZE(wellknown);i++) {
@@ -254,7 +255,7 @@ int ldb_dn_extended_add_syntax(struct ldb_context *ldb,
 			       unsigned flags,
 			       const struct ldb_dn_extended_syntax *syntax)
 {
-	int n;
+	unsigned int n;
 	struct ldb_dn_extended_syntax *a;
 
 	if (!syntax) {
@@ -284,7 +285,7 @@ int ldb_dn_extended_add_syntax(struct ldb_context *ldb,
 const struct ldb_dn_extended_syntax *ldb_dn_extended_syntax_by_name(struct ldb_context *ldb,
 								    const char *name)
 {
-	int i;
+	unsigned int i;
 	for (i=0; i < ldb->schema.num_dn_extended_syntax; i++) {
 		if (ldb_attr_cmp(ldb->schema.dn_extended_syntax[i].name, name) == 0) {
 			return &ldb->schema.dn_extended_syntax[i];
diff --git a/source4/lib/ldb/common/ldb_controls.c b/source4/lib/ldb/common/ldb_controls.c
index 8da43ab..ef0e06f 100644
--- a/source4/lib/ldb/common/ldb_controls.c
+++ b/source4/lib/ldb/common/ldb_controls.c
@@ -37,7 +37,7 @@
 /* returns NULL if not found */
 struct ldb_control *ldb_request_get_control(struct ldb_request *req, const char *oid)
 {
-	int i;
+	unsigned int i;
 
 	if (req->controls != NULL) {
 		for (i = 0; req->controls[i]; i++) {
@@ -56,7 +56,7 @@ struct ldb_control *ldb_request_get_control(struct ldb_request *req, const char
 /* returns NULL if not found */
 struct ldb_control *ldb_reply_get_control(struct ldb_reply *rep, const char *oid)
 {
-	int i;
+	unsigned int i;
 
 	if (rep->controls != NULL) {
 		for (i = 0; rep->controls[i]; i++) {
@@ -77,7 +77,7 @@ the "exclude" control */
 int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver)
 {
 	struct ldb_control **lcs;
-	int i, j;
+	unsigned int i, j;
 
 	*saver = req->controls;
 	for (i = 0; req->controls[i]; i++);
@@ -110,7 +110,7 @@ struct ldb_control **controls_except_specified(struct ldb_control **controls_in,
 					       struct ldb_control *exclude)
 {
 	struct ldb_control **lcs = NULL;
-	int i, j;
+	unsigned int i, j;
 
 	for (i = 0; controls_in && controls_in[i]; i++);
 
@@ -147,7 +147,7 @@ struct ldb_control **controls_except_specified(struct ldb_control **controls_in,
 /* return True if any, False if none */
 int check_critical_controls(struct ldb_control **controls)
 {
-	int i;
+	unsigned int i;
 
 	if (controls == NULL) {
 		return 0;
@@ -164,7 +164,7 @@ int check_critical_controls(struct ldb_control **controls)
 
 int ldb_request_add_control(struct ldb_request *req, const char *oid, bool critical, void *data)
 {
-	unsigned i, n;
+	unsigned int i, n;
 	struct ldb_control **ctrls;
 	struct ldb_control *ctrl;
 
@@ -238,7 +238,7 @@ int ldb_reply_add_control(struct ldb_reply *ares, const char *oid, bool critical
 
 struct ldb_control **ldb_parse_control_strings(struct ldb_context *ldb, void *mem_ctx, const char **control_strings)
 {
-	int i;
+	unsigned int i;
 	struct ldb_control **ctrl;
 
 	char *error_string = NULL;
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index eb7d122..d91e9d9 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -191,7 +191,7 @@ static int ldb_dn_escape_internal(char *dst, const char *src, int len)
 {
 	const char *p, *s;
 	char *d;
-	int l;
+	size_t l;
 
 	p = s = src;
 	d = dst;
@@ -297,8 +297,9 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
 	bool in_quote = false;
 	bool is_oid = false;
 	bool escape = false;
-	unsigned x;
-	int l, ret;
+	unsigned int x;
+	size_t l;
+	int ret;
 	char *parse_dn;
 	bool is_index;
 
@@ -740,7 +741,8 @@ bool ldb_dn_validate(struct ldb_dn *dn)
 
 const char *ldb_dn_get_linearized(struct ldb_dn *dn)
 {
-	int i, len;
+	unsigned int i;
+	size_t len;
 	char *d, *n;
 
 	if ( ! dn || ( dn->invalid)) return NULL;
@@ -806,7 +808,7 @@ char *ldb_dn_get_extended_linearized(void *mem_ctx, struct ldb_dn *dn, int mode)
 {
 	const char *linearized = ldb_dn_get_linearized(dn);
 	char *p = NULL;
-	int i;
+	unsigned int i;
 
 	if (!linearized) {
 		return NULL;
@@ -884,7 +886,7 @@ char *ldb_dn_get_extended_linearized(void *mem_ctx, struct ldb_dn *dn, int mode)
  */
 void ldb_dn_extended_filter(struct ldb_dn *dn, const char * const *accept)
 {
-	int i;
+	unsigned int i;
 	for (i=0; i<dn->ext_comp_num; i++) {
 		if (!ldb_attr_in_list(accept, dn->ext_components[i].name)) {
 			memmove(&dn->ext_components[i],
@@ -910,7 +912,8 @@ char *ldb_dn_alloc_linearized(void *mem_ctx, struct ldb_dn *dn)
 
 static bool ldb_dn_casefold_internal(struct ldb_dn *dn)
 {
-	int i, ret;
+	unsigned int i;
+	int ret;
 
 	if ( ! dn || dn->invalid) return false;
 
@@ -955,7 +958,8 @@ failed:
 
 const char *ldb_dn_get_casefold(struct ldb_dn *dn)
 {
-	int i, len;
+	unsigned int i;
+	size_t len;
 	char *d, *n;
 
 	if (dn->casefold) return dn->casefold;
@@ -1025,7 +1029,7 @@ char *ldb_dn_alloc_casefold(void *mem_ctx, struct ldb_dn *dn)
 int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn)
 {
 	int ret;
-	int n_base, n_dn;
+	long long int n_base, n_dn;
 
 	if ( ! base || base->invalid) return 1;
 	if ( ! dn || dn->invalid) return -1;
@@ -1111,7 +1115,8 @@ int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn)
 
 int ldb_dn_compare(struct ldb_dn *dn0, struct ldb_dn *dn1)
 {
-	int i, ret;
+	unsigned int i;
+	int ret;
 
 	if (( ! dn0) || dn0->invalid || ! dn1 || dn1->invalid) {
 		return -1;
@@ -1269,7 +1274,7 @@ struct ldb_dn *ldb_dn_copy(void *mem_ctx, struct ldb_dn *dn)
 	*new_dn = *dn;
 
 	if (dn->components) {
-		int i;
+		unsigned int i;
 
 		new_dn->components =
 			talloc_zero_array(new_dn,
@@ -1292,7 +1297,7 @@ struct ldb_dn *ldb_dn_copy(void *mem_ctx, struct ldb_dn *dn)
 	}
 
 	if (dn->ext_components) {
-		int i;
+		unsigned int i;
 
 		new_dn->ext_components =
 			talloc_zero_array(new_dn,
@@ -1358,7 +1363,7 @@ bool ldb_dn_add_base(struct ldb_dn *dn, struct ldb_dn *base)
 	}
 
 	if (dn->components) {
-		int i;
+		unsigned int i;
 
 		if ( ! ldb_dn_validate(base)) {
 			return false;
@@ -1480,7 +1485,8 @@ bool ldb_dn_add_child(struct ldb_dn *dn, struct ldb_dn *child)
 	}
 
 	if (dn->components) {
-		int n, i, j;
+		unsigned int n;
+		long long int i, j;
 
 		if ( ! ldb_dn_validate(child)) {
 			return false;
@@ -1588,7 +1594,7 @@ bool ldb_dn_add_child_fmt(struct ldb_dn *dn, const char *child_fmt, ...)
 
 bool ldb_dn_remove_base_components(struct ldb_dn *dn, unsigned int num)
 {
-	int i;
+	long long int i;
 
 	if ( ! ldb_dn_validate(dn)) {
 		return false;
@@ -1631,7 +1637,7 @@ bool ldb_dn_remove_base_components(struct ldb_dn *dn, unsigned int num)
 
 bool ldb_dn_remove_child_components(struct ldb_dn *dn, unsigned int num)
 {
-	int i, j;
+	unsigned int i, j;
 
 	if ( ! ldb_dn_validate(dn)) {
 		return false;
@@ -1706,7 +1712,7 @@ struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, struct ldb_dn *dn)
 
 */
 static char *ldb_dn_canonical(void *mem_ctx, struct ldb_dn *dn, int ex_format) {
-	int i;
+	long long int i;
 	TALLOC_CTX *tmpctx;
 	char *cracked = NULL;
 	const char *format = (ex_format ? "\n" : "/" );
@@ -1851,7 +1857,7 @@ int ldb_dn_set_component(struct ldb_dn *dn, int num,
 	dn->components[num].value = v;
 
 	if (dn->valid_case) {
-		int i;
+		unsigned int i;
 		for (i = 0; i < dn->comp_num; i++) {
 			LDB_FREE(dn->components[i].cf_name);
 			LDB_FREE(dn->components[i].cf_value.data);
@@ -1873,7 +1879,7 @@ int ldb_dn_set_component(struct ldb_dn *dn, int num,
 const struct ldb_val *ldb_dn_get_extended_component(struct ldb_dn *dn,
 						    const char *name)
 {
-	int i;
+	unsigned int i;
 	if ( ! ldb_dn_validate(dn)) {
 		return NULL;
 	}
@@ -1889,7 +1895,7 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn,
 				  const char *name, const struct ldb_val *val)
 {
 	struct ldb_dn_ext_component *p;
-	int i;
+	unsigned int i;
 	struct ldb_val v2;
 
 	if ( ! ldb_dn_validate(dn)) {
diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c
index 819caa7..8e1e165 100644
--- a/source4/lib/ldb/common/ldb_ldif.c
+++ b/source4/lib/ldb/common/ldb_ldif.c
@@ -219,7 +219,7 @@ int ldb_should_b64_encode(struct ldb_context *ldb, const struct ldb_val *val)
 static int fold_string(int (*fprintf_fn)(void *, const char *, ...), void *private_data,
 			const char *buf, size_t length, int start_pos)
 {
-	unsigned int i;
+	size_t i;
 	int total=0, ret;
 
 	for (i=0;i<length;i++) {
diff --git a/source4/lib/ldb/common/ldb_match.c b/source4/lib/ldb/common/ldb_match.c
index 4bd121a..74bc015 100644
--- a/source4/lib/ldb/common/ldb_match.c
+++ b/source4/lib/ldb/common/ldb_match.c
@@ -189,7 +189,7 @@ static int ldb_wildcard_compare(struct ldb_context *ldb,
 	struct ldb_val *chunk;
 	char *p, *g;
 	uint8_t *save_p = NULL;
-	int c = 0;
+	unsigned int c = 0;
 
 	a = ldb_schema_attribute_by_name(ldb, tree->u.substring.attr);
 
@@ -304,7 +304,7 @@ static int ldb_match_extended(struct ldb_context *ldb,
 			      const struct ldb_parse_tree *tree,
 			      enum ldb_scope scope)
 {
-	int i;
+	unsigned int i;
 	const struct {
 		const char *oid;
 		int (*comparator)(const struct ldb_val *, const struct ldb_val *);
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index 4cf5dc8..ce6031f 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -48,7 +48,7 @@ void ldb_set_modules_dir(struct ldb_context *ldb, const char *path)
 
 static char *ldb_modules_strdup_no_spaces(TALLOC_CTX *mem_ctx, const char *string)
 {
-	int i, len;
+	size_t i, len;
 	char *trimmed;
 
 	trimmed = talloc_strdup(mem_ctx, string);
@@ -79,7 +79,7 @@ const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *m
 	char **modules = NULL;
 	const char **m;
 	char *modstr, *p;
-	int i;
+	unsigned int i;
 
 	/* spaces not admitted */
 	modstr = ldb_modules_strdup_no_spaces(mem_ctx, string);
@@ -144,7 +144,7 @@ static const struct ldb_builtins {
 static ldb_connect_fn ldb_find_backend(const char *url)
 {
 	struct backends_list_entry *backend;
-	int i;
+	unsigned int i;
 
 	for (i = 0; builtins[i].backend_ops || builtins[i].module_ops; i++) {
 		if (builtins[i].backend_ops == NULL) continue;
@@ -262,7 +262,7 @@ int ldb_connect_backend(struct ldb_context *ldb,
 static const struct ldb_module_ops *ldb_find_module_ops(const char *name)
 {
 	struct ops_list_entry *e;
-	int i;
+	unsigned int i;
 
 	for (i = 0; builtins[i].backend_ops || builtins[i].module_ops; i++) {
 		if (builtins[i].module_ops == NULL) continue;
@@ -333,7 +333,7 @@ static void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name,
 int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, struct ldb_module *backend, struct ldb_module **out)
 {
 	struct ldb_module *module;
-	int i;
+	unsigned int i;
 
 	module = backend;
 
@@ -399,7 +399,7 @@ int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module)
 int ldb_load_modules(struct ldb_context *ldb, const char *options[])
 {
 	const char **modules = NULL;
-	int i;
+	unsigned int i;
 	int ret;
 	TALLOC_CTX *mem_ctx = talloc_new(ldb);
 	if (!mem_ctx) {
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index 3c5b64e..2d2b34d 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -476,7 +476,7 @@ struct ldb_message *ldb_msg_copy_shallow(TALLOC_CTX *mem_ctx,
 					 const struct ldb_message *msg)
 {
 	struct ldb_message *msg2;
-	int i;
+	unsigned int i;
 
 	msg2 = talloc(mem_ctx, struct ldb_message);
 	if (msg2 == NULL) return NULL;
@@ -506,7 +506,7 @@ struct ldb_message *ldb_msg_copy(TALLOC_CTX *mem_ctx,
 				 const struct ldb_message *msg)
 {
 	struct ldb_message *msg2;
-	int i, j;
+	unsigned int i, j;
 
 	msg2 = ldb_msg_copy_shallow(mem_ctx, msg);
 	if (msg2 == NULL) return NULL;
@@ -542,7 +542,7 @@ failed:
 struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, 
 					 const struct ldb_message *msg)
 {
-	int i;
+	unsigned int i;
 	struct ldb_message *msg2;
 
 	msg2 = ldb_msg_copy(ldb, msg);
@@ -640,7 +640,7 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb,
 int ldb_msg_sanity_check(struct ldb_context *ldb, 
 			 const struct ldb_message *msg)
 {
-	int i, j;
+	unsigned int i, j;
 
 	/* basic check on DN */
 	if (msg->dn == NULL) {
@@ -678,7 +678,8 @@ int ldb_msg_sanity_check(struct ldb_context *ldb,
 const char **ldb_attr_list_copy(TALLOC_CTX *mem_ctx, const char * const *attrs)
 {
 	const char **ret;
-	int i;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list