avoid int overflow too
This commit is contained in:
parent
1f75efdeaa
commit
a4d2feea0b
|
@ -6,7 +6,7 @@ diff -Nurb --strip-trailing-cr audiofile-0.3.6-orig/libaudiofile/modules/SimpleM
|
||||||
|
|
||||||
static const int kScaleBits = (Format + 1) * CHAR_BIT - 1;
|
static const int kScaleBits = (Format + 1) * CHAR_BIT - 1;
|
||||||
- static const int kMinSignedValue = -1 << kScaleBits;
|
- static const int kMinSignedValue = -1 << kScaleBits;
|
||||||
+ static const int kMinSignedValue = 0L-(1<<kScaleBits);
|
+ static const int kMinSignedValue = 0-(1U<<kScaleBits);
|
||||||
|
|
||||||
struct signedToUnsigned : public std::unary_function<SignedType, UnsignedType>
|
struct signedToUnsigned : public std::unary_function<SignedType, UnsignedType>
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ diff -Nurb --strip-trailing-cr audiofile-0.3.6-orig/test/FloatToInt.cpp audiofil
|
||||||
}
|
}
|
||||||
|
|
||||||
-static const int32_t kMinInt24 = -1<<23;
|
-static const int32_t kMinInt24 = -1<<23;
|
||||||
+static const int32_t kMinInt24 = 0L-(1<<23);
|
+static const int32_t kMinInt24 = 0-(1U<<23);
|
||||||
static const int32_t kMaxInt24 = (1<<23) - 1;
|
static const int32_t kMaxInt24 = (1<<23) - 1;
|
||||||
|
|
||||||
TEST_F(FloatToIntTest, Int24)
|
TEST_F(FloatToIntTest, Int24)
|
||||||
|
@ -30,7 +30,7 @@ diff -Nurb --strip-trailing-cr audiofile-0.3.6-orig/test/IntToFloat.cpp audiofil
|
||||||
}
|
}
|
||||||
|
|
||||||
-static const int32_t kMinInt24 = -1<<23;
|
-static const int32_t kMinInt24 = -1<<23;
|
||||||
+static const int32_t kMinInt24 = 0L-(1<<23);
|
+static const int32_t kMinInt24 = 0-(1U<<23);
|
||||||
static const int32_t kMaxInt24 = (1<<23) - 1;
|
static const int32_t kMaxInt24 = (1<<23) - 1;
|
||||||
|
|
||||||
TEST_F(IntToFloatTest, Int24)
|
TEST_F(IntToFloatTest, Int24)
|
||||||
|
@ -42,7 +42,7 @@ diff -Nurb --strip-trailing-cr audiofile-0.3.6-orig/test/Sign.cpp audiofile-0.3.
|
||||||
}
|
}
|
||||||
|
|
||||||
-static const int32_t kMinInt24 = -1<<23;
|
-static const int32_t kMinInt24 = -1<<23;
|
||||||
+static const int32_t kMinInt24 = 0L-(1<<23);
|
+static const int32_t kMinInt24 = 0-(1U<<23);
|
||||||
static const int32_t kMaxInt24 = (1<<23) - 1;
|
static const int32_t kMaxInt24 = (1<<23) - 1;
|
||||||
static const uint32_t kMaxUInt24 = (1<<24) - 1;
|
static const uint32_t kMaxUInt24 = (1<<24) - 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue