[tip:tools/kvm] kvm tools: narrow the C.S. of compat_mtx

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

 



Commit-ID:  386d17431e4b8d244c1d20bc55d7c3af5aa21c8c
Gitweb:     http://git.kernel.org/tip/386d17431e4b8d244c1d20bc55d7c3af5aa21c8c
Author:     Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
AuthorDate: Mon, 12 Dec 2011 15:15:53 +0800
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Mon, 12 Dec 2011 23:35:36 +0200

kvm tools: narrow the C.S. of compat_mtx

The allocation and the copy are not required in the C.S.

Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/guest_compat.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/tools/kvm/guest_compat.c b/tools/kvm/guest_compat.c
index fac53f5..de97df5 100644
--- a/tools/kvm/guest_compat.c
+++ b/tools/kvm/guest_compat.c
@@ -21,20 +21,19 @@ int compat__add_message(const char *title, const char *desc)
 {
 	struct compat_message *msg;
 
-	mutex_lock(&compat_mtx);
 	msg = malloc(sizeof(*msg));
 	if (msg == NULL)
 		goto cleanup;
 
-	*msg = (struct compat_message) {
-		.id = id,
-		.title = strdup(title),
-		.desc = strdup(desc),
-	};
+	msg->title = strdup(title);
+	msg->desc = strdup(desc);
 
 	if (msg->title == NULL || msg->desc == NULL)
 		goto cleanup;
 
+	mutex_lock(&compat_mtx);
+
+	msg->id = id;
 	list_add_tail(&msg->list, &messages);
 
 	mutex_unlock(&compat_mtx);
@@ -48,8 +47,6 @@ cleanup:
 		free(msg);
 	}
 
-	mutex_unlock(&compat_mtx);
-
 	return -ENOMEM;
 }
 
@@ -101,4 +98,4 @@ int compat__print_all_messages(void)
 	mutex_unlock(&compat_mtx);
 
 	return 0;
-}
\ No newline at end of file
+}
--
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