Received: from eggs.gnu.org ([2001:4830:134:3::10]:55147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrrNB-0001F0-31 for qemu-devel@nongnu.org; Thu, 29 Oct 2015 13:52:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrrN6-0005yM-Ny for qemu-devel@nongnu.org; Thu, 29 Oct 2015 13:52:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrrN6-0005yF-GL for qemu-devel@nongnu.org; Thu, 29 Oct 2015 13:52:20 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id E9F93AACF9 for ; Thu, 29 Oct 2015 17:52:19 +0000 (UTC) Date: Thu, 29 Oct 2015 15:52:17 -0200 From: Eduardo Habkost Message-ID: <20151029175217.GO4180@thinpad.lan.raisama.net> References: <1446057425-16891-1-git-send-email-ehabkost@redhat.com> <1446057425-16891-2-git-send-email-ehabkost@redhat.com> <87bnbhvarr.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87bnbhvarr.fsf@blackfin.pond.sub.org> Subject: Re: [Qemu-devel] [PATCH v2 01/16] vl.c: Replace fprintf(stderr) with error_report() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Paolo Bonzini , Andrew Jones , qemu-devel@nongnu.org On Thu, Oct 29, 2015 at 06:34:48PM +0100, Markus Armbruster wrote: > Eduardo Habkost writes: > > > Replace most fprintf(stderr) calls on vl.c with error_report(). > > > > Minimal changes were made in the error messages. Only the trailing > > newlines, "qemu:" and "error:" message prefixes were removed. > > > > The only remaining fprintf(stderr) calls are the ones at > > qemu_kill_report(), because the error mesage is split in multiple > > fprintf() calls. > > > > Reviewed-by: Markus Armbruster > > Reviewed-by: Eric Blake > > Signed-off-by: Eduardo Habkost > > --- > > Changes v1 -> v2: > > * Indentation fix at "No machine specified" error message > > --- > > vl.c | 228 +++++++++++++++++++++++++++++++++---------------------------------- > > 1 file changed, 112 insertions(+), 116 deletions(-) > > > > diff --git a/vl.c b/vl.c > > index f5f7c3f..25b91fc 100644 > > --- a/vl.c > > +++ b/vl.c > > @@ -674,9 +674,9 @@ void runstate_set(RunState new_state) > > assert(new_state < RUN_STATE_MAX); > > > > if (!runstate_valid_transitions[current_run_state][new_state]) { > > - fprintf(stderr, "ERROR: invalid runstate transition: '%s' -> '%s'\n", > > - RunState_lookup[current_run_state], > > - RunState_lookup[new_state]); > > + error_report("invalid runstate transition: '%s' -> '%s'", > > + RunState_lookup[current_run_state], > > + RunState_lookup[new_state]); > > abort(); > > } > > trace_runstate_set(new_state); > > @@ -828,8 +828,8 @@ static void configure_rtc_date_offset(const char *startdate, int legacy) > > rtc_start_date = mktimegm(&tm); > > if (rtc_start_date == -1) { > > date_fail: > > - fprintf(stderr, "Invalid date format. Valid formats are:\n" > > - "'2006-06-17T16:01:21' or '2006-06-17'\n"); > > + error_report("Invalid date format. Valid formats are:\n" > > + "'2006-06-17T16:01:21' or '2006-06-17'"); > > I'm afraid you violate error_report()'s contract: > > /* > * Print an error message to current monitor if we have one, else to stderr. > * Format arguments like sprintf(). The result should not contain > * newlines. > * Prepend the current location and append a newline. > * It's wrong to call this in a QMP monitor. Use error_setg() there. > */ > > Make it something like > > error_report("invalid date format"); > error_printf("valid formats: '2006-06-17T16:01:21'" > " or '2006-06-17'\n"); Oops, that's what happens when I use existing code as reference, instead of reading the documentation. :) I will fix it. Thanks. -- Eduardo