Skip to contentSkip to conversation

arm64: avoid clang warning about self-assignment

PATCH In review Arnd Bergmann 2 participants 2 messages Feb 22, 2019 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: avoid clang warning about self-assignment

Building a preprocessed source file for arm64 now always produces a warning with clang because of the page_to_virt() macro assigning a variable to itself.

Adding a new temporary variable avoids this issue.

Fixes 2813b9c02962 ("kasan, mm, arm64: tag non slab memory allocated via pagealloc")
---
 arch/arm64/include/asm/memory.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/include/asm/memory.h +3 -2
index b01ef0180a03..290195168bb3 100644
@@ -312,8 +312,9 @@ static inline void *phys_to_virt(phys_addr_t x)
 #define page_to_virt(page)	({					\
 	unsigned long __addr =						\
 		((__page_to_voff(page)) | PAGE_OFFSET);			\
-	__addr = __tag_set(__addr, page_kasan_tag(page));		\
-	((void *)__addr);						\
+	unsigned long __addr_tag =					\
+		 __tag_set(__addr, page_kasan_tag(page));		\
+	((void *)__addr_tag);						\
 })
 
 #define virt_to_page(vaddr)	((struct page *)((__virt_to_pgoff(vaddr)) | VMEMMAP_START))
Signature · 1 line
2.20.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Arnd Bergmann

Building a preprocessed source file for arm64 now always produces a warning with clang because of the page_to_virt() macro assigning a variable to itself.

Adding a new temporary variable avoids this issue.

Fixes 2813b9c02962 ("kasan, mm, arm64: tag non slab memory allocated via pagealloc")

Thanks!

Quoted 23 lines
---
 arch/arm64/include/asm/memory.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/include/asm/memory.h +3 -3
index b01ef0180a03..290195168bb3 100644
@@ -312,8 +312,9 @@ static inline void *phys_to_virt(phys_addr_t x)
 #define page_to_virt(page)     ({                                      \
        unsigned long __addr =                                          \
                ((__page_to_voff(page)) | PAGE_OFFSET);                 \
-       __addr = __tag_set(__addr, page_kasan_tag(page));               \
-       ((void *)__addr);                                               \
+       unsigned long __addr_tag =                                      \
+                __tag_set(__addr, page_kasan_tag(page));               \
+       ((void *)__addr_tag);                                           \
 })
 
 #define virt_to_page(vaddr)    ((struct page *)((__virt_to_pgoff(vaddr)) | VMEMMAP_START))
--

2.20.0