From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDRuc-0007dd-UE for qemu-devel@nongnu.org; Thu, 16 Jun 2016 03:40:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDRuX-000569-Ux for qemu-devel@nongnu.org; Thu, 16 Jun 2016 03:40:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56779) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDRuX-00055i-OU for qemu-devel@nongnu.org; Thu, 16 Jun 2016 03:40:21 -0400 From: Markus Armbruster References: <1466011636-6112-1-git-send-email-armbru@redhat.com> <1466011636-6112-3-git-send-email-armbru@redhat.com> <5761A71D.8070003@redhat.com> Date: Thu, 16 Jun 2016 09:40:19 +0200 In-Reply-To: <5761A71D.8070003@redhat.com> (Eric Blake's message of "Wed, 15 Jun 2016 13:06:05 -0600") Message-ID: <87a8ilfuos.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain 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: Eric Blake Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, alex.bennee@linaro.org Eric Blake writes: > On 06/15/2016 11:27 AM, Markus Armbruster wrote: >> g_error() is not an acceptable way to report errors to the user: >> >> $ qemu-system-x86_64 -dfilter 1000+0 >> >> ** (process:17187): ERROR **: Failed to parse range in: 1000+0 >> Trace/breakpoint trap (core dumped) >> >> g_assert() isn't, either: >> >> $ qemu-system-x86_64 -dfilter 1000x+64 >> ** >> ERROR:/work/armbru/qemu/util/log.c:180:qemu_set_dfilter_ranges: assertion failed: (e == range_op) >> Aborted (core dumped) > > I see you're trying to improve my range.h patches, and got dragged into > this stuff. Yup, except I'd call it "build upon", not "improve". >> Convert qemu_set_dfilter_ranges() to Error. Rework its deeply nested >> control flow. Touch up the error messages. Call it with >> &error_fatal. >> >> This also permits testing without a subprocess, so do that. >> >> 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(-) >> > >> + qemu_set_dfilter_ranges("0x1000+onehundred", &err); >> + error_free_or_abort(&err); >> + >> + qemu_set_dfilter_ranges("0x1000+0", &err); >> + error_free_or_abort(&err); >> } >> > > Maybe also worth testing "0x" and "0x1000+0x" for being invalid? The former would add a test for the error handling of qemu_set_dfilter_ranges()'s other use of qemu_strtoull(). If it wasn't worth testing before my patch... But I can add a test case anyway, if I need to respin. The latter would basically test an additional error path within qemu_strtoull(). > > Reviewed-by: Eric Blake Thanks!