[PATCH] asm-generic: Avoid variable in __set_fixmap_offset

From: Mark Rutland
Date: Tue Feb 09 2016 - 06:43:55 EST


Currently __set_fixmap_offset is a macro function which has a local
variable called 'addr'. If a caller passes a 'phys' parameter which is
derived from a variable also called 'addr', the local variable will
shadow this, and the compiler will complain about the use of an
uninitialized variable.

It is likely that fixmap users may use the name 'addr' for variables
that may be directly passed to __set_fixmap_offset, or that may be
indirectly generated via other macros. Rather than placing the burden on
callers to avoid the name 'addr', this patch removes the temporary
'addr' variable in __set_fixmap_offset, directly returning the result of
the address calculation.

Signed-off-by: Mark Rutland <mark.rutland@xxxxxxx>
Cc: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
Cc: Jeremy Linton <jeremy.linton@xxxxxxx>
Cc: Laura Abbott <labbott@xxxxxxxxxxxxxxxxx>
Cc: Sudip Mukherjee <sudipm.mukherjee@xxxxxxxxx>
---
include/asm-generic/fixmap.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h
index 1cbb833..ae2cc43 100644
--- a/include/asm-generic/fixmap.h
+++ b/include/asm-generic/fixmap.h
@@ -72,10 +72,8 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr)
/* Return a pointer with offset calculated */
#define __set_fixmap_offset(idx, phys, flags) \
({ \
- unsigned long addr; \
__set_fixmap(idx, phys, flags); \
- addr = fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \
- addr; \
+ fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \
})

#define set_fixmap_offset(idx, phys) \
--
1.9.1