diff mbox

[5/5,v2] xenconsole: Define and use a macro XEN_INVALID_PFN instead of -1

Message ID 1508923628-26446-5-git-send-email-bhupinder.thakur@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Bhupinder Thakur Oct. 25, 2017, 9:27 a.m. UTC
xenconsole will use a new macro XEN_INVALID_PFN instead of -1 for initializing ring-ref.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

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(-)

Comments

Wei Liu Oct. 26, 2017, 11:26 a.m. UTC | #1
On Wed, Oct 25, 2017 at 02:57:08PM +0530, Bhupinder Thakur wrote:
> xenconsole will use a new macro XEN_INVALID_PFN instead of -1 for initializing ring-ref.

Can you please paste in the error if the compilation fails with -1?

The way this series is arranged make me wonder if the compilation is
broken half way. We should avoid that.
Bhupinder Thakur Oct. 27, 2017, 7:04 a.m. UTC | #2
Hi Wei,

On 26 October 2017 at 16:56, Wei Liu <wei.liu2@citrix.com> wrote:
> On Wed, Oct 25, 2017 at 02:57:08PM +0530, Bhupinder Thakur wrote:
>> xenconsole will use a new macro XEN_INVALID_PFN instead of -1 for initializing ring-ref.
>
> Can you please paste in the error if the compilation fails with -1?
>
> The way this series is arranged make me wonder if the compilation is
> broken half way. We should avoid that.
It is not breaking the compilation. Since the type of ring_ref is
changed to xen_pfn_t (which is an unsigned value) assigning -1
appeared to be confusing. For better clarity, XEN_INVALID_PFN is
introduced.

Regards,
Bhupinder
Bhupinder Thakur Oct. 27, 2017, 7:07 a.m. UTC | #3
On 27 October 2017 at 12:34, Bhupinder Thakur
<bhupinder.thakur@linaro.org> wrote:
> Hi Wei,
>
> On 26 October 2017 at 16:56, Wei Liu <wei.liu2@citrix.com> wrote:
>> On Wed, Oct 25, 2017 at 02:57:08PM +0530, Bhupinder Thakur wrote:
>>> xenconsole will use a new macro XEN_INVALID_PFN instead of -1 for initializing ring-ref.
>>
>> Can you please paste in the error if the compilation fails with -1?
>>
>> The way this series is arranged make me wonder if the compilation is
>> broken half way. We should avoid that.
> It is not breaking the compilation. Since the type of ring_ref is
> changed to xen_pfn_t (which is an unsigned value) assigning -1
> appeared to be confusing. For better clarity, XEN_INVALID_PFN is
> introduced.

I will update the commit message accordingly.

Regards,
Bhupinder
diff mbox

Patch

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;