public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] return NULL instead of 0
@ 2007-06-03  9:47 Nguyen Anh Quynh
       [not found] ` <9cde8bff0706030247g73501fcj6c34860b00477228-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Nguyen Anh Quynh @ 2007-06-03  9:47 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

[-- Attachment #1: Type: text/plain, Size: 167 bytes --]

This patch makes kvm_get_msr_list() returns NULL rather than plain 0
in error cases.

Signed-off-by: Nguyen Anh Quynh <aquynh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

[-- Attachment #2: patch6.patch --]
[-- Type: application/octet-stream, Size: 1316 bytes --]

diff --git a/user/kvmctl.c b/user/kvmctl.c
index 82d1926..4153ed6 100644
--- a/user/kvmctl.c
+++ b/user/kvmctl.c
@@ -543,27 +543,27 @@ int kvm_set_sregs(kvm_context_t kvm, int vcpu, struct kvm_sregs *sregs)
  */
 struct kvm_msr_list *kvm_get_msr_list(kvm_context_t kvm)
 {
-    struct kvm_msr_list sizer, *msrs;
-    int r, e;
+	struct kvm_msr_list sizer, *msrs;
+	int r, e;
 
-    sizer.nmsrs = 0;
-    r = ioctl(kvm->fd, KVM_GET_MSR_INDEX_LIST, &sizer);
-    if (r == -1 && errno != E2BIG)
-	return 0;
-    msrs = malloc(sizeof *msrs + sizer.nmsrs * sizeof *msrs->indices);
-    if (!msrs) {
-	errno = ENOMEM;
-	return 0;
-    }
-    msrs->nmsrs = sizer.nmsrs;
-    r = ioctl(kvm->fd, KVM_GET_MSR_INDEX_LIST, msrs);
-    if (r == -1) {
-	e = errno;
-	free(msrs);
-	errno = e;
-	return 0;
-    }
-    return msrs;
+	sizer.nmsrs = 0;
+	r = ioctl(kvm->fd, KVM_GET_MSR_INDEX_LIST, &sizer);
+	if (r == -1 && errno != E2BIG)
+		return NULL;
+	msrs = malloc(sizeof *msrs + sizer.nmsrs * sizeof *msrs->indices);
+	if (!msrs) {
+		errno = ENOMEM;
+		return NULL;
+	}
+	msrs->nmsrs = sizer.nmsrs;
+	r = ioctl(kvm->fd, KVM_GET_MSR_INDEX_LIST, msrs);
+	if (r == -1) {
+		e = errno;
+		free(msrs);
+		errno = e;
+		return NULL;
+	}
+	return msrs;
 }
 
 int kvm_get_msrs(kvm_context_t kvm, int vcpu, struct kvm_msr_entry *msrs,

[-- Attachment #3: Type: text/plain, Size: 286 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-06-03  9:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-03  9:47 [PATCH] return NULL instead of 0 Nguyen Anh Quynh
     [not found] ` <9cde8bff0706030247g73501fcj6c34860b00477228-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-06-03  9:51   ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox