[PATCH] powerpc/ptrace: Fix cppcheck issue in gpr32_set_common/gpr32_get_common.
Daniel Axtens
dja at axtens.net
Wed Aug 24 12:21:23 AEST 2016
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 :)
> 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:
> @@ -2218,7 +2225,11 @@ static int gpr32_get(struct task_struct *target,
> unsigned int pos, unsigned int count,
> void *kbuf, void __user *ubuf)
> {
> +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
> return gpr32_get_common(target, regset, pos, count, kbuf, ubuf, 0);
> +#else
> + return gpr32_get_common(target, regset, pos, count, kbuf, ubuf);
> +#endif
> }
>
> static int gpr32_set(struct task_struct *target,
> @@ -2226,7 +2237,11 @@ static int gpr32_set(struct task_struct *target,
> unsigned int pos, unsigned int count,
> const void *kbuf, const void __user *ubuf)
> {
> +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
> return gpr32_set_common(target, regset, pos, count, kbuf, ubuf, 0);
> +#else
> + return gpr32_set_common(target, regset, pos, count, kbuf, ubuf);
> +#endif
> }
Apart from that, thanks for fixing this up!
Regards,
Daniel
>
> /*
> --
> 1.8.3.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 859 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20160824/031eaffb/attachment.sig>
More information about the Linuxppc-dev
mailing list