[Nut-upsdev] gcc4 compiler warnings
Peter Selinger
selinger at mathstat.dal.ca
Fri Feb 10 08:30:27 UTC 2006
Charles Lepple wrote:
>
> On 2/9/06, Arjen de Korte <nut+devel at de-korte.org> wrote:
> > This is due to the fact that some drivers need to pass character values
> > between 0x80 and 0xFF to or from the drivers, but the serial functions us=
> e
> > signed chars. Unless some drivers use negative values, my preference woul=
> d
> > be to fix/create serial functions (to use unsigned chars), rather than to
> > convert the characters between 0x80 and 0xFF to negative numbers.
> > Especially where status bits are used, listing a hex value is more
> > readable then.
>
> I tend to agree with Arjen on this one - most drivers will be treating
> characters as unsigned, since the majority of the values being
> returned are unsigned. The only exceptions I know about are the ones
> that Peter mentioned in libHID, and that code is a mess anyway.
The situation in libhid is not really related, because we are not
reading characters; we are reading bits, actually, and then assemble
them into values (signed or unsigned, with units, exponents, bells,
whistles) quite explicitly.
> Is there a reason why the common serial functions should return signed
> characters?
I can't think of one. In any case, pre-gcc4, many drivers silently
converted these (char *) pointers to (unsigned char *) pointers.
I don't see why the same thing should not work the other way around.
-- Peter
More information about the Nut-upsdev
mailing list