From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpFx5-00082M-6c for qemu-devel@nongnu.org; Thu, 22 Oct 2015 09:30:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpFx1-0003Su-4F for qemu-devel@nongnu.org; Thu, 22 Oct 2015 09:30:42 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:41473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpFx0-0003Se-PV for qemu-devel@nongnu.org; Thu, 22 Oct 2015 09:30:39 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <8737x4p8l9.fsf@fimbulvetr.bsc.es> <87si54i2w4.fsf@blackfin.pond.sub.org> Date: Thu, 22 Oct 2015 15:30:34 +0200 In-Reply-To: <87si54i2w4.fsf@blackfin.pond.sub.org> (Markus Armbruster's message of "Wed, 21 Oct 2015 18:48:27 +0200") Message-ID: <87y4ev81z9.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: Markus Armbruster Cc: Peter Maydell , qemu-devel@nongnu.org Markus Armbruster writes: > Llu=C3=ADs Vilanova writes: [...] >> So, is there any agreement on what should be used? If so, could that ple= ase be >> added to CODING_STYLE? > I think HACKING would be a better fit. What about this? (at the end of HACKING) Feel free to add references to oth= er functions you think are important. I'll send a patch once we agree on the t= ext. Cheers, Lluis 7. Error reporting QEMU provides two different mechanisms for reporting errors. You should use= one of these mechanisms instead of manually reporting them (e.g., do not use 'printf', 'exit' or 'abort'). 7.1. Errors in user inputs QEMU provides the functions in "include/qemu/error-report.h" to report erro= rs related to inputs provided by the user (e.g., command line arguments or configuration files). These functions generate error messages with a uniform format that can refe= rence a location on the offending input. 7.2. Other errors QEMU provides the functions in "include/qapi/error.h" to report other types= of errors. Functions in this header are used to accumulate error messages in an 'Error' object, which can be propagated up the call chain where it is finally repor= ted. 7.3. Errors with an immediate exit/abort There are two convenience forms to report errors in a way that immediately terminates QEMU: * 'error_setg(&error_fatal, msg, ...)' Reports a fatal error with the given error message and exits QEMU. * 'error_setg(&error_abort, msg, ...)' Reports a programming error with the given error message and aborts QEMU. For convenience, you can also use 'error_setg_errno' and 'error_setg_win32'= to append a message for OS-specific errors, and 'error_setg_file_open' for err= ors when opening files. --=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