[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] x86/shadow: split a nested max() invocation



commit 193c28c4653167f7e79bd0566c658d96757ae066
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon May 18 09:01:23 2026 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon May 18 09:01:23 2026 +0200

    x86/shadow: split a nested max() invocation
    
    Such nesting causes the inner instance to shadow the outer instance's
    macro-local variables, thus violating Misra C:2012 rule 5.3 ("An
    identifier declared in an inner scope shall not hide an identifier
    declared in an outer scope"). Use an intermediate variable for the
    inner invocation. No difference in generated code.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
---
 xen/arch/x86/mm/shadow/common.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c
index dd2d04d049..ed698fa90b 100644
--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -767,11 +767,12 @@ static unsigned int sh_min_allocation(const struct domain 
*d)
      * megabyte of RAM (for the p2m table, minimally enough for HVM's setting
      * up of slot zero and an LAPIC page), plus one for HVM's 1-to-1 pagetable.
      */
+    unsigned int extra = max(domain_tot_pages(d) / 256,
+                             is_hvm_domain(d) ? CONFIG_PAGING_LEVELS + 2 : 0U) 
+
+                         is_hvm_domain(d);
+
     return shadow_min_acceptable_pages(d) +
-           max(max(domain_tot_pages(d) / 256,
-                   is_hvm_domain(d) ? CONFIG_PAGING_LEVELS + 2 : 0U) +
-               is_hvm_domain(d),
-               d->arch.paging.p2m_pages);
+           max(extra, d->arch.paging.p2m_pages);
 }
 
 int shadow_set_allocation(struct domain *d, unsigned int pages, bool 
*preempted)
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.