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

[PATCH v2 06/13] libxenguest: complete loops in xc_map_domain_meminfo()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 5 Jul 2021 17:14:36 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sOcBB1u7iiUx62PemDoqgBpbGc1Bb2Zr3M+3XNGrMl8=; b=eiNnGiNm5NXjHKjhBsIkWcn+MNtqjAvqC4MpPgyz0R1+AQi36hcwdBpdoOz6KxjeganchWBiEdNit9oH9HNkhxDA2c636FyaWRZSZtqbL3p+xuUpBAMvx7iVX0y1rNlK1uHQ/8mXC8hN/qxlrCk3WqWsXxkAklPf9Fuv3xjkA6D4Rz+aXJ3JxP6VibwJhymi7dP3wfoKefrWK+yfAD5Q4AxCZNX6IQG6wOyRd00DFXlykjkrJpByNS74Gjt+NB064fMWsEKrhv0t5ylh7AUpfbZfpZNAAsUs0FQkhsBNZlgOn5ko3QFqjVQF5JHkqfi427IZsRU5/kOf1mNHekxxNw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AJeVtxo9ExmWSTBby4AsX50DdP0nFK7lP0mWnwtowEwr9gkPgzBjr/3PU1MpCdMIib2jV/RmUUzm2gjopj96l357AJ0DUPXFGaRYyS8mFHOmhoVAt/CexyvDNM+w4Z9OWZm8zgHIdW02DCO7JeQvC41vLR8IzQOWVpJ/zIX90EBmOzLCo4FadK4dFlI9cVIal0hKod3gWXMBqxwNgdmGlOf+e8K6KO3ggfofNPdtrbXWVNIoIKCKmTeY8xsYl3wsTvgPLZ2a82xluXnnGJJFAAQWMsZGxsAt9TzIR1q3riocJ6ldbH/VVfNHrtW4O6+l3VJqMbH8rZIFrBe2iwTh2w==
  • Authentication-results: xenproject.org; dkim=none (message not signed) header.d=none;xenproject.org; dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>
  • Delivery-date: Mon, 05 Jul 2021 15:14:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

minfo->p2m_size may have more than 31 significant bits. Change the
induction variable to unsigned long, and (largely for signed-ness
consistency) a helper variable to unsigned int. And while there also
avoid open-coding min().

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
v2: Use min().

--- a/tools/libs/guest/xg_domain.c
+++ b/tools/libs/guest/xg_domain.c
@@ -40,7 +40,7 @@ int xc_map_domain_meminfo(xc_interface *
     xc_dominfo_t info;
     shared_info_any_t *live_shinfo;
     xen_capabilities_info_t xen_caps = "";
-    int i;
+    unsigned long i;
 
     /* Only be initialized once */
     if ( minfo->pfn_type || minfo->p2m_table )
@@ -116,12 +116,11 @@ int xc_map_domain_meminfo(xc_interface *
     /* Retrieve PFN types in batches */
     for ( i = 0; i < minfo->p2m_size ; i+=1024 )
     {
-        int count = ((minfo->p2m_size - i ) > 1024 ) ?
-                        1024: (minfo->p2m_size - i);
+        unsigned int count = min(minfo->p2m_size - i, 1024UL);
 
         if ( xc_get_pfn_type_batch(xch, domid, count, minfo->pfn_type + i) )
         {
-            PERROR("Could not get %d-eth batch of PFN types", (i+1)/1024);
+            PERROR("Could not get batch %lu of PFN types", (i + 1) / 1024);
             goto failed;
         }
     }




 


Rackspace

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