On 25/11/15 05:06 AM, Clemens Ladisch wrote: > Mathias Krause wrote: >> [...] >> So, prior extending the usage of the __read_only annotation some >> toolchain support is needed. Maybe a gcc plugin that'll warn/error on >> code that writes to such a variable but is not __init itself. > > Or mark them as "const". This would require the initialization code to > cast it away, probably with a helper macro. > > > Regards, > Clemens > That would be undefined. It would only be safe if you exposed a const pointer as the only way of accessing a non-const variable. It would be silly to mangle the code simply to get a warning as it should be easy enough to add to GCC. The usefulness isn't just limited to the kernel either.