Re: [PATCH] signed char fixes for scripts
From: Bernd Petrovitsch
Date: Thu Jul 28 2005 - 06:07:46 EST
On Thu, 2005-07-28 at 11:40 +0100, Paulo Marques wrote:
> You're comming really late in this thread :)
Well, the same issue arised recently somewhere else too on this list and
lots of C programmers (not only beginners) don't know about the 3 char
types as speficied in the C standard.
[ The C standard may have got problems recently with the real world
usinf UTF-8 for a printable character but this must be solved
> The problem is that "sym" isn't really a string. It starts out as a
> string, but as the compression scheme begins to work it just becomes a
> "bunch of bytes" using all the values in the range 0-255 for which
> unsigned char is the perfect type.
> Since only the loading of the symbols use string functions, and all the
> compression process treats these as bytes, it seemed better to treat
> them as unsigned chars and just typecast the first few uses.
> The union suggested by J.A.Magallon might be a reasonable solution, but
Syntactically yes. Conceptually no IMHO. sizeof(char) must be ==
sizeof(unsigned char) and must have the same alignment. So a cast seems
to be the simpler and cleaner solution.
> we only need 4 casts in the 500 lines of code of scripts/kallsyms.c to
> solve all problems, so this seems really overkill.
> >>Is my compiler version the problem (3.3.2), or are you testing with the
> > Compiler version - zse gcc-4.*.
> Yes, I know J.A.Magallon is trying to silence the warnings of gcc 4.0,
> but as I understood it, gcc 3 would also complain of the same problems
> if -Wsign-compare were specified. It was just that gcc4 would complain
> even without -Wsign-compare.
AFAIK applies -Wsign-compare in gcc-3 only to pure compares (<, >, ...)
and not assignments/passed parameters too.
> So the question is: is gcc4 complaining about signedness problems that
> gcc3 doesn't, even with -Wsign-compare?
> Now that I look at the source, I can see that it must be complaining!
> There are still 3 calls to strcmp that use sym directly, and gcc3
> doesn't say a thing.
As above - this will probably be silently promoted by gcc-3.
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and Services
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/