qemu-devel
[Top][All Lists]
Advanced

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

Re: Questionable aspects of QEMU Error's design


From: Peter Maydell
Subject: Re: Questionable aspects of QEMU Error's design
Date: Thu, 2 Apr 2020 08:11:11 +0000

On Thu, 2 Apr 2020 at 07:11, Vladimir Sementsov-Ogievskiy
<address@hidden> wrote:
> Somehow, in general, especially with long function names and long parameter 
> lists I prefer
>
> ret = func(..);
> if (ret < 0) {
>      return ret;
> }

Personally I prefer the other approach -- this one has an extra line
in the source and
needs an extra local variable.

> Are you sure that adding a lot of boolean functions is a good idea? I somehow 
> feel better with more usual int functions with -errno on failure.
>
> Bool is a good return value for functions which are boolean by nature: 
> checks, is something correspond to some criteria. But for reporting an error 
> I'd prefer -errno.

When would we want to return an errno? I thought the whole point of the
Error* was that that was where information about the error was returned.
If all your callsites are just going to do "if (ret < 0) { ... } then having
the functions pick an errno value to return is just extra work.

thanks
-- PMM



reply via email to

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