Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS/ptrace: Update mips_get_syscall_arg's return type

clang warns:

arch/mips/include/asm/syscall.h:136:3: error: variable 'ret' is
uninitialized when used here [-Werror,-Wuninitialized]
ret |= mips_get_syscall_arg(args++, task, regs, i++);
^~~
arch/mips/include/asm/syscall.h:129:9: note: initialize the variable
'ret' to silence this warning
int ret;
^
= 0
1 error generated.

It's not wrong; however, it's not an issue in practice because ret is
only assigned to, not read from. ret could just be initialized to zero
but looking into it further, ret has been unused since it was first
added in 2012 so just get rid of it and update mips_get_syscall_arg's
return type since none of the return values are ever checked. If it is
ever needed again, this commit can be reverted and ret can be properly
initialized.

Fixes: c0ff3c53d4f9 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.")
Link: https://github.com/ClangBuiltLinux/linux/issues/604
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: James Hogan <jhogan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: linux-mips@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: clang-built-linux@googlegroups.com

authored by

Nathan Chancellor and committed by
Paul Burton
077ff3be c2869aaf

+7 -14
+7 -14
arch/mips/include/asm/syscall.h
··· 54 54 task_thread_info(task)->syscall = regs->regs[2]; 55 55 } 56 56 57 - static inline unsigned long mips_get_syscall_arg(unsigned long *arg, 57 + static inline void mips_get_syscall_arg(unsigned long *arg, 58 58 struct task_struct *task, struct pt_regs *regs, unsigned int n) 59 59 { 60 60 unsigned long usp __maybe_unused = regs->regs[29]; ··· 63 63 case 0: case 1: case 2: case 3: 64 64 *arg = regs->regs[4 + n]; 65 65 66 - return 0; 66 + return; 67 67 68 68 #ifdef CONFIG_32BIT 69 69 case 4: case 5: case 6: case 7: 70 - return get_user(*arg, (int *)usp + n); 70 + get_user(*arg, (int *)usp + n); 71 + return; 71 72 #endif 72 73 73 74 #ifdef CONFIG_64BIT 74 75 case 4: case 5: case 6: case 7: 75 76 #ifdef CONFIG_MIPS32_O32 76 77 if (test_tsk_thread_flag(task, TIF_32BIT_REGS)) 77 - return get_user(*arg, (int *)usp + n); 78 + get_user(*arg, (int *)usp + n); 78 79 else 79 80 #endif 80 81 *arg = regs->regs[4 + n]; 81 82 82 - return 0; 83 + return; 83 84 #endif 84 85 85 86 default: ··· 127 126 { 128 127 unsigned int i = 0; 129 128 unsigned int n = 6; 130 - int ret; 131 129 132 130 /* O32 ABI syscall() */ 133 131 if (mips_syscall_is_indirect(task, regs)) 134 132 i++; 135 133 136 134 while (n--) 137 - ret |= mips_get_syscall_arg(args++, task, regs, i++); 138 - 139 - /* 140 - * No way to communicate an error because this is a void function. 141 - */ 142 - #if 0 143 - return ret; 144 - #endif 135 + mips_get_syscall_arg(args++, task, regs, i++); 145 136 } 146 137 147 138 extern const unsigned long sys_call_table[];