From 6e2fdfed67cb877b622016a23f6792ae0545c234 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 20 Oct 2011 10:32:29 +0000 Subject: [PATCH] Reindent code Avoid 1 indent level and use check for empty list only for add of transaction_id message. --- lib/thin/thin.c | 67 +++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/lib/thin/thin.c b/lib/thin/thin.c index 1237b2ce5..c3f8438b5 100644 --- a/lib/thin/thin.c +++ b/lib/thin/thin.c @@ -241,41 +241,42 @@ static int _thin_pool_add_target_line(struct dev_manager *dm, seg->zero_new_blocks ? 0 : 1)) return_0; - if (!dm_list_empty(&seg->thin_messages)) { - dm_list_iterate_items(lmsg, &seg->thin_messages) { - dmsg.type = lmsg->type; - switch (lmsg->type) { - case DM_THIN_MESSAGE_CREATE_SNAP: - /* FIXME: to be implemented */ - log_debug("Thin pool create_snap %s.", lmsg->u.lv->name); - dmsg.u.m_create_snap.device_id = first_seg(lmsg->u.lv)->device_id; - dmsg.u.m_create_snap.origin_id = 0;//first_seg(first_seg(lmsg->u.lv)->origin)->device_id; - if (!dm_tree_node_add_thin_pool_message(node, &dmsg)) - return_0; - log_error(INTERNAL_ERROR "Sorry, not implemented yet."); - return 0; - case DM_THIN_MESSAGE_CREATE_THIN: - log_debug("Thin pool create_thin %s.", lmsg->u.lv->name); - dmsg.u.m_create_thin.device_id = first_seg(lmsg->u.lv)->device_id; - if (!dm_tree_node_add_thin_pool_message(node, &dmsg)) - return_0; - break; - case DM_THIN_MESSAGE_DELETE: - log_debug("Thin pool delete %u.", lmsg->u.delete_id); - dmsg.u.m_delete.device_id = lmsg->u.delete_id; - if (!dm_tree_node_add_thin_pool_message(node, &dmsg)) - return_0; - break; - case DM_THIN_MESSAGE_TRIM: - /* FIXME: to be implemented */ - log_error(INTERNAL_ERROR "Sorry, not implemented yet."); - return 0; - default: - log_error(INTERNAL_ERROR "Unsupported message."); - return 0; - } + dm_list_iterate_items(lmsg, &seg->thin_messages) { + dmsg.type = lmsg->type; + switch (lmsg->type) { + case DM_THIN_MESSAGE_CREATE_SNAP: + /* FIXME: to be implemented */ + log_debug("Thin pool create_snap %s.", lmsg->u.lv->name); + dmsg.u.m_create_snap.device_id = first_seg(lmsg->u.lv)->device_id; + dmsg.u.m_create_snap.origin_id = 0;//first_seg(first_seg(lmsg->u.lv)->origin)->device_id; + if (!dm_tree_node_add_thin_pool_message(node, &dmsg)) + return_0; + log_error("Sorry SNAPSHOTS is not yet supported."); + return 0; + case DM_THIN_MESSAGE_CREATE_THIN: + log_debug("Thin pool create_thin %s.", lmsg->u.lv->name); + dmsg.u.m_create_thin.device_id = first_seg(lmsg->u.lv)->device_id; + if (!dm_tree_node_add_thin_pool_message(node, &dmsg)) + return_0; + break; + case DM_THIN_MESSAGE_DELETE: + log_debug("Thin pool delete %u.", lmsg->u.delete_id); + dmsg.u.m_delete.device_id = lmsg->u.delete_id; + if (!dm_tree_node_add_thin_pool_message(node, &dmsg)) + return_0; + break; + case DM_THIN_MESSAGE_TRIM: + /* FIXME: to be implemented */ + log_error("Sorry TRIM is not yes supported."); + return 0; + default: + log_error(INTERNAL_ERROR "Unsupported message."); + return 0; } + } + if (!dm_list_empty(&seg->thin_messages)) { + /* Messages were passed, modify transaction_id as the last one */ log_debug("Thin pool set_transaction_id %" PRIu64 ".", seg->transaction_id); dmsg.type = DM_THIN_MESSAGE_SET_TRANSACTION_ID; dmsg.u.m_set_transaction_id.current_id = seg->transaction_id - 1;