From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAzF3-0002Mt-Hg for qemu-devel@nongnu.org; Mon, 10 Sep 2012 04:21:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TAzF1-0005pk-VY for qemu-devel@nongnu.org; Mon, 10 Sep 2012 04:21:13 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:53568) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TAzF1-0005o7-BX for qemu-devel@nongnu.org; Mon, 10 Sep 2012 04:21:11 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 10 Sep 2012 18:19:15 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8A8BnVs17694746 for ; Mon, 10 Sep 2012 18:11:49 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q8A8L1LR016092 for ; Mon, 10 Sep 2012 18:21:02 +1000 Message-ID: <504DA2DE.8080002@linux.vnet.ibm.com> Date: Mon, 10 Sep 2012 16:20:46 +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: 7bit 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 about the error number defines, I think using union instead of macro will cause additional trouble: int64_t qb_read() In this case return is type int64_t, and it may return the error number, so using unions for error number would not provide much help. Other issues you mentioned have been fixed in next version. > 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? > -- Best Regards Wenchao Xia