On Thu, Jan 25, 2024 at 11:07:41 -0800, Andrea Bolognani wrote:
On Thu, Jan 25, 2024 at 03:50:33PM +0100, Peter Krempa wrote:
> On Wed, Jan 24, 2024 at 20:37:45 +0100, Andrea Bolognani wrote:
> > +static int
>
> IMO at this point you can return virDomainChrSerialTargetModel.
Sure, I can try that. But what's the advantage? Ultimately we store
most (all?) models as int inside structs, and only cast them to the
This pattern is discouraged and being actively elliminated. The main
reason for this pattern to exist was that the enum*TypeFromString
function returns -1 on error, so you can't directly assign it into a
enum type which is unsigned.
proper enum type for switches. Which is a real shame, obviously, but
IIRC was done for Some Actual Reason™. Or am I misremembering?
The additional reason here is that if somebody will be editting this
function and decide to add a return of an arbitrary -1 or -2, returning
a proper enum type will make them reconsider what they are doing and
look at all callers before doing so.