Skip to content

Commit 61646ca

Browse files
keessuryasaimadhu
authored andcommitted
x86/uaccess: Move variable into switch case statement
When building with automatic stack variable initialization, GCC 12 complains about variables defined outside of switch case statements. Move the variable into the case that uses it, which silences the warning: ./arch/x86/include/asm/uaccess.h:317:23: warning: statement will never be executed [-Wswitch-unreachable] 317 | unsigned char x_u8__; \ | ^~~~~~ Fixes: 865c50e ("x86/uaccess: utilize CONFIG_CC_HAS_ASM_GOTO_OUTPUT") Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 0fcfb00 commit 61646ca

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/x86/include/asm/uaccess.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,12 @@ do { \
314314
do { \
315315
__chk_user_ptr(ptr); \
316316
switch (size) { \
317-
unsigned char x_u8__; \
318-
case 1: \
317+
case 1: { \
318+
unsigned char x_u8__; \
319319
__get_user_asm(x_u8__, ptr, "b", "=q", label); \
320320
(x) = x_u8__; \
321321
break; \
322+
} \
322323
case 2: \
323324
__get_user_asm(x, ptr, "w", "=r", label); \
324325
break; \

0 commit comments

Comments
 (0)