]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Remove unused code for print_guest()
authorLai Jiangshan <laijs@cn.fujitsu.com>
Tue, 27 Dec 2011 07:36:36 +0000 (15:36 +0800)
committerPekka Enberg <penberg@kernel.org>
Tue, 3 Jan 2012 17:07:01 +0000 (19:07 +0200)
comm is unused ==> fscanf() is unused ==> fd is unused
==> proc_name is unused.

so all this code can be removed.

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

index eb0ac6ca95312c2e8a326f3bb3415c9faf041a28..dbd6d98f329056c3445403376e488ca203fa7d2d 100644 (file)
@@ -70,20 +70,13 @@ static int get_vmstate(int sock)
 
 static int print_guest(const char *name, int sock)
 {
-       char proc_name[PATH_MAX];
-       char *comm = NULL;
-       FILE *fd;
        pid_t pid;
        int vmstate;
 
        pid = get_pid(sock);
        vmstate = get_vmstate(sock);
 
-       sprintf(proc_name, "/proc/%d/stat", pid);
-       fd = fopen(proc_name, "r");
-       if (fd == NULL)
-               goto cleanup;
-       if (fscanf(fd, "%*u (%as)", &comm) == 0)
+       if ((int)pid < 0 || vmstate < 0)
                goto cleanup;
 
        if (vmstate == KVM_VMSTATE_PAUSED)
@@ -91,20 +84,11 @@ static int print_guest(const char *name, int sock)
        else
                printf("%5d %-20s %s\n", pid, name, KVM_INSTANCE_RUNNING);
 
-       free(comm);
-
-       fclose(fd);
-
        return 0;
 
 cleanup:
-       if (fd)
-               fclose(fd);
-       if (comm)
-               free(comm);
-
        kvm__remove_socket(name);
-       return 0;
+       return -1;
 }
 
 static int kvm_list_running_instances(void)