From: Tim Beale Date: Wed, 27 Sep 2017 23:01:34 +0000 (+1300) Subject: replmd: Change replmd_check_singleval_la_conflict() logic flow X-Git-Tag: tevent-0.9.34~147 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c83dffc6f1cc30be4cad404c4b5f5c3213d27b9f;p=thirdparty%2Fsamba.git replmd: Change replmd_check_singleval_la_conflict() logic flow Return immediately if there's no conflict, which reduces nesting. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13055 Signed-off-by: Tim Beale Reviewed-by: Garming Sam Reviewed-by: Andrew Bartlett --- diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 11275ddf044..f18415a137e 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -7332,38 +7332,38 @@ static int replmd_check_singleval_la_conflict(struct ldb_module *module, conflict_pdn = active_pdn; } - /* resolve any single-valued link conflicts */ - if (conflict_pdn != NULL) { - - DBG_WARNING("Link conflict for %s attribute on %s\n", - attr->lDAPDisplayName, ldb_dn_get_linearized(src_obj_dn)); + if (conflict_pdn == NULL) { + return LDB_SUCCESS; + } - if (replmd_link_update_is_newer(conflict_pdn, la)) { - DBG_WARNING("Using received value %s, over existing target %s\n", - ldb_dn_get_linearized(dsdb_dn->dn), - ldb_dn_get_linearized(conflict_pdn->dsdb_dn->dn)); + /* resolve any single-valued link conflicts */ + DBG_WARNING("Link conflict for %s attribute on %s\n", + attr->lDAPDisplayName, ldb_dn_get_linearized(src_obj_dn)); - ret = replmd_delete_link_value(module, replmd_private, - old_el, src_obj_dn, schema, - attr, seq_num, true, - &conflict_pdn->guid, - conflict_pdn->dsdb_dn, - conflict_pdn->v); + if (replmd_link_update_is_newer(conflict_pdn, la)) { + DBG_WARNING("Using received value %s, over existing target %s\n", + ldb_dn_get_linearized(dsdb_dn->dn), + ldb_dn_get_linearized(conflict_pdn->dsdb_dn->dn)); - if (ret != LDB_SUCCESS) { - return ret; - } - } else { - DBG_WARNING("Using existing target %s, over received value %s\n", - ldb_dn_get_linearized(conflict_pdn->dsdb_dn->dn), - ldb_dn_get_linearized(dsdb_dn->dn)); + ret = replmd_delete_link_value(module, replmd_private, old_el, + src_obj_dn, schema, attr, + seq_num, true, &conflict_pdn->guid, + conflict_pdn->dsdb_dn, + conflict_pdn->v); - /* - * we want to keep our existing active link and add the - * received link as inactive - */ - *add_as_inactive = true; + if (ret != LDB_SUCCESS) { + return ret; } + } else { + DBG_WARNING("Using existing target %s, over received value %s\n", + ldb_dn_get_linearized(conflict_pdn->dsdb_dn->dn), + ldb_dn_get_linearized(dsdb_dn->dn)); + + /* + * we want to keep our existing active link and add the + * received link as inactive + */ + *add_as_inactive = true; } return LDB_SUCCESS;