From: Lai Jiangshan Date: Tue, 20 Dec 2011 09:08:44 +0000 (+0800) Subject: kvm tools: cleanup kvm_cmd_debug() X-Git-Tag: next-20120402~5^2~96 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=7a50442ac0dae04ba0cce1baa08834be2d6dc6a4;p=karo-tx-linux.git kvm tools: cleanup kvm_cmd_debug() Use stack variable. Remove unneeded branch. Close opened file. Signed-off-by: Lai Jiangshan Signed-off-by: Pekka Enberg --- diff --git a/tools/kvm/builtin-debug.c b/tools/kvm/builtin-debug.c index 7c51ea3984bb..add9b5c4460f 100644 --- a/tools/kvm/builtin-debug.c +++ b/tools/kvm/builtin-debug.c @@ -13,7 +13,6 @@ #define BUFFER_SIZE 100 static bool all; -static int instance; static int nmi = -1; static bool dump; static const char *instance_name; @@ -82,19 +81,23 @@ static int do_debug(const char *name, int sock) int kvm_cmd_debug(int argc, const char **argv, const char *prefix) { parse_debug_options(argc, argv); + int instance; + int r; if (all) return kvm__enumerate_instances(do_debug); - if (instance_name == NULL && - instance == 0) + if (instance_name == NULL) kvm_debug_help(); - if (instance_name) - instance = kvm__get_sock_by_instance(instance_name); + instance = kvm__get_sock_by_instance(instance_name); if (instance <= 0) die("Failed locating instance"); - return do_debug(instance_name, instance); + r = do_debug(instance_name, instance); + + close(instance); + + return r; }