qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/5] sparc: fix expression with uninitialized in


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH 2/5] sparc: fix expression with uninitialized initial value
Date: Mon, 30 Jul 2012 18:59:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120713 Thunderbird/14.0

Am 30.07.2012 18:13, schrieb Peter Maydell:
> On 30 July 2012 17:04,  <address@hidden> wrote:
>> From: Blue Swirl <address@hidden>
>>
>> err was uninitalized, it's not OK to use |=. Spotted by Clang
> 
> "uninitialized" (feel free to just fix typo on commit).
> 
>> compiler.
>>
>> Fix by replacing |= by =.
>>
>> Signed-off-by: Blue Swirl <address@hidden>
>> ---
>>  linux-user/signal.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/linux-user/signal.c b/linux-user/signal.c
>> index 97f30d9..3d6b5df 100644
>> --- a/linux-user/signal.c
>> +++ b/linux-user/signal.c
>> @@ -2061,7 +2061,7 @@ restore_fpu_state(CPUSPARCState *env, 
>> qemu_siginfo_fpu_t *fpu)
>>          err = __copy_from_user(&env->fpr[0], &fpu->si_float_regs[0],
>>                                      (sizeof(unsigned long) * 32));
>>  #endif
>> -        err |= __get_user(env->fsr, &fpu->si_fsr);
>> +        err = __get_user(env->fsr, &fpu->si_fsr);
>>  #if 0
>>          err |= __get_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
>>          if (current->thread.fpqdepth != 0)
> 
> This will need changing again if we ever fix the #if 0-d out
> code in this function, but I guess that will be obvious to whoever
> does that.

You mean the #endif part? Would an explicit err = 0 make things better?

Andreas

> 
> Incidentally, __get_user() can never fail [we catch unreadable memory
> earlier when wo do the lock_user_struct] so you could also just
> not do anything with its return value. Some of the other targets
> rely on this in their signal save/restore code. I think the use
> of the return value is mostly in code that was copy-and-pasted
> from the Linux kernel (which does use a __get_user() that can fail).
> 
> Reviewed-by: Peter Maydell <address@hidden>
> 
> -- PMM

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]