summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2009-10-17 22:25:12 +0200
committerAndrew Bartlett <abartlet@samba.org>2009-12-01 16:48:02 +1100
commit7be99d373578f42ac47e67ef1b95a2409cecc184 (patch)
treeae131b29dec2cff2836e942a6acbab27507102aa /source4/dsdb
parent012494b8005b621642ec98d51d067378f8e10421 (diff)
downloadsamba-7be99d373578f42ac47e67ef1b95a2409cecc184.tar.gz
samba-7be99d373578f42ac47e67ef1b95a2409cecc184.tar.bz2
samba-7be99d373578f42ac47e67ef1b95a2409cecc184.zip
s4:schema - Make some more (result) variables const and fix up warnings with "discard_const_p"
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/schema/schema.h8
-rw-r--r--source4/dsdb/schema/schema_inferiors.c117
2 files changed, 72 insertions, 53 deletions
diff --git a/source4/dsdb/schema/schema.h b/source4/dsdb/schema/schema.h
index fa687d0728..186f5d5ddb 100644
--- a/source4/dsdb/schema/schema.h
+++ b/source4/dsdb/schema/schema.h
@@ -138,10 +138,10 @@ struct dsdb_class {
bool isDefunct;
bool systemOnly;
- char **supclasses;
- char **subclasses;
- char **subclasses_direct;
- char **posssuperiors;
+ const char **supclasses;
+ const char **subclasses;
+ const char **subclasses_direct;
+ const char **posssuperiors;
uint32_t subClassOf_id;
uint32_t *systemAuxiliaryClass_ids;
uint32_t *auxiliaryClass_ids;
diff --git a/source4/dsdb/schema/schema_inferiors.c b/source4/dsdb/schema/schema_inferiors.c
index 23cd43d701..d6fc1cfe5a 100644
--- a/source4/dsdb/schema/schema_inferiors.c
+++ b/source4/dsdb/schema/schema_inferiors.c
@@ -34,15 +34,16 @@
/*
create the SUPCLASSES() list
*/
-static char **schema_supclasses(struct dsdb_schema *schema, struct dsdb_class *schema_class)
+static const char **schema_supclasses(const struct dsdb_schema *schema,
+ struct dsdb_class *schema_class)
{
- char **list;
+ const char **list;
if (schema_class->supclasses) {
return schema_class->supclasses;
}
- list = str_list_make_empty(schema_class);
+ list = const_str_list(str_list_make_empty(schema_class));
if (list == NULL) {
DEBUG(0,(__location__ " out of memory\n"));
return NULL;
@@ -56,13 +57,11 @@ static char **schema_supclasses(struct dsdb_schema *schema, struct dsdb_class *s
}
if (schema_class->subClassOf) {
+ const struct dsdb_class *schema_class2 = dsdb_class_by_lDAPDisplayName(schema, schema_class->subClassOf);
const char **list2;
- list = str_list_add_const(list, schema_class->subClassOf);
+ list = str_list_add_const(list, schema_class->subClassOf);
- list2 = schema_supclasses(schema,
- discard_const_p(struct dsdb_class,
- dsdb_class_by_lDAPDisplayName(schema,
- schema_class->subClassOf)));
+ list2 = schema_supclasses(schema, discard_const_p(struct dsdb_class, schema_class2));
list = str_list_append_const(list, list2);
}
@@ -75,13 +74,15 @@ static char **schema_supclasses(struct dsdb_schema *schema, struct dsdb_class *s
this one is used internally
matches SUBCLASSES() python function
*/
-static char **schema_subclasses(struct dsdb_schema *schema, TALLOC_CTX *mem_ctx, char **oclist)
+static const char **schema_subclasses(const struct dsdb_schema *schema,
+ TALLOC_CTX *mem_ctx,
+ const char **oclist)
{
- char **list = str_list_make_empty(mem_ctx);
+ const char **list = const_str_list(str_list_make_empty(mem_ctx));
int i;
for (i=0; oclist && oclist[i]; i++) {
- struct dsdb_class *schema_class = dsdb_class_by_lDAPDisplayName(schema, oclist[i]);
+ const struct dsdb_class *schema_class = dsdb_class_by_lDAPDisplayName(schema, oclist[i]);
if (!schema_class) {
DEBUG(0, ("ERROR: Unable to locate subClass: '%s'\n", oclist[i]));
continue;
@@ -95,24 +96,25 @@ static char **schema_subclasses(struct dsdb_schema *schema, TALLOC_CTX *mem_ctx,
/*
equivalent of the POSSSUPERIORS() python function
*/
-static char **schema_posssuperiors(struct dsdb_schema *schema,
- struct dsdb_class *schema_class)
+static const char **schema_posssuperiors(const struct dsdb_schema *schema,
+ struct dsdb_class *schema_class)
{
if (schema_class->posssuperiors == NULL) {
- char **list2 = str_list_make_empty(schema_class);
- char **list3;
+ const char **list2 = const_str_list(str_list_make_empty(schema_class));
+ const char **list3;
int i;
list2 = str_list_append_const(list2, schema_class->systemPossSuperiors);
list2 = str_list_append_const(list2, schema_class->possSuperiors);
list3 = schema_supclasses(schema, schema_class);
for (i=0; list3 && list3[i]; i++) {
- struct dsdb_class *class2 = dsdb_class_by_lDAPDisplayName(schema, list3[i]);
+ const struct dsdb_class *class2 = dsdb_class_by_lDAPDisplayName(schema, list3[i]);
if (!class2) {
DEBUG(0, ("ERROR: Unable to locate supClass: '%s'\n", list3[i]));
continue;
}
- list2 = str_list_append_const(list2, schema_posssuperiors(schema, class2));
+ list2 = str_list_append_const(list2, schema_posssuperiors(schema,
+ discard_const_p(struct dsdb_class, class2)));
}
list2 = str_list_append_const(list2, schema_subclasses(schema, list2, list2));
@@ -122,14 +124,16 @@ static char **schema_posssuperiors(struct dsdb_schema *schema,
return schema_class->posssuperiors;
}
-static char **schema_subclasses_recurse(struct dsdb_schema *schema, struct dsdb_class *schema_class)
+static const char **schema_subclasses_recurse(const struct dsdb_schema *schema,
+ struct dsdb_class *schema_class)
{
- char **list = str_list_copy_const(schema_class, schema_class->subclasses_direct);
+ const char **list = str_list_copy_const(schema_class, schema_class->subclasses_direct);
int i;
for (i=0;list && list[i]; i++) {
- struct dsdb_class *schema_class2 = dsdb_class_by_lDAPDisplayName(schema, list[i]);
+ const struct dsdb_class *schema_class2 = dsdb_class_by_lDAPDisplayName(schema, list[i]);
if (schema_class != schema_class2) {
- list = str_list_append_const(list, schema_subclasses_recurse(schema, schema_class2));
+ list = str_list_append_const(list, schema_subclasses_recurse(schema,
+ discard_const_p(struct dsdb_class, schema_class2)));
}
}
return list;
@@ -137,37 +141,40 @@ static char **schema_subclasses_recurse(struct dsdb_schema *schema, struct dsdb_
/* Walk down the subClass tree, setting a higher index as we go down
* each level. top is 1, subclasses of top are 2, etc */
-void schema_subclasses_order_recurse(struct dsdb_schema *schema, struct dsdb_class *schema_class, int order)
+void schema_subclasses_order_recurse(const struct dsdb_schema *schema,
+ struct dsdb_class *schema_class,
+ const int order)
{
const char **list = schema_class->subclasses_direct;
int i;
schema_class->subClass_order = order;
for (i=0;list && list[i]; i++) {
- struct dsdb_class *schema_class2 = dsdb_class_by_lDAPDisplayName(schema, list[i]);
- schema_subclasses_order_recurse(schema, schema_class2, order+1);
+ const struct dsdb_class *schema_class2 = dsdb_class_by_lDAPDisplayName(schema, list[i]);
+ schema_subclasses_order_recurse(schema, discard_const_p(struct dsdb_class, schema_class2), order+1);
}
return;
}
-static int schema_create_subclasses(struct dsdb_schema *schema)
+static int schema_create_subclasses(const struct dsdb_schema *schema)
{
struct dsdb_class *schema_class, *top;
for (schema_class=schema->classes; schema_class; schema_class=schema_class->next) {
- struct dsdb_class *schema_class2 = dsdb_class_by_lDAPDisplayName(schema, schema_class->subClassOf);
+ struct dsdb_class *schema_class2 = discard_const_p(struct dsdb_class,
+ dsdb_class_by_lDAPDisplayName(schema, schema_class->subClassOf));
if (schema_class2 == NULL) {
DEBUG(0,("ERROR: no subClassOf for '%s'\n", schema_class->lDAPDisplayName));
return LDB_ERR_OPERATIONS_ERROR;
}
if (schema_class2 && schema_class != schema_class2) {
if (schema_class2->subclasses_direct == NULL) {
- schema_class2->subclasses_direct = str_list_make_empty(schema_class2);
+ schema_class2->subclasses_direct = const_str_list(str_list_make_empty(schema_class2));
if (!schema_class2->subclasses_direct) {
return LDB_ERR_OPERATIONS_ERROR;
}
}
- schema_class2->subclasses_direct = str_list_add_const(schema_class2->subclasses_direct,
- schema_class->lDAPDisplayName);
+ schema_class2->subclasses_direct = str_list_add_const(schema_class2->subclasses_direct,
+ schema_class->lDAPDisplayName);
}
}
@@ -178,7 +185,7 @@ static int schema_create_subclasses(struct dsdb_schema *schema)
schema_class->subClass_order = 0;
}
- top = dsdb_class_by_lDAPDisplayName(schema, "top");
+ top = discard_const_p(struct dsdb_class, dsdb_class_by_lDAPDisplayName(schema, "top"));
if (!top) {
DEBUG(0,("ERROR: no 'top' class in loaded schema\n"));
return LDB_ERR_OPERATIONS_ERROR;
@@ -188,40 +195,42 @@ static int schema_create_subclasses(struct dsdb_schema *schema)
return LDB_SUCCESS;
}
-static void schema_fill_possible_inferiors(struct dsdb_schema *schema, struct dsdb_class *schema_class)
+static void schema_fill_possible_inferiors(const struct dsdb_schema *schema,
+ struct dsdb_class *schema_class)
{
struct dsdb_class *c2;
for (c2=schema->classes; c2; c2=c2->next) {
- char **superiors = schema_posssuperiors(schema, c2);
+ const char **superiors = schema_posssuperiors(schema, c2);
if (c2->systemOnly == false
&& c2->objectClassCategory != 2
&& c2->objectClassCategory != 3
&& str_list_check(superiors, schema_class->lDAPDisplayName)) {
if (schema_class->possibleInferiors == NULL) {
- schema_class->possibleInferiors = str_list_make_empty(schema_class);
+ schema_class->possibleInferiors = const_str_list(str_list_make_empty(schema_class));
}
schema_class->possibleInferiors = str_list_add_const(schema_class->possibleInferiors,
- c2->lDAPDisplayName);
+ c2->lDAPDisplayName);
}
}
schema_class->possibleInferiors = str_list_unique(schema_class->possibleInferiors);
}
-static void schema_fill_system_possible_inferiors(struct dsdb_schema *schema, struct dsdb_class *schema_class)
+static void schema_fill_system_possible_inferiors(const struct dsdb_schema *schema,
+ struct dsdb_class *schema_class)
{
struct dsdb_class *c2;
for (c2=schema->classes; c2; c2=c2->next) {
- char **superiors = schema_posssuperiors(schema, c2);
+ const char **superiors = schema_posssuperiors(schema, c2);
if (c2->objectClassCategory != 2
&& c2->objectClassCategory != 3
&& str_list_check(superiors, schema_class->lDAPDisplayName)) {
if (schema_class->systemPossibleInferiors == NULL) {
- schema_class->systemPossibleInferiors = str_list_make_empty(schema_class);
+ schema_class->systemPossibleInferiors = const_str_list(str_list_make_empty(schema_class));
}
schema_class->systemPossibleInferiors = str_list_add_const(schema_class->systemPossibleInferiors,
- c2->lDAPDisplayName);
+ c2->lDAPDisplayName);
}
}
schema_class->systemPossibleInferiors = str_list_unique(schema_class->systemPossibleInferiors);
@@ -230,11 +239,14 @@ static void schema_fill_system_possible_inferiors(struct dsdb_schema *schema, st
/*
fill in a string class name from a governs_ID
*/
-static void schema_fill_from_class_one(struct dsdb_schema *schema, struct dsdb_class *c,
- const char **s, uint32_t id)
+static void schema_fill_from_class_one(const struct dsdb_schema *schema,
+ const struct dsdb_class *c,
+ const char **s,
+ const uint32_t id)
{
if (*s == NULL && id != 0) {
- struct dsdb_class *c2 = dsdb_class_by_governsID_id(schema, id);
+ const struct dsdb_class *c2 =
+ dsdb_class_by_governsID_id(schema, id);
if (c2) {
*s = c2->lDAPDisplayName;
}
@@ -244,15 +256,18 @@ static void schema_fill_from_class_one(struct dsdb_schema *schema, struct dsdb_c
/*
fill in a list of string class names from a governs_ID list
*/
-static void schema_fill_from_class_list(struct dsdb_schema *schema, struct dsdb_class *c,
- const char ***s, uint32_t *ids)
+static void schema_fill_from_class_list(const struct dsdb_schema *schema,
+ const struct dsdb_class *c,
+ const char ***s,
+ const uint32_t *ids)
{
if (*s == NULL && ids != NULL) {
int i;
for (i=0;ids[i];i++) ;
*s = talloc_array(c, const char *, i+1);
for (i=0;ids[i];i++) {
- struct dsdb_class *c2 = dsdb_class_by_governsID_id(schema, ids[i]);
+ const struct dsdb_class *c2 =
+ dsdb_class_by_governsID_id(schema, ids[i]);
if (c2) {
(*s)[i] = c2->lDAPDisplayName;
} else {
@@ -266,15 +281,18 @@ static void schema_fill_from_class_list(struct dsdb_schema *schema, struct dsdb_
/*
fill in a list of string attribute names from a attributeID list
*/
-static void schema_fill_from_attribute_list(struct dsdb_schema *schema, struct dsdb_class *c,
- const char ***s, uint32_t *ids)
+static void schema_fill_from_attribute_list(const struct dsdb_schema *schema,
+ const struct dsdb_class *c,
+ const char ***s,
+ const uint32_t *ids)
{
if (*s == NULL && ids != NULL) {
int i;
for (i=0;ids[i];i++) ;
*s = talloc_array(c, const char *, i+1);
for (i=0;ids[i];i++) {
- struct dsdb_attribute *a = dsdb_attribute_by_attributeID_id(schema, ids[i]);
+ const struct dsdb_attribute *a =
+ dsdb_attribute_by_attributeID_id(schema, ids[i]);
if (a) {
(*s)[i] = a->lDAPDisplayName;
} else {
@@ -288,7 +306,7 @@ static void schema_fill_from_attribute_list(struct dsdb_schema *schema, struct d
/*
if the schema came from DRS then some attributes will be setup as IDs
*/
-static void schema_fill_from_ids(struct dsdb_schema *schema)
+static void schema_fill_from_ids(const struct dsdb_schema *schema)
{
struct dsdb_class *c;
for (c=schema->classes; c; c=c->next) {
@@ -304,7 +322,7 @@ static void schema_fill_from_ids(struct dsdb_schema *schema)
}
}
-int schema_fill_constructed(struct dsdb_schema *schema)
+int schema_fill_constructed(const struct dsdb_schema *schema)
{
int ret;
struct dsdb_class *schema_class;
@@ -332,5 +350,6 @@ int schema_fill_constructed(struct dsdb_schema *schema)
schema_class->subclasses = NULL;
schema_class->posssuperiors = NULL;
}
+
return LDB_SUCCESS;
}