All of lore.kernel.org
 help / color / mirror / Atom feed
From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-trivial@nongnu.org, luonengjun@huawei.com,
	qemu-devel@nongnu.org, lcapitulino@redhat.com,
	peter.huangpeng@huawei.com, lersek@redhat.com
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] dump: let dump_error return error info to caller
Date: Wed, 3 Sep 2014 16:01:37 +0800	[thread overview]
Message-ID: <5406CAE1.301@huawei.com> (raw)
In-Reply-To: <540620EC.20909@redhat.com>

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<zhang.zhanghailiang@huawei.com>
>> ---
>>   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.:)



WARNING: multiple messages have this Message-ID (diff)
From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-trivial@nongnu.org, luonengjun@huawei.com,
	qemu-devel@nongnu.org, lcapitulino@redhat.com,
	peter.huangpeng@huawei.com, lersek@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] dump: let dump_error return error info to caller
Date: Wed, 3 Sep 2014 16:01:37 +0800	[thread overview]
Message-ID: <5406CAE1.301@huawei.com> (raw)
In-Reply-To: <540620EC.20909@redhat.com>

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<zhang.zhanghailiang@huawei.com>
>> ---
>>   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	other threads:[~2014-09-03  8:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-02  8:25 [Qemu-trivial] [PATCH v2] dump: let dump_error return error info to caller zhanghailiang
2014-09-02  8:25 ` [Qemu-devel] " zhanghailiang
2014-09-02 19:56 ` [Qemu-trivial] " Eric Blake
2014-09-02 19:56   ` Eric Blake
2014-09-03  8:01   ` zhanghailiang [this message]
2014-09-03  8:01     ` zhanghailiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5406CAE1.301@huawei.com \
    --to=zhang.zhanghailiang@huawei.com \
    --cc=eblake@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=lersek@redhat.com \
    --cc=luonengjun@huawei.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.