Re: const-correctness warnings from gcc -Wwrite-strings?

From: Valdis . Kletnieks
Date: Mon May 04 2009 - 22:47:21 EST


On Mon, 04 May 2009 17:00:59 PDT, Chris Peterson said:
> I am preparing a patch that would fix some const-correctness warnings
> when compiling the kernel with gcc -Wwrite-strings. I am not (yet?)
> proposing that the kernel Makefile should use -Wwrite-strings.
>
> String constants are not writable, but without -Wwrite-strings, gcc
> pretends string constants have type non-const char[] to support lazy
> legacy code. :)

Do you have an estimate of how large/intrusive the patch will end up being?

Tossing in a few 'const' s in function signatures shouldn't be too bad.
A bigger problem will be code that does stuff like:

const char foo[] = "defaultstr";

void bar (char *wumpus)
{
baz(wumpus?wumpus:foo);
}

which might get more interesting...

Attachment: pgp00000.pgp
Description: PGP signature