Re: [PATCH] vgaswitcheroo: Fix error checking in vga_switcheroo_register_audio_client()
From: Dan Carpenter
Date: Wed Feb 19 2025 - 11:05:37 EST
On Wed, Feb 19, 2025 at 05:17:56PM +0200, Jani Nikula wrote:
> On Wed, 19 Feb 2025, Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
> > The "id" variable is an enum and in this context it's treated as an
> > unsigned int so the error handling can never trigger.
>
> When would that be true with GCC?
The C standard give compilers a lot of flexibility with regards to enums.
But in terms of GCC/Clang then enums default to unsigned int, if you
declare one as negative then they become signed int. If they don't fit
in int, then they become u64 etc.
enum u32_values {
zero,
};
enum s32_values {
minus_one = -1,
zero,
};
enum u64_values {
big = 0xfffffffffUL;
};
regards,
dan carpenter