[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again
From: |
Ken Hornstein |
Subject: |
Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again |
Date: |
Mon, 04 Feb 2013 21:57:12 -0500 |
>> 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
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, David Levine, 2013/02/04
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again,
Ken Hornstein <=
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Ralph Corderoy, 2013/02/05
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Ken Hornstein, 2013/02/05
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Ralph Corderoy, 2013/02/05
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Ken Hornstein, 2013/02/05
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Lyndon Nerenberg, 2013/02/05
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Ken Hornstein, 2013/02/05
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Tom Lane, 2013/02/05
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Lyndon Nerenberg, 2013/02/05