From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tr8gW-00034i-3s for qemu-devel@nongnu.org; Fri, 04 Jan 2013 09:55:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tr8gU-0001Z3-Mj for qemu-devel@nongnu.org; Fri, 04 Jan 2013 09:55:47 -0500 Received: from mail-bk0-f41.google.com ([209.85.214.41]:41734) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tr8gU-0001YN-7f for qemu-devel@nongnu.org; Fri, 04 Jan 2013 09:55:46 -0500 Received: by mail-bk0-f41.google.com with SMTP id jg9so7300052bkc.28 for ; Fri, 04 Jan 2013 06:55:45 -0800 (PST) Date: Fri, 4 Jan 2013 15:55:42 +0100 From: Stefan Hajnoczi Message-ID: <20130104145542.GB6310@stefanha-thinkpad.hitronhub.home> References: <1355725509-5429-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1355725509-5429-3-git-send-email-xiawenc@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1355725509-5429-3-git-send-email-xiawenc@linux.vnet.ibm.com> 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: Wenchao Xia Cc: kwolf@redhat.com, pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org, blauwirbel@gmail.com 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