qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] Fix: fp-test uninitialized member floatX::exp


From: Alex Bennée
Subject: Re: [Qemu-devel] [PATCH] Fix: fp-test uninitialized member floatX::exp
Date: Tue, 13 Aug 2019 13:21:54 +0100
User-agent: mu4e 1.3.4; emacs 27.0.50

Andrey Shinkevich <address@hidden> writes:

> PINGING...

Sorry about the delay. I did attempt see if the existing code threw up
any errors when built with clang's undefined sanitizer. I think this is
because xPtr->exp will only get read if none of the xPtr->isFOO returns
false. In all those cases xPtr->exp is set.

What pointed you towards this missing initialisations?

>
> On 30/07/2019 13:13, Andrey Shinkevich wrote:
>> Not all the paths in the functions, such as f16ToFloatX(), initialize
>> the member 'exp' of the structure floatX.
>>
>> Signed-off-by: Andrey Shinkevich <address@hidden>
>> ---
>>   source/slowfloat.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/tests/fp/berkeley-testfloat-3/source/slowfloat.c 
>> b/tests/fp/berkeley-testfloat-3/source/slowfloat.c
>> index 4e84656..6e0f0a6 100644
>> --- a/tests/fp/berkeley-testfloat-3/source/slowfloat.c
>> +++ b/tests/fp/berkeley-testfloat-3/source/slowfloat.c
>> @@ -623,6 +623,7 @@ static void f16ToFloatX( float16_t a, struct floatX 
>> *xPtr )
>>       xPtr->isInf = false;
>>       xPtr->isZero = false;
>>       xPtr->sign = ((uiA & 0x8000) != 0);
>> +    xPtr->exp = 0;
>>       exp = uiA>>10 & 0x1F;
>>       sig64 = uiA & 0x03FF;
>>       sig64 <<= 45;
>> @@ -759,6 +760,7 @@ static void f32ToFloatX( float32_t a, struct floatX 
>> *xPtr )
>>       xPtr->isInf = false;
>>       xPtr->isZero = false;
>>       xPtr->sign = ((uiA & 0x80000000) != 0);
>> +    xPtr->exp = 0;
>>       exp = uiA>>23 & 0xFF;
>>       sig64 = uiA & 0x007FFFFF;
>>       sig64 <<= 32;
>> @@ -895,6 +897,7 @@ static void f64ToFloatX( float64_t a, struct floatX 
>> *xPtr )
>>       xPtr->isInf = false;
>>       xPtr->isZero = false;
>>       xPtr->sign = ((uiA & UINT64_C( 0x8000000000000000 )) != 0);
>> +    xPtr->exp = 0;
>>       exp = uiA>>52 & 0x7FF;
>>       sig64 = uiA & UINT64_C( 0x000FFFFFFFFFFFFF );
>>       if ( exp == 0x7FF ) {
>> @@ -1220,6 +1223,7 @@ static void f128MToFloatX( const float128_t *aPtr, 
>> struct floatX *xPtr )
>>       xPtr->isZero = false;
>>       uiA64 = uiAPtr->v64;
>>       xPtr->sign = ((uiA64 & UINT64_C( 0x8000000000000000 )) != 0);
>> +    xPtr->exp = 0;
>>       exp = uiA64>>48 & 0x7FFF;
>>       sig.v64 = uiA64 & UINT64_C( 0x0000FFFFFFFFFFFF );
>>       sig.v0  = uiAPtr->v0;
>>


--
Alex Bennée



reply via email to

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