From ef3cf096e76cc2e34c4cd42e11c436605ff2dec9 Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Wed, 20 Nov 2019 13:12:40 -0500 Subject: [PATCH] exec.c: get nodes_nb_alloc with one MAX calculation The purpose of these two MAX here is to get the maximum of these three variables: A: map->nodes_nb + nodes B: map->nodes_nb_alloc C: alloc_hint We can write it like MAX(A, B, C). Since the if condition says A > B, this means MAX(A, B, C) = MAX(A, C). This patch just simplify the calculation a bit. Backports commit c95cfd040078db8017f74fd3a4d6f798385d960c from qemu --- qemu/exec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qemu/exec.c b/qemu/exec.c index 498c0337..69838a36 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -150,8 +150,7 @@ static void tcg_commit(MemoryListener *listener); static void phys_map_node_reserve(struct uc_struct *uc, PhysPageMap *map, unsigned nodes) { if (map->nodes_nb + nodes > map->nodes_nb_alloc) { - map->nodes_nb_alloc = MAX(map->nodes_nb_alloc, uc->phys_map_node_alloc_hint); - map->nodes_nb_alloc = MAX(map->nodes_nb_alloc, map->nodes_nb + nodes); + map->nodes_nb_alloc = MAX(uc->phys_map_node_alloc_hint, map->nodes_nb + nodes); map->nodes = g_renew(Node, map->nodes, map->nodes_nb_alloc); uc->phys_map_node_alloc_hint = map->nodes_nb_alloc; }