Skip to content

Commit

Permalink
compiler.h, kasan: Avoid duplicating __read_once_size_nocheck()
Browse files Browse the repository at this point in the history
Instead of having two identical __read_once_size_nocheck() functions
with different attributes, consolidate all the difference in new macro
__no_kasan_or_inline and use it. No functional changes.

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Andrey Ryabinin authored and Linus Torvalds committed Feb 1, 2018
1 parent d8a5b80 commit bdb5ac8
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions include/linux/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,21 @@ void __read_once_size(const volatile void *p, void *res, int size)

#ifdef CONFIG_KASAN
/*
* This function is not 'inline' because __no_sanitize_address confilcts
* We can't declare function 'inline' because __no_sanitize_address confilcts
* with inlining. Attempt to inline it may cause a build failure.
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
* '__maybe_unused' allows us to avoid defined-but-not-used warnings.
*/
static __no_sanitize_address __maybe_unused
void __read_once_size_nocheck(const volatile void *p, void *res, int size)
{
__READ_ONCE_SIZE;
}
# define __no_kasan_or_inline __no_sanitize_address __maybe_unused
#else
static __always_inline
# define __no_kasan_or_inline __always_inline
#endif

static __no_kasan_or_inline
void __read_once_size_nocheck(const volatile void *p, void *res, int size)
{
__READ_ONCE_SIZE;
}
#endif

static __always_inline void __write_once_size(volatile void *p, void *res, int size)
{
Expand Down

0 comments on commit bdb5ac8

Please sign in to comment.