]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: cleanup kvm_cmd_pause()
authorLai Jiangshan <laijs@cn.fujitsu.com>
Tue, 20 Dec 2011 09:08:45 +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-pause.c

index 107641ccd494821000a1d0b577afdecbbafe9254..eb89ff7e9abbe13974c4c29ce4831af4a2feb167 100644 (file)
@@ -15,7 +15,6 @@ struct pause_cmd {
 };
 
 static bool all;
-static int instance;
 static const char *instance_name;
 
 static const char * const pause_usage[] = {
@@ -59,20 +58,25 @@ static int do_pause(const char *name, int sock)
 
 int kvm_cmd_pause(int argc, const char **argv, const char *prefix)
 {
+       int instance;
+       int r;
+
        parse_pause_options(argc, argv);
 
        if (all)
                return kvm__enumerate_instances(do_pause);
 
-       if (instance_name == NULL &&
-           instance == 0)
+       if (instance_name == NULL)
                kvm_pause_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_pause(instance_name, instance);
+       r = do_pause(instance_name, instance);
+
+       close(instance);
+
+       return r;
 }