On Wed, Oct 02, 2019 at 02:07:50PM +0300, Nikolay Borisov wrote: > > +struct list_head * __attribute_const__ btrfs_get_fs_uuids(void) > > I'm not entirely sure this function is cons. According to the manual: > > Calls to functions whose return value is not affected by changes to the > observable state of the program and that have no observable effects on > such state other than to return a value may lend themselves to > optimizations such as common subexpression elimination. > > The const attribute prohibits a function from reading objects that > affect its return value between successive invocations. However, > functions declared with the attribute can safely read objects that do > not change their return value, such as non-volatile constants. > > > My doubt stems from the fact this function actually references outside > memory, namely gets the ptr to fs_uuids. There is a specific remark not > to use const when the function takes a ptr argument but it doesn't say > anything when getting a ptr from a global var.
The fs_uuids are a non-volatile constant. It does not change accross the lifetime of the module, so all code executed will always see the same value.