diff options
author | Mike Rapoport | 2020-06-27 11:16:53 +0300 |
---|---|---|
committer | David S. Miller | 2020-07-21 18:25:59 -0700 |
commit | c0d5b0c721b67d13796914031cc8b9bbf2c7f453 (patch) | |
tree | 9578ec169cd59c43f04aeeeae1ba4fe4b6cfd5d4 /arch/sparc/include | |
parent | 72a7af33e08083c118b57c93c1456cc9a5045dc6 (diff) |
sparc32: srmmu: improve type safety of __nocache_fix()
The __nocache_fix(VADDR) macro is used to add an offset for pointers and
its "return type" is 'void *'.
We can do better and keep the type information with simply by casting the
return value to (__typeof__(VADDR)).
This will ".. show when those pgd/p4d/pud pointers get mis-used because
they don't end up dropping the type info.."
The addition of the casting to __nocache_fix() also allows to remove
explicit casts at its call sites.
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Link: https://lkml.kernel.org/r/CAHk-=wisORTa7QVPnFqNw9pFs62UiwgsD4C4d=MtYy1o4JPyGQ@mail.gmail.com
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/include')
-rw-r--r-- | arch/sparc/include/asm/pgtsrmmu.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h index 7708d015712b..6067925972d9 100644 --- a/arch/sparc/include/asm/pgtsrmmu.h +++ b/arch/sparc/include/asm/pgtsrmmu.h @@ -113,7 +113,7 @@ extern unsigned long last_valid_pfn; extern void *srmmu_nocache_pool; #define __nocache_pa(VADDR) (((unsigned long)VADDR) - SRMMU_NOCACHE_VADDR + __pa((unsigned long)srmmu_nocache_pool)) #define __nocache_va(PADDR) (__va((unsigned long)PADDR) - (unsigned long)srmmu_nocache_pool + SRMMU_NOCACHE_VADDR) -#define __nocache_fix(VADDR) __va(__nocache_pa(VADDR)) +#define __nocache_fix(VADDR) ((__typeof__(VADDR))__va(__nocache_pa(VADDR))) /* Accessing the MMU control register. */ unsigned int srmmu_get_mmureg(void); |