Commit-ID: a657151707247c6975c754d773d0f5f470ebfcab Gitweb: http://git.kernel.org/tip/a657151707247c6975c754d773d0f5f470ebfcab Author: Lai Jiangshan <laijs@xxxxxxxxxxxxxx> AuthorDate: Tue, 20 Dec 2011 17:08:48 +0800 Committer: Pekka Enberg <penberg@xxxxxxxxxx> CommitDate: Wed, 21 Dec 2011 22:28:08 +0200 kvm tools: cleanup kvm_cmd_stop() 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-stop.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/kvm/builtin-stop.c b/tools/kvm/builtin-stop.c index 52325e5..7d29eac 100644 --- a/tools/kvm/builtin-stop.c +++ b/tools/kvm/builtin-stop.c @@ -15,7 +15,6 @@ struct stop_cmd { }; static bool all; -static int instance; static const char *instance_name; static const char * const stop_usage[] = { @@ -59,20 +58,25 @@ static int do_stop(const char *name, int sock) int kvm_cmd_stop(int argc, const char **argv, const char *prefix) { + int instance; + int r; + parse_stop_options(argc, argv); if (all) return kvm__enumerate_instances(do_stop); - if (instance_name == NULL && - instance == 0) + if (instance_name == NULL) kvm_stop_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_stop(instance_name, instance); + r = do_stop(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