s4:dsdb: Replace early ‘continue’ with ‘if’ statement (CID 1414738)
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Fri, 6 Oct 2023 01:33:16 +0000 (14:33 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 13 Oct 2023 02:18:31 +0000 (02:18 +0000)
A ‘continue’ statement creates the misleading impression that this loop
executes more than once.

This also avoids ‘mem_ctx’ being leaked.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/schema/schema_convert_to_ol.c

index 259d9b9f976eec209cc72f8e0d9fb254c5ee597b..013787e9f4c678d35fae0b612adc3cf58424359b 100644 (file)
@@ -49,7 +49,8 @@ static char *print_schema_recursive(char *append_to_string, struct dsdb_schema *
                return NULL;
        }
 
-       do {
+       /* We have been asked to skip some attributes/objectClasses */
+       if (attrs_skip == NULL || !str_list_check_ci(attrs_skip, objectclass->lDAPDisplayName)) {
                TALLOC_CTX *mem_ctx = talloc_new(append_to_string);
                const char *name = objectclass->lDAPDisplayName;
                const char *oid = objectclass->governsID_oid;
@@ -72,11 +73,6 @@ static char *print_schema_recursive(char *append_to_string, struct dsdb_schema *
                        return NULL;
                }
 
-               /* We have been asked to skip some attributes/objectClasses */
-               if (attrs_skip && str_list_check_ci(attrs_skip, name)) {
-                       continue;
-               }
-
                /* We might have been asked to remap this oid, due to a conflict */
                for (j=0; oid_map && oid_map[j].old_oid; j++) {
                        if (strcasecmp(oid, oid_map[j].old_oid) == 0) {
@@ -154,7 +150,7 @@ static char *print_schema_recursive(char *append_to_string, struct dsdb_schema *
                        return NULL;
                }
                talloc_free(mem_ctx);
-       } while (0);
+       }
 
 
        for (objectclass=schema->classes; objectclass; objectclass = objectclass->next) {