]> git.puffer.fish Git - matthieu/frr.git/commit
lib/table: remove nonsensical const, add pure
authorDavid Lamparter <equinox@diac24.net>
Tue, 21 May 2019 02:48:30 +0000 (04:48 +0200)
committerDavid Lamparter <equinox@diac24.net>
Tue, 21 May 2019 03:42:13 +0000 (05:42 +0200)
commit3b18b6c03d0243d9d161d17b875b0bb4c6587f1e
treeeba4a1ac235f8155150d4922c2708a18fbb1b55b
parent0734f93b8ed51de625720346c953bd50e9f40487
lib/table: remove nonsensical const, add pure

Passing the struct route_table *ptr as const doesn't really help; if
anything it semantically would imply that the returned route_node is
const too since constness should propagate (but it doesn't in C.)

The right thing to do here - which actually helps the compiler optimize
the code too - is to tag functions with __attribute__((pure)).  The
compiler does this automatically if it has the function body (and the
body of all called functions) available.  That should cover most "static
inline" functions in headers, as well as functions in the same file.

However, this doesn't work (at least without LTO) for extern functions.
Hence, add "ext_pure" for this case.  (Built-in "extern" to make lines
shorter.)

Signed-off-by: David Lamparter <equinox@diac24.net>
lib/compiler.h
lib/table.c
lib/table.h