summaryrefslogtreecommitdiff
path: root/audio/libaudiofile/files/patch-test_Sign.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2024-09-13 11:11:45 +0200
committerDimitry Andric <dim@FreeBSD.org>2024-09-28 11:43:47 +0200
commit7955b1d7ec787bf13f2cfea75e9355a3f3e91a53 (patch)
tree0d02c2d980fcecc4eeb67046377b81728ea59aed /audio/libaudiofile/files/patch-test_Sign.cpp
parentgraphics/vigra: fix build with clang 19 (diff)
audio/libaudiofile: fix build with clang 19, enable tests
Clang 19 has become more strict about initialization with undefined behavior, resulting in errors similar to: ./SimpleModule.h:126:40: error: in-class initializer for static data member is not a constant expression 126 | static const int kMinSignedValue = -1 << kScaleBits; | ~~~^~~~~~~~~~~~~ ./SimpleModule.h:176:22: note: in instantiation of template class 'signConverter<kInt8>' requested here 176 | transform<typename signConverter<Format>::signedToUnsigned>(src, dst, count); | ^ ./SimpleModule.h:183:5: note: in instantiation of function template specialization 'ConvertSign::convertSignedToUnsigned<kInt8>' requested here 183 | convertSignedToUnsigned<kInt8>(src, dst, count); | ^ This is because left-shifting negative values is undefined. Replace -1 with ~0u which results in the expected value. While here, add a few other patches to remove warnings about undefined left-shifts, and add support for the "make test" target. PR: 281477 Approved by: maintainer timeout (2 weeks) MFH: 2024Q3
Diffstat (limited to 'audio/libaudiofile/files/patch-test_Sign.cpp')
-rw-r--r--audio/libaudiofile/files/patch-test_Sign.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/audio/libaudiofile/files/patch-test_Sign.cpp b/audio/libaudiofile/files/patch-test_Sign.cpp
new file mode 100644
index 000000000000..04c521685a7f
--- /dev/null
+++ b/audio/libaudiofile/files/patch-test_Sign.cpp
@@ -0,0 +1,20 @@
+--- test/Sign.cpp.orig 2013-02-11 17:23:26 UTC
++++ test/Sign.cpp
+@@ -116,7 +116,7 @@ TEST_F(SignConversionTest, Int16)
+ EXPECT_EQ(readData[i], expectedData[i]);
+ }
+
+-static const int32_t kMinInt24 = -1<<23;
++static const int32_t kMinInt24 = ~0u<<23;
+ static const int32_t kMaxInt24 = (1<<23) - 1;
+ static const uint32_t kMaxUInt24 = (1<<24) - 1;
+
+@@ -157,7 +157,7 @@ TEST_F(SignConversionTest, Int32)
+ 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]);
+ }