[sheepdog] [PATCH 1/6] sheep: use switch case inside vdi_create()

Liu Yuan namei.unix at gmail.com
Sat Apr 27 07:44:17 CEST 2013


From: Liu Yuan <tailai.ly at taobao.com>

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/vdi.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/sheep/vdi.c b/sheep/vdi.c
index 8b7a11f..8abc23c 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -498,17 +498,17 @@ int vdi_create(struct vdi_iocb *iocb, uint32_t *new_vid)
 	int ret;
 
 	ret = vdi_lookup(iocb, &info);
-	if (iocb->create_snapshot) {
-		/* We should have base vdi, otherwise error happens */
-		if (ret != SD_RES_SUCCESS)
-			return ret;
-	} else {
-		/* If we already have the same VDI or met other errors. */
-		if (ret != SD_RES_NO_VDI) {
-			if (ret == SD_RES_SUCCESS)
-				ret = SD_RES_VDI_EXIST;
+	switch (ret) {
+	case SD_RES_SUCCESS:
+		if (!iocb->create_snapshot)
+			return SD_RES_VDI_EXIST;
+		break;
+	case SD_RES_NO_VDI:
+		if (iocb->create_snapshot)
 			return ret;
-		}
+		break;
+	default:
+		return ret;
 	}
 	if (!iocb->snapid)
 		iocb->snapid = 1;
-- 
1.7.9.5




More information about the sheepdog mailing list