]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
kcc: Factor out MAX_DWORD
authorGarming Sam <garming@catalyst.net.nz>
Mon, 23 Feb 2015 22:44:11 +0000 (11:44 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 28 May 2015 05:25:08 +0000 (07:25 +0200)
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/kcc_utils.py
source4/scripting/bin/samba_kcc

index 1e057d480fcafe4950f1911be4bbc1f2d2598133..5b612ccce54cb90eccbb92bc79365a28dc175c70 100644 (file)
@@ -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
index 3c1e50ea4391dc074b102530111329dd8efe8265..0c346f09cc7f41ea9c20a3b84f57b474a889d90b 100755 (executable)
@@ -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