Skip to content

Commit acea994

Browse files
Jump2233KAGA-KOKO
authored andcommitted
vdso: Address variable shadowing in macros
Compiling the kernel with gcc12.3 W=2 results in shadowing warnings: warning: declaration of '__pptr' shadows a previous local [-Wshadow] const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); note: in definition of macro '__put_unaligned_t' __pptr->x = (val); note: in expansion of macro '__get_unaligned_t' __put_unaligned_t(type, __get_unaligned_t(type, src), dst); __get_unaligned_t() and __put_unaligned_t() use a local variable named '__pptr', which can lead to variable shadowing when these macros are used in the same scope. This results in a -Wshadow warning during compilation. To address this issue, rename the local variables within the macros to ensure uniqueness. Signed-off-by: Peng Jiang <jiang.peng9@zte.com.cn> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20250324191230477zpGtgIRSH4mEHdtxGtgx9@zte.com.cn
1 parent 92e250c commit acea994

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

include/vdso/unaligned.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
#ifndef __VDSO_UNALIGNED_H
33
#define __VDSO_UNALIGNED_H
44

5-
#define __get_unaligned_t(type, ptr) ({ \
6-
const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \
7-
__pptr->x; \
5+
#define __get_unaligned_t(type, ptr) ({ \
6+
const struct { type x; } __packed * __get_pptr = (typeof(__get_pptr))(ptr); \
7+
__get_pptr->x; \
88
})
99

10-
#define __put_unaligned_t(type, val, ptr) do { \
11-
struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \
12-
__pptr->x = (val); \
10+
#define __put_unaligned_t(type, val, ptr) do { \
11+
struct { type x; } __packed * __put_pptr = (typeof(__put_pptr))(ptr); \
12+
__put_pptr->x = (val); \
1313
} while (0)
1414

1515
#endif /* __VDSO_UNALIGNED_H */

0 commit comments

Comments
 (0)