* const-correctness warnings from gcc -Wwrite-strings?
@ 2009-05-05 0:00 Chris Peterson
2009-05-05 2:47 ` Valdis.Kletnieks
0 siblings, 1 reply; 2+ messages in thread
From: Chris Peterson @ 2009-05-05 0:00 UTC (permalink / raw)
To: linux-kernel
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. :)
Are these fixes of any interest? The only controversy I see is that
some of the changes affect the function signatures of some ops
structures' function pointers.
chris
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: const-correctness warnings from gcc -Wwrite-strings?
2009-05-05 0:00 const-correctness warnings from gcc -Wwrite-strings? Chris Peterson
@ 2009-05-05 2:47 ` Valdis.Kletnieks
0 siblings, 0 replies; 2+ messages in thread
From: Valdis.Kletnieks @ 2009-05-05 2:47 UTC (permalink / raw)
To: Chris Peterson; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 751 bytes --]
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 #2: Type: application/pgp-signature, Size: 226 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-05 2:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-05 0:00 const-correctness warnings from gcc -Wwrite-strings? Chris Peterson
2009-05-05 2:47 ` Valdis.Kletnieks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®