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

Attachment: signature.asc
Description: PGP signature

Reply via email to