From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: luonengjun@huawei.com, qemu-devel@nongnu.org,
lcapitulino@redhat.com, qiaonuohan@cn.fujitsu.com,
peter.huangpeng@huawei.com, lersek@redhat.com
Subject: Re: [Qemu-devel] [PATCH v5 2/2] dump: Don't return error code when return an Error object
Date: Fri, 19 Sep 2014 08:51:14 +0800 [thread overview]
Message-ID: <541B7E02.1060301@huawei.com> (raw)
In-Reply-To: <87ppeva5yr.fsf@blackfin.pond.sub.org>
On 2014/9/17 0:24, Markus Armbruster wrote:
> zhanghailiang <zhang.zhanghailiang@huawei.com> writes:
>
>> Functions shouldn't return an error code and an Error object at the same time.
>> Turn all these functions that returning Error object to void.
>> We also judge if a function success or fail by reference to the *errp.
>>
>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
>> ---
>> dump.c | 244 +++++++++++++++++++++++++----------------------------------------
>> 1 file changed, 94 insertions(+), 150 deletions(-)
>>
>> diff --git a/dump.c b/dump.c
>> index 07d2300..b2ed846 100644
>> --- a/dump.c
>> +++ b/dump.c
> [...]
>> /* write the memroy to vmcore. 1 page per I/O. */
>> -static int write_memory(DumpState *s, GuestPhysBlock *block, ram_addr_t start,
>> +static void write_memory(DumpState *s, GuestPhysBlock *block, ram_addr_t start,
>> int64_t size, Error **errp)
>> {
>> int64_t i;
>> - int ret;
>>
>> for (i = 0; i < size / TARGET_PAGE_SIZE; i++) {
>> - ret = write_data(s, block->host_addr + start + i * TARGET_PAGE_SIZE,
>> + write_data(s, block->host_addr + start + i * TARGET_PAGE_SIZE,
>> TARGET_PAGE_SIZE, errp);
>
> Please fix up indentation of arguments.
>
OK.
>> - if (ret < 0) {
>> - return ret;
>> + if (*errp) {
>> + return;
>
> This breaks when a caller choses to ignore errors by passing a null
> argument for errp.
>
> For static functions that may be okay. But in general, we support null
> arguments by coding like this:
>
> Error *local_err = NULL;
> int64_t i;
>
> for (i = 0; i < size / TARGET_PAGE_SIZE; i++) {
> write_data(s, block->host_addr + start + i * TARGET_PAGE_SIZE,
> TARGET_PAGE_SIZE, &local_err);
> if (local_err) {
> error_propagate(errp, local_err);
> return;
> }
> }
>
> I feel it's better to stick to this convention.
>
> More of the same elsewhere.
>
OK, will do it, Thanks.
>> }
>> }
> [...]
>
> .
>
prev parent reply other threads:[~2014-09-19 0:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-16 7:30 [Qemu-devel] [PATCH v5 0/2] Fix dump_error to return error message zhanghailiang
2014-09-16 7:30 ` [Qemu-devel] [PATCH v5 1/2] dump: let dump_error return error info to caller zhanghailiang
2014-09-16 7:30 ` [Qemu-devel] [PATCH v5 2/2] dump: Don't return error code when return an Error object zhanghailiang
2014-09-16 16:24 ` Markus Armbruster
2014-09-19 0:51 ` zhanghailiang [this message]
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=541B7E02.1060301@huawei.com \
--to=zhang.zhanghailiang@huawei.com \
--cc=armbru@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=qiaonuohan@cn.fujitsu.com \
/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.