Eric Blake writes: > On 10/21/2015 09:03 AM, Lluís Vilanova wrote: >> Hi, >> >> I was wondering what is the proper way (or ways, depending on the subsystem) >> 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: >> >> * 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 >> >> So, is there any agreement on what should be used? If so, could that please >> 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 -- "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