[tip:tools/kvm] kvm tools: cleanup kvm_cmd_debug()

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

 



Commit-ID:  7a50442ac0dae04ba0cce1baa08834be2d6dc6a4
Gitweb:     http://git.kernel.org/tip/7a50442ac0dae04ba0cce1baa08834be2d6dc6a4
Author:     Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
AuthorDate: Tue, 20 Dec 2011 17:08:44 +0800
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Wed, 21 Dec 2011 22:28:07 +0200

kvm tools: cleanup kvm_cmd_debug()

Use stack variable.
Remove unneeded branch.
Close opened file.

Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/builtin-debug.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/kvm/builtin-debug.c b/tools/kvm/builtin-debug.c
index 7c51ea3..add9b5c 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;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux