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

[Xen-devel] [PATCH 4/4 v3] xenconsole: Define and use a macro XEN_INVALID_PFN instead of -1



xenconsole will use a new macro XEN_INVALID_PFN instead of -1 for initializing 
ring-ref.
Since the type of ring_ref is changed to xen_pfn_t (which is an unsigned value) 
assigning -1
appeared to be confusing. For clarity, XEN_INVALID_PFN is introduced.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@xxxxxxxxxx>
---
CC: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Julien Grall <julien.grall@xxxxxxx>

This patch is as per the review of commit fa1f157
    libxl: Fix the bug introduced in commit "libxl: use correct type

 tools/console/daemon/io.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 1839973..aa291db 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -62,6 +62,8 @@
 /* Duration of each time period in ms */
 #define RATE_LIMIT_PERIOD 200
 
+#define XEN_INVALID_PFN (~(xen_pfn_t)0)
+
 extern int log_reload;
 extern int log_guest;
 extern int log_hv;
@@ -658,12 +660,12 @@ static void console_unmap_interface(struct console *con)
 {
        if (con->interface == NULL)
                return;
-       if (xgt_handle && con->ring_ref == -1)
+       if (xgt_handle && con->ring_ref == XEN_INVALID_PFN)
                xengnttab_unmap(xgt_handle, con->interface, 1);
        else
                munmap(con->interface, XC_PAGE_SIZE);
        con->interface = NULL;
-       con->ring_ref = -1;
+       con->ring_ref = XEN_INVALID_PFN;
 }
  
 static int console_create_ring(struct console *con)
@@ -698,7 +700,7 @@ static int console_create_ring(struct console *con)
        free(type);
 
        /* If using ring_ref and it has changed, remap */
-       if (ring_ref != con->ring_ref && con->ring_ref != -1)
+       if (ring_ref != con->ring_ref && con->ring_ref != XEN_INVALID_PFN)
                console_unmap_interface(con);
 
        if (!con->interface && xgt_handle && con->use_gnttab) {
@@ -706,7 +708,7 @@ static int console_create_ring(struct console *con)
                con->interface = xengnttab_map_grant_ref(xgt_handle,
                        dom->domid, GNTTAB_RESERVED_CONSOLE,
                        PROT_READ|PROT_WRITE);
-               con->ring_ref = -1;
+               con->ring_ref = XEN_INVALID_PFN;
        }
        if (!con->interface) {
                /* Fall back to xc_map_foreign_range */
@@ -812,7 +814,7 @@ static int console_init(struct console *con, struct domain 
*dom, void **data)
        con->master_pollfd_idx = -1;
        con->slave_fd = -1;
        con->log_fd = -1;
-       con->ring_ref = -1;
+       con->ring_ref = XEN_INVALID_PFN;
        con->local_port = -1;
        con->remote_port = -1;
        con->xce_pollfd_idx = -1;
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

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