flaticon: Fix warnings due to type punning
Original warnings:
In function ‘bool BPrivate::Icon::read_float_24(BPrivate::Icon::LittleEndianBuffer&, float&)’:
/s/src/libs/icon/flat_icon/FlatIconFormat.cpp:94:20:
warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
_value = (float&)value;
^~~~~
/s/src/libs/icon/flat_icon/FlatIconFormat.cpp:108:26: warning:
dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
uint32 value = (uint32&)_value;
^~~~~~
Change-Id: Ibe1facde0d37beefd5bcf542c89502bac2384034
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4499
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
610f99c838
commit
5b38b945ae
@@ -89,9 +89,12 @@ read_float_24(LittleEndianBuffer& buffer, float& _value)
|
|||||||
if (shortValue == 0)
|
if (shortValue == 0)
|
||||||
_value = 0.0;
|
_value = 0.0;
|
||||||
else {
|
else {
|
||||||
uint32 value = (sign << 31) | ((exponent + 127) << 23) | mantissa;
|
union {
|
||||||
|
uint32 intValue;
|
||||||
_value = (float&)value;
|
float floatValue;
|
||||||
|
} i2f;
|
||||||
|
i2f.intValue = (sign << 31) | ((exponent + 127) << 23) | mantissa;
|
||||||
|
_value = i2f.floatValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -105,11 +108,15 @@ write_float_24(LittleEndianBuffer& buffer, float _value)
|
|||||||
// 6 bit exponent
|
// 6 bit exponent
|
||||||
// 17 bit mantissa
|
// 17 bit mantissa
|
||||||
// TODO: fixme for non-IEEE 754 architectures
|
// TODO: fixme for non-IEEE 754 architectures
|
||||||
uint32 value = (uint32&)_value;
|
union {
|
||||||
|
float floatValue;
|
||||||
|
uint32 intValue;
|
||||||
|
} f2i;
|
||||||
|
f2i.floatValue = _value;
|
||||||
|
|
||||||
int sign = (value & 0x80000000) >> 31;
|
int sign = (f2i.intValue & 0x80000000) >> 31;
|
||||||
int exponent = ((value & 0x7f800000) >> 23) - 127;
|
int exponent = ((f2i.intValue & 0x7f800000) >> 23) - 127;
|
||||||
int mantissa = value & 0x007fffff;
|
int mantissa = f2i.intValue & 0x007fffff;
|
||||||
|
|
||||||
if (exponent >= 32 || exponent < -32) {
|
if (exponent >= 32 || exponent < -32) {
|
||||||
uint8 zero = 0;
|
uint8 zero = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user