From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TrP6g-0001H2-TX for qemu-devel@nongnu.org; Sat, 05 Jan 2013 03:27:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TrP6f-0002qu-Rl for qemu-devel@nongnu.org; Sat, 05 Jan 2013 03:27:54 -0500 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:55037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TrP6f-0002qq-71 for qemu-devel@nongnu.org; Sat, 05 Jan 2013 03:27:53 -0500 Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 5 Jan 2013 18:23:07 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 813F7357804D for ; Sat, 5 Jan 2013 19:27:47 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r058RkCg50790452 for ; Sat, 5 Jan 2013 19:27:47 +1100 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 r058Rk4d019040 for ; Sat, 5 Jan 2013 19:27:46 +1100 Message-ID: <50E7E401.2050906@linux.vnet.ibm.com> Date: Sat, 05 Jan 2013 16:27:45 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1355725509-5429-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1355725509-5429-3-git-send-email-xiawenc@linux.vnet.ibm.com> <20130104145542.GB6310@stefanha-thinkpad.hitronhub.home> In-Reply-To: <20130104145542.GB6310@stefanha-thinkpad.hitronhub.home> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 2/6] snapshot: add error set function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org, blauwirbel@gmail.com 于 2013-1-4 22:55, Stefan Hajnoczi 写道: > On Mon, Dec 17, 2012 at 02:25:05PM +0800, Wenchao Xia wrote: > > This patch has nothing to do with snapshots, so "snapshot: add error set > function" is not a useful commit message. "error: add > error_set_replace()" would be okay. Please use git log on > the file you are modifying to find good component names (e.g. "block:", > "error:"). > >> @@ -29,6 +29,9 @@ typedef struct Error Error; >> */ >> void error_set(Error **err, ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(3, 4); >> >> +void error_set_replace(Error **err, ErrorClass err_class, const char *fmt, ...) >> +GCC_FMT_ATTR(3, 4); >> + >> /** >> * Set an indirect pointer to an error given a ErrorClass value and a >> * printf-style human message, followed by a strerror() string if >> @@ -43,6 +46,12 @@ void error_set_errno(Error **err, int os_error, ErrorClass err_class, const char >> error_set(err, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__) >> #define error_setg_errno(err, os_error, fmt, ...) \ >> error_set_errno(err, os_error, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__) >> +#define error_setg_replace(err, fmt, ...) do { \ >> + if (*err != NULL) { \ >> + error_free(*err); \ >> + } \ >> + error_set(err, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__); \ >> +} while (/*CONSTCOND*/0) > > Why not use error_set_replace() to get rid of the error_free() check? > > Stefan > It will be changed to error_set_check() which only set error when *err is not set, to keep first error not over written. -- Best Regards Wenchao Xia