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

[Xen-devel] [PATCH] memshr tools: use hypercall return value incorrectly


  • To: xen-devel@xxxxxxxxxxxxx
  • From: Yanzhang Li <liyz@xxxxxxxxxx>
  • Date: Sat, 8 Dec 2012 15:40:04 +0800 (CST)
  • Delivery-date: Mon, 10 Dec 2012 13:08:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

When programs in TOOLS call hypercall and fail, they will get return value -1 
and find real error number in "errno". But in the following code, it uses 
return value -1 to do switch-case incorrectly.

Signed-off-by: Yanzhang Li <liyz@xxxxxxxxxx>

diff -u xen-4.2.0/tools/memshr/interface.c 
change/xen-4.2.0/tools/memshr/interface.c
--- xen-4.2.0/tools/memshr/interface.c  2012-09-17 18:21:18.000000000 +0800
+++ change/xen-4.2.0/tools/memshr/interface.c   2012-12-07 09:50:16.208705246 
+0800
@@ -18,6 +18,7 @@
  */
 #include <string.h>
 #include <inttypes.h>
+#include <errno.h>

 #include "memshr.h"
 #include "memshr-priv.h"
@@ -184,7 +185,7 @@
         if(!ret) return 0;
         /* Handles failed to be shared => at least one of them must be invalid,
            remove the relevant ones from the map */
-        switch(ret)
+        switch(-errno)
         {
             case XENMEM_SHARING_OP_S_HANDLE_INVALID:
                 ret = blockshr_shrhnd_remove(memshr.blks, source_st, NULL);

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


 


Rackspace

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