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
This commit is contained in:
Wei Yang 2019-11-20 13:12:40 -05:00 committed by Lioncash
parent 4274315278
commit ef3cf096e7
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -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;
}