Commit-ID: 808f7dd4be8e203c6eb83859263cf313f718f1d2 Gitweb: http://git.kernel.org/tip/808f7dd4be8e203c6eb83859263cf313f718f1d2 Author: Lai Jiangshan <laijs@xxxxxxxxxxxxxx> AuthorDate: Tue, 20 Dec 2011 17:08:47 +0800 Committer: Pekka Enberg <penberg@xxxxxxxxxx> CommitDate: Wed, 21 Dec 2011 22:28:08 +0200 kvm tools: cleanup kvm_cmd_stat() 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-stat.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/kvm/builtin-stat.c b/tools/kvm/builtin-stat.c index 1f9ead4..855cc89 100644 --- a/tools/kvm/builtin-stat.c +++ b/tools/kvm/builtin-stat.c @@ -19,7 +19,6 @@ struct stat_cmd { static bool mem; static bool all; -static int instance; static const char *instance_name; static const char * const stat_usage[] = { @@ -106,6 +105,9 @@ static int do_memstat(const char *name, int sock) int kvm_cmd_stat(int argc, const char **argv, const char *prefix) { + int instance; + int r = 0; + parse_stat_options(argc, argv); if (!mem) @@ -114,18 +116,18 @@ int kvm_cmd_stat(int argc, const char **argv, const char *prefix) if (mem && all) return kvm__enumerate_instances(do_memstat); - if (instance_name == NULL && - instance == 0) + if (instance_name == NULL) kvm_stat_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"); if (mem) - return do_memstat(instance_name, instance); + r = do_memstat(instance_name, instance); - return 0; + 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