From 99d4efc917699a9ad42d3b028581b46b1852eb4e Mon Sep 17 00:00:00 2001 From: Garming Sam Date: Tue, 24 Feb 2015 11:44:11 +1300 Subject: [PATCH] kcc: Factor out MAX_DWORD Signed-off-by: Garming Sam Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- python/samba/kcc_utils.py | 8 +++++--- source4/scripting/bin/samba_kcc | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/python/samba/kcc_utils.py b/python/samba/kcc_utils.py index 1e057d480fc..5b612ccce54 100644 --- a/python/samba/kcc_utils.py +++ b/python/samba/kcc_utils.py @@ -2315,8 +2315,10 @@ class InternalEdge(object): ################################################## -# Global Functions +# Global Functions and Variables ################################################## +MAX_DWORD = 2 ** 32 - 1 + def sort_dsa_by_guid(dsa1, dsa2): return cmp(dsa1.dsa_guid, dsa2.dsa_guid) @@ -2358,7 +2360,7 @@ def combine_repl_info(info_a, info_b, info_c): # Truncate to MAX_DWORD info_c.cost = info_a.cost + info_b.cost - if info_c.cost > 2 ** 32 - 1: - info_c.cost = 2 ** 32 -1 + if info_c.cost > MAX_DWORD: + info_c.cost = MAX_DWORD return True diff --git a/source4/scripting/bin/samba_kcc b/source4/scripting/bin/samba_kcc index 3c1e50ea439..0c346f09cc7 100755 --- a/source4/scripting/bin/samba_kcc +++ b/source4/scripting/bin/samba_kcc @@ -1697,7 +1697,7 @@ class KCC(object): v = edge.vertices[0] w = edge.vertices[1] if v.site is vid or w.site is vid: - if (v.is_black() or w.is_black()) and not v.dist_to_red == 2 ** 32 - 1: + if (v.is_black() or w.is_black()) and not v.dist_to_red == MAX_DWORD: edge.directed = True if w.dist_to_red < v.dist_to_red: @@ -2653,7 +2653,7 @@ def create_edge_set(graph, transport, site_link_bridge): def setup_vertices(graph): for v in graph.vertices: if v.is_white(): - v.repl_info.cost = 2 ** 32 - 1 + v.repl_info.cost = MAX_DWORD v.root = None v.component_id = None else: @@ -2686,7 +2686,7 @@ def setup_dijkstra(graph, edge_type, include_black, queue): if ((vertex.is_black() and not include_black) or edge_type not in vertex.accept_black or edge_type not in vertex.accept_red_red): - vertex.repl_info.cost = 2 ** 32 - 1 + vertex.repl_info.cost = MAX_DWORD vertex.root = None # NULL GUID vertex.demoted = True # Demoted appears not to be used else: @@ -2722,7 +2722,7 @@ def check_demote_vertex(vertex, edge_type): # Accepts neither red-red nor black edges, demote if edge_type not in vertex.accept_black and edge_type not in vertex.accept_red_red: - vertex.repl_info.cost = 2 ** 32 - 1 + vertex.repl_info.cost = MAX_DWORD vertex.root = None vertex.demoted = True # Demoted appears not to be used