Markus Armbruster writes: > Lluís Vilanova <vilan...@ac.upc.edu> writes: [...] >> So, is there any agreement on what should be used? If so, could that please >> 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 other functions you think are important. I'll send a patch once we agree on the text. 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 errors 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 reference 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 reported. 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 errors when opening files. -- "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