[tip:tools/kvm] kvm tools: Remove unused code for print_guest()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  31b01e06aa499ea59a4685286674017d53f4dc31
Gitweb:     http://git.kernel.org/tip/31b01e06aa499ea59a4685286674017d53f4dc31
Author:     Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
AuthorDate: Tue, 27 Dec 2011 15:36:36 +0800
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Tue, 3 Jan 2012 19:07:01 +0200

kvm tools: Remove unused code for print_guest()

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@xxxxxxxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/builtin-list.c |   20 ++------------------
 1 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/tools/kvm/builtin-list.c b/tools/kvm/builtin-list.c
index eb0ac6c..dbd6d98 100644
--- a/tools/kvm/builtin-list.c
+++ b/tools/kvm/builtin-list.c
@@ -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)
--
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


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux