]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ldb: Slightly simplify ldb_dn_get_extended_linearized()
authorVolker Lendecke <vl@samba.org>
Tue, 14 Jul 2026 19:55:49 +0000 (21:55 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 30 Jul 2026 13:11:31 +0000 (13:11 +0000)
Return early with dn->ext_comp_num==0, no need to check further down again.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/ldb/common/ldb_dn.c

index 7596ce056f95f966423a0946d14eee5e167347ac..b29dc0f4de757eb42cbee55a7388473b0a31b99e 100644 (file)
@@ -849,6 +849,10 @@ char *ldb_dn_get_extended_linearized(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, int
        TYPESAFE_QSORT(dn->ext_components, dn->ext_comp_num,
                       ldb_dn_extended_component_compare);
 
+       if (dn->ext_comp_num == 0) {
+               return NULL;
+       }
+
        for (i = 0; i < dn->ext_comp_num; i++) {
                const struct ldb_dn_extended_syntax *ext_syntax;
                const char *name = dn->ext_components[i].name;
@@ -890,14 +894,10 @@ char *ldb_dn_get_extended_linearized(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, int
                talloc_free(val.data);
        }
 
-       if (dn->ext_comp_num && *linearized) {
+       if (*linearized) {
                talloc_asprintf_addbuf(&p, ";%s", linearized);
        }
 
-       if (!p) {
-               return NULL;
-       }
-
        return p;
 }