From: Kyle Hale Date: Thu, 5 Jul 2012 19:38:51 +0000 (-0500) Subject: Small fixes in v3_free.c X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=69f8e46cb46163c55b2832fe5e504d8090ec084e Small fixes in v3_free.c Use strtol instead of atoi for more flexible index numbers. Also, fail on error returned from ioctl. --- diff --git a/linux_usr/v3_free.c b/linux_usr/v3_free.c index c9c7276..1aa4d7a 100644 --- a/linux_usr/v3_free.c +++ b/linux_usr/v3_free.c @@ -18,6 +18,7 @@ int main(int argc, char* argv[]) { int vm_fd = 0; unsigned long vm_idx = 0; + int ret; if (argc <= 1) { @@ -26,7 +27,7 @@ int main(int argc, char* argv[]) { } - vm_idx = atoi(argv[1]); + vm_idx = strtol(argv[1], NULL, 0); printf("Freeing VM %d\n", vm_idx); @@ -37,14 +38,14 @@ int main(int argc, char* argv[]) { return -1; } - ioctl(vm_fd, V3_FREE_GUEST, vm_idx); - - + ret = ioctl(vm_fd, V3_FREE_GUEST, vm_idx); + if (ret < 0) { + printf("Error freeing VM %d\n", vm_idx); + return -1; + } /* Close the file descriptor. */ close(vm_fd); - - return 0; }