Skip to content

Commit 3694bd7

Browse files
mrutland-armctmarinas
authored andcommitted
asm-generic: Fix local variable shadow in __set_fixmap_offset
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. To avoid the issue with namespace clashes, 'addr' is prefixed with a liberal sprinkling of underscores. Turning __set_fixmap_offset into a static inline breaks the build for several architectures. Fixing this properly requires updates to a number of architectures to make them agree on the prototype of __set_fixmap (it could be done as a subsequent patch series). Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Arnd Bergmann <arnd@arndb.de> [catalin.marinas@arm.com: squashed the original function patch and macro fixup] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 18558ca commit 3694bd7

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎include/asm-generic/fixmap.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr)
7070
#endif
7171

7272
/* Return a pointer with offset calculated */
73-
#define __set_fixmap_offset(idx, phys, flags) \
74-
({ \
75-
unsigned long addr; \
76-
__set_fixmap(idx, phys, flags); \
77-
addr = fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \
78-
addr; \
73+
#define __set_fixmap_offset(idx, phys, flags) \
74+
({ \
75+
unsigned long ________addr; \
76+
__set_fixmap(idx, phys, flags); \
77+
________addr = fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \
78+
________addr; \
7979
})
8080

8181
#define set_fixmap_offset(idx, phys) \

0 commit comments

Comments
 (0)