From: =?gbk?B?WWFuemhhbmcgTGkg?= Subject: =?gbk?q?_=5BPATCH=5D_memshr_tools=3A_use_hypercall_re?= =?gbk?q?turn_value_incorrectly?= Date: Sat, 8 Dec 2012 15:40:04 +0800 (CST) Message-ID: <1947237017.20.1354952403984.JavaMail.root@bj-mail05.pku.edu.cn> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.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 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 #include +#include #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);