Yanzhang Li
2012-Dec-08 07:40 UTC
[PATCH] memshr tools: use hypercall return value incorrectly
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@pku.edu.cn> 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);