On 1 April 2014 16:10, James Bottomley <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx> wrote: > On Sun, 2014-03-30 at 15:30 +0200, Mathias Krause wrote: >> The format strings for various printk()s make use of a temporary >> variable that is declared 'static'. This is probably not intended, >> so fix those. > > Actually, it was intended. It was to work around an assignment to const > gcc bug: some versions of gcc won't allow the first assignment to an > uninitialised const. Could it be you're mixing up 'const char *' with 'char *const'? The latter would be the wrong type and would generate an error when tying to be assigned after initialization. But the former is totally fine. In fact, it is fine with ancient versions of gcc as well. The oldest one I managed to get running on my system is gcc 2.7.2.3 from 1998. It compiled this little example just fine: ,--[ test.c ]--- | static const char *strings[] = { | "foo", "bar%s", "ba%z" | }; | | int main(int argc, char **argv) { | const char *s; | | s = strings[argc]; | printf(s, "got ya!"); | putchar('\n'); | | return 0; | } `--- The same is true for gcc 3.2 -- the oldest supported version according to README. It compiles the above example just fine. > I can't remember how long ago this was, but > probably at least 10 years, so it's likely whatever version of gcc that > caused the problem is long gone, but someone should check this > modification works on our earliest supported version. I haven't tried compiling the kernel with those old compilers -- I've installed them in a very basic chroot environment only -- but as this is a very common used pattern, pretty much the rest of the kernel wouldn't compile either if gcc would require quirks like this. It's standard C, after all. Thanks, Mathias -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html