From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8nJP-0006Gq-A8 for qemu-devel@nongnu.org; Tue, 04 Sep 2012 03:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8nJL-0005T8-CT for qemu-devel@nongnu.org; Tue, 04 Sep 2012 03:12:39 -0400 Received: from e28smtp03.in.ibm.com ([122.248.162.3]:44229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8nJK-0005Sw-MS for qemu-devel@nongnu.org; Tue, 04 Sep 2012 03:12:35 -0400 Received: from /spool/local by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Sep 2012 12:42:29 +0530 Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q847CORA30539868 for ; Tue, 4 Sep 2012 12:42:24 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q847COr3005837 for ; Tue, 4 Sep 2012 17:12:24 +1000 Message-ID: <5045A9D4.3030500@linux.vnet.ibm.com> Date: Tue, 04 Sep 2012 15:12:20 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1346663926-20188-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1346663926-20188-4-git-send-email-xiawenc@linux.vnet.ibm.com> <5044BD2A.1070409@redhat.com> In-Reply-To: <5044BD2A.1070409@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 3/6] libqblock error handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org, stefanha@gmail.com 于 2012-9-3 22:22, Eric Blake 写道: > On 09/03/2012 03:18 AM, Wenchao Xia wrote: >> This patch contains error handling APIs. >> >> Signed-off-by: Wenchao Xia >> --- >> libqblock/libqblock-error.c | 44 +++++++++++++++++++++++++++++++++++++++++++ >> libqblock/libqblock-error.h | 34 +++++++++++++++++++++++++++++++++ >> 2 files changed, 78 insertions(+), 0 deletions(-) >> create mode 100644 libqblock/libqblock-error.c >> create mode 100644 libqblock/libqblock-error.h >> >> diff --git a/libqblock/libqblock-error.c b/libqblock/libqblock-error.c >> new file mode 100644 >> index 0000000..28d1d77 >> --- /dev/null >> +++ b/libqblock/libqblock-error.c >> @@ -0,0 +1,44 @@ >> +#include "libqblock-error.h" > > No copyright. Shame. > >> +++ b/libqblock/libqblock-error.h >> @@ -0,0 +1,34 @@ >> +#ifndef LIBQBLOCK_ERROR > > No copyright. Shame. > >> +#define LIBQBLOCK_ERROR >> + >> +#include "libqblock-types.h" >> + >> +#define QB_ERR_MEM_ERR (-1) >> +#define QB_ERR_INTERNAL_ERR (-2) >> +#define QB_ERR_INVALID_PARAM (-3) >> +#define QB_ERR_BLOCK_OUT_OF_RANGE (-100) > > Would an enum make more sense than #defines? > >> + >> +/* error handling */ >> +/** >> + * qb_error_get_human_str: get human readable erro string. > > s/erro/error/ > >> + * >> + * return a human readable string. >> + * >> + * @broker: operation broker, must be valid. >> + * @buf: buf to receive the string. >> + * @buf_size: the size of the string buf. >> + */ >> +void qb_error_get_human_str(struct QBroker *broker, >> + char *buf, int buf_size); > > What happens if buf_size is too small to receive the entire error > message? Should this function return int, with negative value on input > error? > if so, the string is truncated. Give negative value resulting an error check for an error check, I guess user would not like it, so provide error check functions which never fail. -- Best Regards Wenchao Xia