qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/6] snapshot: add error set function


From: Wenchao Xia
Subject: Re: [Qemu-devel] [PATCH 2/6] snapshot: add error set function
Date: Sat, 05 Jan 2013 16:27:45 +0800
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121026 Thunderbird/16.0.2

于 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 <filename> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]