From: Wei Yang Date: Thu, 21 Mar 2019 08:25:55 +0000 (+0800) Subject: exec.c: add a check between constants to see whether we could skip X-Git-Tag: qemu-xen-4.14.0~395^2~23 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=526ca2360ea1cd947f74c8c6c38b91b9d6fcfdb5;p=qemu-xen.git exec.c: add a check between constants to see whether we could skip The maximum level is defined as P_L2_LEVELS and skip is defined with 6 bits, which means if P_L2_LEVELS < (1 << 6), skip never exceeds the boundary. Since this check is between two constants, which leverages compiler to optimize the code based on different configuration. Signed-off-by: Wei Yang Message-Id: <20190321082555.21118-7-richardw.yang@linux.intel.com> Signed-off-by: Paolo Bonzini --- diff --git a/exec.c b/exec.c index d1969bb894..b9511be096 100644 --- a/exec.c +++ b/exec.c @@ -324,7 +324,8 @@ static void phys_page_compact(PhysPageEntry *lp, Node *nodes) assert(valid_ptr < P_L2_SIZE); /* Don't compress if it won't fit in the # of bits we have. */ - if (lp->skip + p[valid_ptr].skip >= (1 << 6)) { + if (P_L2_LEVELS >= (1 << 6) && + lp->skip + p[valid_ptr].skip >= (1 << 6)) { return; }