<div>I see.</div><div>Thanks!</div><div><div><br></div><div><br></div><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>From: </b> "Hitoshi Mitake";<mitake.hitoshi@lab.ntt.co.jp>;</div><div><b>Date: </b> Thu, Sep 11, 2014 10:28 AM</div><div><b>To: </b> "Bingpeng Zhu"<nkuzbp@foxmail.com>; <wbr></div><div><b>Cc: </b> "sheepdog"<sheepdog@lists.wpkg.org>; "Bingpeng Zhu"<bingpeng.zbp@alibaba-inc.com>; <wbr></div><div><b>Subject: </b> Re: [sheepdog] [PATCH v1] sheep: replace valloc with xvalloc</div></div><div><br></div>At Wed, 10 Sep 2014 19:52:10 +0800,<br>Bingpeng Zhu wrote:<br>> <br>> xvalloc is the wrapper function of valloc in lib/util.<br>> We should use xvalloc instead of valloc in our code.<br>> <br>> Signed-off-by: Bingpeng Zhu <bingpeng.zbp@alibaba-inc.com><br>> ---<br>>  sheep/plain_store.c |    4 +---<br>>  sheep/request.c     |    6 +-----<br>>  2 files changed, 2 insertions(+), 8 deletions(-)<br><br>xvalloc() can call panic() when it fails to allocate memory so I think<br>the below changes are too agressive. e.g. sheep can panic() when it<br>receives GET_HASH request from dog. In most cases like this, returning<br>SD_RES_NO_MEM is suitable than calling panic().<br><br>Thanks,<br>Hitoshi<br><br>> <br>> diff --git a/sheep/plain_store.c b/sheep/plain_store.c<br>> index 876582c..7ab0699 100644<br>> --- a/sheep/plain_store.c<br>> +++ b/sheep/plain_store.c<br>> @@ -691,9 +691,7 @@ int default_get_hash(uint64_t oid, uint32_t epoch, uint8_t *sha1)<br>>         }<br>>  <br>>       length = get_store_objsize(oid);<br>> -        buf = valloc(length);<br>> -   if (buf == NULL)<br>> -                return SD_RES_NO_MEM;<br>> +   buf = xvalloc(length);<br>>  <br>>          iocb.epoch = epoch;<br>>          iocb.buf = buf;<br>> diff --git a/sheep/request.c b/sheep/request.c<br>> index 8a2e7dc..bc10b90 100644<br>> --- a/sheep/request.c<br>> +++ b/sheep/request.c<br>> @@ -690,11 +690,7 @@ static struct request *alloc_request(struct client_info *ci, int data_length)<br>>  <br>>       if (data_length) {<br>>           req->data_length = data_length;<br>> -              req->data = valloc(data_length);<br>> -             if (!req->data) {<br>> -                    free(req);<br>> -                      return NULL;<br>> -            }<br>> +               req->data = xvalloc(data_length);<br>>         }<br>>  <br>>       req->ci = ci;<br>> -- <br>> 1.7.1<br>> <br>> <br>> -- <br>> sheepdog mailing list<br>> sheepdog@lists.wpkg.org<br>> http://lists.wpkg.org/mailman/listinfo/sheepdog<br></div>