diff options
Diffstat (limited to 'meta-oe/recipes-multimedia/audiofile/files/0001-test-sign.cpp-Fix-C-narrowing-errors.patch')
| -rw-r--r-- | meta-oe/recipes-multimedia/audiofile/files/0001-test-sign.cpp-Fix-C-narrowing-errors.patch | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/meta-oe/recipes-multimedia/audiofile/files/0001-test-sign.cpp-Fix-C-narrowing-errors.patch b/meta-oe/recipes-multimedia/audiofile/files/0001-test-sign.cpp-Fix-C-narrowing-errors.patch new file mode 100644 index 0000000000..83c573a873 --- /dev/null +++ b/meta-oe/recipes-multimedia/audiofile/files/0001-test-sign.cpp-Fix-C-narrowing-errors.patch | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | From bed0eb57c3294bac1c743cbe4404168c1007287d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Thu, 13 Nov 2025 17:00:59 -0800 | ||
| 4 | Subject: [PATCH] test/sign.cpp: Fix C++ narrowing errors | ||
| 5 | |||
| 6 | The error is because -kMinInt32 is both overflowing and a narrowing conversion in a brace initializer. | ||
| 7 | Fix it by doing the negation in a wider type and explicitly casting to uint32_t in the initializer. | ||
| 8 | |||
| 9 | Fixes | ||
| 10 | |||
| 11 | ../../sources/audiofile-0.3.6/test/Sign.cpp:160:39: error: non-constant-expression cannot be narrowed from type 'int32_t' (aka 'int') to 'uint32_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing] | ||
| 12 | 160 | const uint32_t expectedData[] = { 0, -kMinInt32, kMaxUInt32 }; | ||
| 13 | | ^~~~~~~~~~ | ||
| 14 | ../../sources/audiofile-0.3.6/test/Sign.cpp:160:39: note: insert an explicit cast to silence this issue | ||
| 15 | 160 | const uint32_t expectedData[] = { 0, -kMinInt32, kMaxUInt32 }; | ||
| 16 | | ^~~~~~~~~~ | ||
| 17 | | static_cast<uint32_t>( ) | ||
| 18 | ../../sources/audiofile-0.3.6/test/Sign.cpp:160:39: warning: overflow in expression; result is -2'147'483'648 with type 'int32_t' (aka 'int') [-Winteger-overflow] | ||
| 19 | 160 | const uint32_t expectedData[] = { 0, -kMinInt32, kMaxUInt32 }; | ||
| 20 | | ^~~~~~~~~~ | ||
| 21 | 1 warning and 1 error generated. | ||
| 22 | |||
| 23 | Upstream-Status: Pending | ||
| 24 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 25 | --- | ||
| 26 | test/Sign.cpp | 2 +- | ||
| 27 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 28 | |||
| 29 | diff --git a/test/Sign.cpp b/test/Sign.cpp | ||
| 30 | index c339514..0d80fe6 100644 | ||
| 31 | --- a/test/Sign.cpp | ||
| 32 | +++ b/test/Sign.cpp | ||
| 33 | @@ -157,7 +157,7 @@ TEST_F(SignConversionTest, Int32) | ||
| 34 | AFframecount framesRead = afReadFrames(file, AF_DEFAULT_TRACK, readData, frameCount); | ||
| 35 | ASSERT_EQ(framesRead, frameCount); | ||
| 36 | afCloseFile(file); | ||
| 37 | - const uint32_t expectedData[] = { 0, -kMinInt32, kMaxUInt32 }; | ||
| 38 | + const uint32_t expectedData[] = { 0, static_cast<uint32_t>(-static_cast<int64_t>(kMinInt32)), kMaxUInt32 }; | ||
| 39 | for (int i=0; i<frameCount; i++) | ||
| 40 | EXPECT_EQ(readData[i], expectedData[i]); | ||
| 41 | } | ||
