[PATCH] powerpc/ptrace: Fix cppcheck issue in gpr32_set_common/gpr32_get_common.
wei.guo.simon at gmail.com
Wed Aug 24 17:38:27 AEST 2016
On Wed, Aug 24, 2016 at 12:21:23PM +1000, Daniel Axtens wrote:
> Hi Simon,
> > 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 :)
> > 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)
> > +#endif
> I 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.
More information about the Linuxppc-dev