]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: cleanup kvm_cmd_resume()
authorLai Jiangshan <laijs@cn.fujitsu.com>
Tue, 20 Dec 2011 09:08:46 +0000 (17:08 +0800)
committerPekka Enberg <penberg@kernel.org>
Wed, 21 Dec 2011 20:28:07 +0000 (22:28 +0200)
Use stack variable.
Remove unneeded branch.
Close opened file.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/builtin-resume.c

index 7b87f595ef97c972d5e1a4cf3976ef68f16bec57..33ccc2bae89030005b2745b772180ffb7c7b8b0a 100644 (file)
@@ -15,7 +15,6 @@ struct resume_cmd {
 };
 
 static bool all;
-static int instance;
 static const char *instance_name;
 
 static const char * const resume_usage[] = {
@@ -59,20 +58,25 @@ static int do_resume(const char *name, int sock)
 
 int kvm_cmd_resume(int argc, const char **argv, const char *prefix)
 {
+       int instance;
+       int r;
+
        parse_resume_options(argc, argv);
 
        if (all)
                return kvm__enumerate_instances(do_resume);
 
-       if (instance_name == NULL &&
-           instance == 0)
+       if (instance_name == NULL)
                kvm_resume_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_resume(instance_name, instance);
+       r = do_resume(instance_name, instance);
+
+       close(instance);
+
+       return r;
 }