[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87r03tn4su.fsf@intel.com>
Date: Wed, 19 Feb 2025 20:54:41 +0200
From: Jani Nikula <jani.nikula@...ux.intel.com>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Jim Qu <Jim.Qu@....com>, Lukas Wunner <lukas@...ner.de>, Maarten
Lankhorst <maarten.lankhorst@...ux.intel.com>, Maxime Ripard
<mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>, David
Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>, Takashi Iwai
<tiwai@...e.de>, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org, Su Hui
<suhui@...china.com>
Subject: Re: [PATCH] vgaswitcheroo: Fix error checking in
vga_switcheroo_register_audio_client()
On Wed, 19 Feb 2025, Dan Carpenter <dan.carpenter@...aro.org> wrote:
> On Wed, Feb 19, 2025 at 05:17:56PM +0200, Jani Nikula wrote:
>> On Wed, 19 Feb 2025, Dan Carpenter <dan.carpenter@...aro.org> 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
Powered by blists - more mailing lists