qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2] dump: let dump_error return error info to ca


From: zhanghailiang
Subject: Re: [Qemu-devel] [PATCH v2] dump: let dump_error return error info to caller
Date: Wed, 3 Sep 2014 16:01:37 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1

On 2014/9/3 3:56, Eric Blake wrote:
On 09/02/2014 02:25 AM, zhanghailiang wrote:
The second parameter of dump_error is unused, but one purpose of
using this function is to report the error info.

Use error_set to return the error info to the caller.

Signed-off-by: zhanghailiang<address@hidden>
---
  V2:
- Return the error reason to the caller which suggested by Luiz Capitulino.
---
  dump.c | 165 ++++++++++++++++++++++++++++++++---------------------------------
  1 file changed, 82 insertions(+), 83 deletions(-)

diff --git a/dump.c b/dump.c
index 71d3e94..0ab72e7 100644
--- a/dump.c
+++ b/dump.c
@@ -81,9 +81,10 @@ static int dump_cleanup(DumpState *s)
      return 0;
  }

-static void dump_error(DumpState *s, const char *reason)
+static void dump_error(DumpState *s, Error **errp, const char *reason)

The Error **errp is typically listed last.

  {
      dump_cleanup(s);
+    error_setg(errp, "%s", reason);
  }

  static int fd_write_vmcore(const void *buf, size_t size, void *opaque)
@@ -99,7 +100,7 @@ static int fd_write_vmcore(const void *buf, size_t size, 
void *opaque)
      return 0;
  }

-static int write_elf64_header(DumpState *s)
+static int write_elf64_header(DumpState *s, Error **errp)
  {
      Elf64_Ehdr elf_header;
      int ret;
@@ -126,14 +127,14 @@ static int write_elf64_header(DumpState *s)

      ret = fd_write_vmcore(&elf_header, sizeof(elf_header), s);
      if (ret<  0) {
-        dump_error(s, "dump: failed to write elf header.\n");
+        dump_error(s, errp, "dump: failed to write elf header.\n");

This ends up calling error_setg with a trailing newline, which should
not be needed.  It looks like all of your conversions to the new
dump_error should drop the \n in the message.


OK, i will fix it, Thanks.:)




reply via email to

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