[PATCH v3 02/11] ALSA: firewire-lib/motu: use int type for the value of bitwise OR with enumerator-constant

Takashi Sakamoto o-takashi at sakamocchi.jp
Tue May 18 10:35:36 CEST 2021


On Tue, May 18, 2021 at 10:23:30AM +0200, Takashi Iwai wrote:
> On Tue, 18 May 2021 10:13:34 +0200,
> Takashi Sakamoto wrote:
> > 
> > On Tue, May 18, 2021 at 09:02:54AM +0200, Takashi Iwai wrote:
> > > On Tue, 18 May 2021 04:43:17 +0200,
> > > Takashi Sakamoto wrote:
> > > > 
> > > > It brings some inconvenience in practice to use enumerated type for
> > > > variable to which bitwise OR with enumerator constant is assigned.
> > > > 
> > > > This commit replaces declarations of enumerated type with int type.
> > > 
> > > Better to use unsigned int for bit flags.  Otherwise the highest bit
> > > becomes harder to use.
> > 
> > I can't imagine such situation that the signed value causes issue. Would
> > I request actual example with such issue? At least, the highest bit is
> > still available as bit even if the value is negative by assigning
> > 0x80000000...
> 
> It's available in signed int, but this is inconvenient, e.g. if you
> shift the bit.  Maybe I forgot something else, too.
> 
> You may still use signed int if you are sure that you'll never reach
> to the highest number, but other than that, using unsigned for bit
> flags is a *VERY* common practice in the kernel programming, so there
> is no reason to ignore it.

Ok. I just follow to the convention under the Linux kernel development.


Thanks

Takashi Sakamoto


More information about the Alsa-devel mailing list