[sheepdog] [PATCH 2/2] sheep: use xzalloc in start_recovery()

Liu Yuan namei.unix at gmail.com
Wed Mar 20 11:25:54 CET 2013


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

The caller of start_recovery() don't handle malloc failure, so panic-out is
a better choice than letting non-recoverable sheep daemon keep running.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/recovery.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/sheep/recovery.c b/sheep/recovery.c
index 9ef7abc..10e9cdb 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -643,12 +643,7 @@ int start_recovery(struct vnode_info *cur_vinfo, struct vnode_info *old_vinfo)
 	if (node_is_gateway_only())
 		return 0;
 
-	rw = zalloc(sizeof(struct recovery_work));
-	if (!rw) {
-		sd_eprintf("%m");
-		return -1;
-	}
-
+	rw = xzalloc(sizeof(struct recovery_work));
 	rw->state = RW_INIT;
 	rw->oids = xmalloc(list_buffer_size);
 	rw->epoch = sys->epoch;
-- 
1.7.9.5




More information about the sheepdog mailing list