kernel - is it harmful to use "volatile" in C? -
i new sparse. , during running sparse seeing warning:
warning: wrong type in argument 2 (different address spaces)
expected void volatile [noderef] <asn:2>*addr got void *
basically, happening because of following:
struct context{ void __iomem *base; }; readl(const volatile void __iomem* add){ .... .... } function: foo(){ struct context *var; readl(var->base); //---> here got above mentioned warning }
to prepare did following:
struct context{ - void __iomem *base; + volatile void __iomem *base; };
and warning removed.
my question: - harmful utilize "volatile" in such case. , if yes why? - think should not create fellow member of struct "volatile". but, how can rid off csparse warning.
as per documentation given @ https://www.kernel.org/doc/documentation/volatile-considered-harmful.txt @ http://lwn.net/articles/233482/. should avoid utilize of volatile.
no, it's not harmful. no thought why should or be, harmful what?
if code you're calling expects volatile
pointer, it's wrong pass non-volatile
one, since code in calling context might not adapted requirements of volatile
value in case.
c kernel volatile sparse-matrix
No comments:
Post a Comment