[PATCH v13 06/30] powerpc/ptrace: Adapt gpr32_get, gpr32_set functions for transaction

Daniel Axtens dja at axtens.net
Thu Aug 4 16:36:22 AEST 2016


Hi all,

This is causing cppcheck warnings (having just landed in next):

[arch/powerpc/kernel/ptrace.c:2062]: (error) Uninitialized variable: ckpt_regs
[arch/powerpc/kernel/ptrace.c:2130]: (error) Uninitialized variable: ckpt_regs

This is from...
> -static int gpr32_get(struct task_struct *target,
> +static int gpr32_get_common(struct task_struct *target,
>  		     const struct user_regset *regset,
>  		     unsigned int pos, unsigned int count,
> -		     void *kbuf, void __user *ubuf)
> +			    void *kbuf, void __user *ubuf, bool tm_active)
>  {
>  	const unsigned long *regs = &target->thread.regs->gpr[0];
> +	const unsigned long *ckpt_regs;
>  	compat_ulong_t *k = kbuf;
>  	compat_ulong_t __user *u = ubuf;
>  	compat_ulong_t reg;
>  	int i;
>  
> -	if (target->thread.regs == NULL)
> -		return -EIO;
> +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
> +	ckpt_regs = &target->thread.ckpt_regs.gpr[0];
> +#endif
> +	if (tm_active) {
> +		regs = ckpt_regs;
... this bit here. If the ifdef doesn't trigger, cppcheck can't find an
initialisation for ckpt_regs, so it complains.

Techinically it's a false positive as (I assume!) tm_active cannot ever
be true in the absense of CONFIG_PPC_TRANSACTIONAL_MEM.

Is there a nice simple fix we could deploy to squash this warning, or
will we just live with it?

> -static int gpr32_set(struct task_struct *target,
> +static int gpr32_set_common(struct task_struct *target,
>  		     const struct user_regset *regset,
>  		     unsigned int pos, unsigned int count,
> -		     const void *kbuf, const void __user *ubuf)
> +		     const void *kbuf, const void __user *ubuf, bool tm_active)
>  {
>  	unsigned long *regs = &target->thread.regs->gpr[0];
> +	unsigned long *ckpt_regs;
>  	const compat_ulong_t *k = kbuf;
>  	const compat_ulong_t __user *u = ubuf;
>  	compat_ulong_t reg;
>  
> -	if (target->thread.regs == NULL)
> -		return -EIO;
> +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
> +	ckpt_regs = &target->thread.ckpt_regs.gpr[0];
> +#endif
>  
> -	CHECK_FULL_REGS(target->thread.regs);
> +	if (tm_active) {
> +		regs = ckpt_regs;
FWIW it happens again here.

Regards,
Daniel Axtens
-------------- 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/20160804/88736b2c/attachment.sig>


More information about the Linuxppc-dev mailing list