qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 2/3] module: add Error arguments to module_load_one and mo


From: Markus Armbruster
Subject: Re: [PATCH v4 2/3] module: add Error arguments to module_load_one and module_load_qom_one
Date: Thu, 22 Sep 2022 15:20:29 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Claudio Fontana <cfontana@suse.de> writes:

[...]

> I think it would be better to completely make the return value separate from 
> the Error,
> and really treat Error as an exception and not mix it up with the regular 
> execution,
>
> but if it is the general consensus that I am the only one seeing this 
> conflation problem we can model it this way too.

It's a matter of language pragmatics.  In Java, you throw an exception
on error.  In C, you return an error value.

Trying to emulate exceptions in C might be even more unadvisable than
trying to avoid them in Java.  Best to work with the language, not
against it.

Trouble is the error values we can conveniently return in C can't convey
enough information.  So we use Error for that.  Just like GLib uses
GError.

More modern languages do "return error value" much better than C can.  C
is what it is.

We could certainly argue how to do better than we do now in QEMU's C
code.  However, the Error API is used all over the place, which makes
changing it expensive.  "Rethinking the whole Error API" (your words)
would have to generate benefits worth this expense.  Which seems
unlikely.

[...]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]