From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDG8g-0005Dg-QK for qemu-devel@nongnu.org; Wed, 15 Jun 2016 15:06:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDG8d-00009o-3S for qemu-devel@nongnu.org; Wed, 15 Jun 2016 15:06:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDG8c-00009k-RY for qemu-devel@nongnu.org; Wed, 15 Jun 2016 15:06:07 -0400 References: <1466011636-6112-1-git-send-email-armbru@redhat.com> <1466011636-6112-3-git-send-email-armbru@redhat.com> From: Eric Blake Message-ID: <5761A71D.8070003@redhat.com> Date: Wed, 15 Jun 2016 13:06:05 -0600 MIME-Version: 1.0 In-Reply-To: <1466011636-6112-3-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GNsBbW0MG2xgKcCAeA3KeLg4ofg39Wwae" Subject: Re: [Qemu-devel] [PATCH 2/3] log: Fix qemu_set_dfilter_ranges() error reporting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: pbonzini@redhat.com, alex.bennee@linaro.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --GNsBbW0MG2xgKcCAeA3KeLg4ofg39Wwae Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/15/2016 11:27 AM, Markus Armbruster wrote: > g_error() is not an acceptable way to report errors to the user: >=20 > $ qemu-system-x86_64 -dfilter 1000+0 >=20 > ** (process:17187): ERROR **: Failed to parse range in: 1000+0 > Trace/breakpoint trap (core dumped) >=20 > g_assert() isn't, either: >=20 > $ qemu-system-x86_64 -dfilter 1000x+64 > ** > ERROR:/work/armbru/qemu/util/log.c:180:qemu_set_dfilter_ranges: ass= ertion failed: (e =3D=3D range_op) > Aborted (core dumped) I see you're trying to improve my range.h patches, and got dragged into this stuff. >=20 > Convert qemu_set_dfilter_ranges() to Error. Rework its deeply nested > control flow. Touch up the error messages. Call it with > &error_fatal. >=20 > This also permits testing without a subprocess, so do that. >=20 > Signed-off-by: Markus Armbruster > --- > include/qemu/log.h | 2 +- > tests/test-logging.c | 49 ++++++++-------------- > util/log.c | 113 ++++++++++++++++++++++++++-----------------= -------- > vl.c | 2 +- > 4 files changed, 75 insertions(+), 91 deletions(-) >=20 > + qemu_set_dfilter_ranges("0x1000+onehundred", &err); > + error_free_or_abort(&err); > + > + qemu_set_dfilter_ranges("0x1000+0", &err); > + error_free_or_abort(&err); > } > =20 Maybe also worth testing "0x" and "0x1000+0x" for being invalid? Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --GNsBbW0MG2xgKcCAeA3KeLg4ofg39Wwae Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXYacdAAoJEKeha0olJ0NqM9oH/1iuXh8HTbnUezmes4MvqLlA J9v8wZBQzdg4X3U7EigV7loupAKBE191HAnXXnFPH0m7/vZLo9ymKI4TYW/2B1/H bFRE9PCUYq5Z6Hxl0Xi4UJLZfmxVjNpAtMzPUo5vnluTVROmvnljyehxCjiTIOfC Moh6kenM0scFrpnpILA7X/XO+cvjgFlMkWbm0zGoUsOq3tZ9/GkTOu9jMKmVvB6S Of8+LYq6HbQvE2WFWgEhMdpvsDJ7LqvG/eOKxVdjke6eTfdkds1gNq/n6zelMiom J1tujhmbd6VNi0LuILRV0pgO0BIL+xsTaw8vZBL/L9xgSD9m27RYo/MyUUfIW70= =EOCW -----END PGP SIGNATURE----- --GNsBbW0MG2xgKcCAeA3KeLg4ofg39Wwae--