audiofile/integer-overflow.patch
Timm Bäder e89bf8be7a Fix an integer overflow warning
Recent GCC versions emit warnings like this during compilation:

<source>:10:31: warning: integer overflow in expression of type 'int' results in '-2147483648' [-Woverflow]
   10 |   const uint32_t limits[] = { -minInt, maxInt };
      |                               ^~~~~~~
<source>:10:31: warning: narrowing conversion of '-2147483648' from 'int' to 'uint32_t' {aka 'unsigned int'} [-Wnarrowing]

And clang even treats them like an error.
2021-01-04 13:43:36 +01:00

13 lines
621 B
Diff

diff -ruN audiofile-0.3.6.orig/test/Sign.cpp audiofile-0.3.6/test/Sign.cpp
--- audiofile-0.3.6.orig/test/Sign.cpp 2021-01-04 12:50:58.563336280 +0100
+++ audiofile-0.3.6/test/Sign.cpp 2021-01-04 13:00:55.536214264 +0100
@@ -157,7 +157,7 @@
AFframecount framesRead = afReadFrames(file, AF_DEFAULT_TRACK, readData, frameCount);
ASSERT_EQ(framesRead, frameCount);
afCloseFile(file);
- const uint32_t expectedData[] = { 0, -kMinInt32, kMaxUInt32 };
+ const uint32_t expectedData[] = { 0, static_cast<uint32_t>(-kMinInt32), kMaxUInt32 };
for (int i=0; i<frameCount; i++)
EXPECT_EQ(readData[i], expectedData[i]);
}