RE: [PATCH v3] serial: make uart_console_write->putchar()'s character an unsigned char

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Maciej W. Rozycki
> Sent: 03 March 2022 11:31
..
>  It does, but, oh dear, it's a "solution" to a problem we have created in
> the first place.  Why do we ever want to have signed characters in the TTY
> layer, and then to vary between platforms?  It's asking for portability
> issues.

C 'char' is signed because the pdp/11 byte load sign extended.

I guess some ABI use unsigned char to avoid issues with all
the functions that take/return an int parameter that is
either a 'char' cast to 'unsigned char' or EOF.

EOF is usually (-1) - but doesn't have to be.
But it needs to be different from any value obtained
by casting a 'char' to 'unsigned char'.
(But that may only need to be all characters, not all values of 'char'.)

Then you get the requirement that:
	sizeof (int) >= sizeof (short) >= sizeof (char)
which means that it is perfectly valid for all 3 to be the same size [1].
In that case 'unsigned char' promotes to 'unsigned int'
which probably breaks some code.
It also makes defining EOF troublesome!

[1] The C compiler for a DSP had this 'feature'.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux