From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjASU-0001PC-Fh for qemu-devel@nongnu.org; Thu, 13 Dec 2012 10:12:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjARd-00063a-JA for qemu-devel@nongnu.org; Thu, 13 Dec 2012 10:12:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:13176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjARd-00063K-Br for qemu-devel@nongnu.org; Thu, 13 Dec 2012 10:11:29 -0500 From: Kevin Wolf Date: Thu, 13 Dec 2012 16:10:37 +0100 Message-Id: <1355411450-12761-31-git-send-email-kwolf@redhat.com> In-Reply-To: <1355411450-12761-1-git-send-email-kwolf@redhat.com> References: <1355411450-12761-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 30/43] blkdebug: Factor out remove_rule() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org The cleanup work to remove a rule depends on the type of the rule. It's easy for the existing rules as there is no data that must be cleaned up and is specific to a type yet, but the next patch will change this. Signed-off-by: Kevin Wolf --- block/blkdebug.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index c9041ec..859792b 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -234,6 +234,18 @@ static int add_rule(QemuOpts *opts, void *opaque) return 0; } +static void remove_rule(BlkdebugRule *rule) +{ + switch (rule->action) { + case ACTION_INJECT_ERROR: + case ACTION_SET_STATE: + break; + } + + QLIST_REMOVE(rule, next); + g_free(rule); +} + static int read_config(BDRVBlkdebugState *s, const char *filename) { FILE *f; @@ -402,8 +414,7 @@ static void blkdebug_close(BlockDriverState *bs) for (i = 0; i < BLKDBG_EVENT_MAX; i++) { QLIST_FOREACH_SAFE(rule, &s->rules[i], next, next) { - QLIST_REMOVE(rule, next); - g_free(rule); + remove_rule(rule); } } } -- 1.7.6.5