lkml.org 
[lkml]   [2011]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 11/11] kvm tools: remove duplicated code
Date
Simple cleanup.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
tools/kvm/guest_compat.c | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/tools/kvm/guest_compat.c b/tools/kvm/guest_compat.c
index 8dd451b..43b9035 100644
--- a/tools/kvm/guest_compat.c
+++ b/tools/kvm/guest_compat.c
@@ -17,6 +17,13 @@ static int id;
static DEFINE_MUTEX(compat_mtx);
static LIST_HEAD(messages);

+static void compat__free(struct compat_message *msg)
+{
+ free(msg->title);
+ free(msg->desc);
+ free(msg);
+}
+
int compat__add_message(const char *title, const char *desc)
{
struct compat_message *msg;
@@ -42,22 +49,12 @@ int compat__add_message(const char *title, const char *desc)
return msg_id;

cleanup:
- if (msg) {
- free(msg->title);
- free(msg->desc);
- free(msg);
- }
+ if (msg)
+ compat__free(msg);

return -ENOMEM;
}

-static void compat__free(struct compat_message *msg)
-{
- free(msg->title);
- free(msg->desc);
- free(msg);
-}
-
int compat__remove_message(int id)
{
struct compat_message *pos, *n;
--
1.7.4.4


\
 
 \ /
  Last update: 2011-12-12 08:17    [W:1.319 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site