Re: [PATCH] powerpc/ptrace: Fix cppcheck issue in gpr32_set_common/gpr32_get_common.
flat view
From: Simon Guo <hidden>
Date: 2016-08-24 07:38:32
Hi Daniel, On Wed, Aug 24, 2016 at 12:21:23PM +1000, Daniel Axtens wrote:
Hi Simon,quoted
The ckpt_regs usage in gpr32_set_common/gpr32_get_common() will lead to cppcheck error. [arch/powerpc/kernel/ptrace.c:2062]: (error) Uninitialized variable: ckpt_regs [arch/powerpc/kernel/ptrace.c:2130]: (error) Uninitialized variable: ckpt_regs A straightforward fix to clean it.I'm always happy to see cppcheck warnings fixed :)
Thanks for raising this issue :)
quoted
static int gpr32_get_common(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM void *kbuf, void __user *ubuf, bool tm_active) +#else + void *kbuf, void __user *ubuf) +#endifI wonder if it might be possible to avoid some of the ifdefs and general churn by making the tm_active argument __maybe_unused rather than ifdefing around it? In particular, it would mean the two hunks in the function definitions and these these two hunks at the call site would be unnecessary:
I think keeping tm_active argument for "ifndef CONFIG_PPC_TRANSACTIONAL_MEM" case (with __maybe_unused prefix) will be somehow strange -- Whatever value is provided in the caller function for tm_active, programmer might be puzzled and cost sometime to think about it. I don't like to use "__maybe_unused" to bypass this warning. Thanks, - Simon