From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRN4F-0004ms-OD for qemu-devel@nongnu.org; Tue, 09 Sep 2014 11:11:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XRN48-00040G-MJ for qemu-devel@nongnu.org; Tue, 09 Sep 2014 11:10:51 -0400 Message-ID: <540F186C.2030508@redhat.com> Date: Tue, 09 Sep 2014 09:10:36 -0600 From: Eric Blake MIME-Version: 1.0 References: <1409738096-35644-1-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1409738096-35644-1-git-send-email-zhang.zhanghailiang@huawei.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="20RvcCX0uSr7Dp9tlr6Cc3sDcJGoBNDxB" Subject: Re: [Qemu-devel] [PATCH v3] dump: let dump_error return error info to caller List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: zhanghailiang , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, luonengjun@huawei.com, lersek@redhat.com, peter.huangpeng@huawei.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --20RvcCX0uSr7Dp9tlr6Cc3sDcJGoBNDxB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/03/2014 03:54 AM, zhanghailiang wrote: > The second parameter of dump_error is unused, but one purpose of > using this function is to report the error info. >=20 > Use error_set to return the error info to the caller. >=20 > Signed-off-by: zhanghailiang > --- > V3: > - Drop the '\n' in the message when call dump_error(comment of Eric Bla= ke)=20 > V2: > - Return the error reason to the caller which suggested by Luiz Capitul= ino. > --- > dump.c | 165 ++++++++++++++++++++++++++++++++-------------------------= -------- > 1 file changed, 82 insertions(+), 83 deletions(-) >=20 > diff --git a/dump.c b/dump.c > index 71d3e94..a08a711 100644 > --- a/dump.c > +++ b/dump.c > @@ -81,9 +81,10 @@ static int dump_cleanup(DumpState *s) > return 0; > } > =20 > -static void dump_error(DumpState *s, const char *reason) > +static void dump_error(DumpState *s, Error **errp, const char *reason)= I still think it is unusual to list the errp argument in the middle, instead of the end. But not necessarily a show-stopper. > -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) > =20 > ret =3D 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."); We tend to avoid trailing '.' in error messages > +static int write_dump_pages(DumpState *s, Error **errp) > { > int ret =3D 0; > DataCache page_desc, page_data; > @@ -1241,7 +1244,7 @@ static int write_dump_pages(DumpState *s) > ret =3D write_cache(&page_data, buf, TARGET_PAGE_SIZE, false); > g_free(buf); > if (ret < 0) { > - dump_error(s, "dump: failed to write page data(zero page).\n")= ; > + dump_error(s, errp, "dump: failed to write page data(zero page= )."); Pre-existing, but worth fixing: space before () in English sentences. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --20RvcCX0uSr7Dp9tlr6Cc3sDcJGoBNDxB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUDxhsAAoJEKeha0olJ0Nq/qMH/iyOVnHsNFSaHgIk2Jdwlcqj BKyPGAVd0swGY96OZx4mtR/Cu1DzHI5Q3+Y05QUVgZaT3IIzKxp5I6tQ9HGaKxbv hfjwvahbqXYsLRfdnguSDRByw5glQN6Z8ecQzyxQsXEsmh6xoJXV6tNKztVFZngN lxZM0LK5nNbqFQygEEPJXLJnOefmbkdUa7g16+p9vkRNA8RXOgZHV7OOzJv0Az5c GJJjUnBM9WXf3JjY2NR16rK1mo0AIpX4HKrz+fukbd4KmTRzrP9wq8EiNr4yAljA SXEQ2QD2fP3/8pBfhER5ipUeAYGZWHufTOPV25Uw66q5n0cpNF8VBOKLuPHtka8= =h7ic -----END PGP SIGNATURE----- --20RvcCX0uSr7Dp9tlr6Cc3sDcJGoBNDxB--