[sheepdog] [PATCH v2 UPDATE] sheep: use switch case inside vdi_create()
Liu Yuan
namei.unix at gmail.com
Mon Apr 29 14:21:25 CEST 2013
From: Liu Yuan <tailai.ly at taobao.com>
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/vdi.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/sheep/vdi.c b/sheep/vdi.c
index 8b7a11f..5ed784f 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -498,17 +498,18 @@ 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:
+ sd_eprintf("%s", sd_strerror(ret));
+ return ret;
}
if (!iocb->snapid)
iocb->snapid = 1;
--
1.7.9.5
More information about the sheepdog
mailing list