Re: [PATCH] vgaswitcheroo: Fix error checking in vga_switcheroo_register_audio_client()
From: Jani Nikula
Date: Wed Feb 19 2025 - 14:27:00 EST
On Wed, 19 Feb 2025, Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
> 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.
This I did know.
> 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.
But somehow I'd failed to appreciate GCC/Clang actually do use unsigned
and signed on a case by case basis. I thought they defaulted to signed
int. TIL.
And I still consider myself a rather experienced C coder. There must be
something wrong with either C or me. Or possibly both.
Thanks,
Jani.
>
> enum u32_values {
> zero,
> };
>
> enum s32_values {
> minus_one = -1,
> zero,
> };
>
> enum u64_values {
> big = 0xfffffffffUL;
> };
>
> regards,
> dan carpenter
>
--
Jani Nikula, Intel