From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZozGr-0007on-3g for qemu-devel@nongnu.org; Wed, 21 Oct 2015 15:42:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZozGn-00075k-Ts for qemu-devel@nongnu.org; Wed, 21 Oct 2015 15:42:01 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:41583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZozGn-00075C-IX for qemu-devel@nongnu.org; Wed, 21 Oct 2015 15:41:57 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <8737x4p8l9.fsf@fimbulvetr.bsc.es> <5627ABF3.10408@redhat.com> Date: Wed, 21 Oct 2015 21:41:55 +0200 In-Reply-To: <5627ABF3.10408@redhat.com> (Eric Blake's message of "Wed, 21 Oct 2015 09:14:59 -0600") Message-ID: <877fmgau0s.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] Coding style for errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Markus Armbruster Eric Blake writes: > On 10/21/2015 09:03 AM, Llu=C3=ADs Vilanova wrote: >> Hi, >>=20 >> I was wondering what is the proper way (or ways, depending on the subsys= tem) of >> reporting and signalling errors in QEMU. The coding style file does not = seem to >> mention it, and the code uses all kinds of forms for that: >>=20 >> * printf + exit(1) >> * fprintf(stderr) + exit(1) > Existing code doesn't all have to be switched, but new code... >> * error_report + exit(1) > ...should favor this approach, or even: > error_setg(..., &error_fatal) > as shorthand. Aha! That's what I was looking for, which provides both exit and abort :) >> * cpu_abort >> * Some other I probably forgot >>=20 >> So, is there any agreement on what should be used? If so, could that ple= ase be >> added to CODING_STYLE? > include/qapi/error.h has more documentation on how to best use struct > Error and the various error_* functions, but you're right that a blurb > in CODING_STYLE can't hurt. Would you care to try writing a first draft? I'll try to give it a swirl tomorrow. Cheers, Lluis --=20 "And it's much the same thing with knowledge, for whenever you learn something new, the whole world becomes that much richer." -- The Princess of Pure Reason, as told by Norton Juster in The Phantom Tollbooth