nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again

2013-02-04 20:57:24
Okay, seems clear enough.  But I'm wondering what the "right" solution
is here.  Should we simply convert things like the format engine over
to use unsigned char for everything?  Considering that we're starting
to support 8-bit characters more and more, that seems like the best
solution.

Agreed.  I think we should chip away at these things.

So, I tried working on that today ... and you know what?  That's a GIGANTIC
pain.

The real problem is this: while unsigned char is required to prevent sign
extension from happening when using the ctype macros (because they take
int), every OTHER string function takes an unqualified char *.  E.g.,
strcpy, strcmp, mbtowc(), etc etc.  printf() and friends luckily end up
okay because the typing doesn't generate a warning with variable arguments
(or at least gcc doesn't complain about it).

So you ended up with some wholesale interface changes, _and_ you had a bunch
more cast's to (char *).  The whole thing felt wrong; it was too huge.

I poked around a bit, and I found this thread:

        http://seclists.org/nmap-dev/2009/q3/209        

What they settled on was casting the arguments to the ctype functions/macros
using (int) (unsigned char), which seems like overkill to me; I think really
casting to unsigned char would be sufficient.  That seems to be what other
packages have done.  This would mean we'd change back all current unsigned
char *'s to just char *'s (it looks like m_getfld() has always taken
arguments of unsigned char *, so I am neutral about changing that; I don't
know why that's been the case).

--Ken

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>