| Message ID | 20251114013528.108047-1-raj.khem@gmail.com |
|---|---|
| State | New |
| Headers | show |
| Series | [meta-oe] audiofile: Fix build with clang++ | expand |
Works on my machine, lgtm On 11/14/25 02:35, Khem Raj wrote: > When tests are enabled additional C++ code is compiled and clang does > not like the code. > > Signed-off-by: Khem Raj <raj.khem@gmail.com> > Cc: Gyorgy Sarvari <skandigraun@gmail.com> > --- > .../audiofile/audiofile_0.3.6.bb | 1 + > ...test-sign.cpp-Fix-C-narrowing-errors.patch | 41 +++++++++++++++++++ > 2 files changed, 42 insertions(+) > create mode 100644 meta-oe/recipes-multimedia/audiofile/files/0001-test-sign.cpp-Fix-C-narrowing-errors.patch > > diff --git a/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb b/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb > index cc7fef2a26..6ebb54e261 100644 > --- a/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb > +++ b/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb > @@ -19,6 +19,7 @@ SRC_URI = " \ > file://0006-Check-for-multiplication-overflow-in-sfconvert.patch \ > file://0007-Actually-fail-when-error-occurs-in-parseFormat.patch \ > file://0008-Check-for-multiplication-overflow-in-MSADPCM-decodeS.patch \ > + file://0001-test-sign.cpp-Fix-C-narrowing-errors.patch \ > file://test-for-CVE-2015-7747.patch \ > file://CVE-2019-13147.patch \ > file://CVE-2022-24599.patch \ > 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 @@ > +From bed0eb57c3294bac1c743cbe4404168c1007287d Mon Sep 17 00:00:00 2001 > +From: Khem Raj <raj.khem@gmail.com> > +Date: Thu, 13 Nov 2025 17:00:59 -0800 > +Subject: [PATCH] test/sign.cpp: Fix C++ narrowing errors > + > +The error is because -kMinInt32 is both overflowing and a narrowing conversion in a brace initializer. > +Fix it by doing the negation in a wider type and explicitly casting to uint32_t in the initializer. > + > +Fixes > + > +../../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] > + 160 | const uint32_t expectedData[] = { 0, -kMinInt32, kMaxUInt32 }; > + | ^~~~~~~~~~ > +../../sources/audiofile-0.3.6/test/Sign.cpp:160:39: note: insert an explicit cast to silence this issue > + 160 | const uint32_t expectedData[] = { 0, -kMinInt32, kMaxUInt32 }; > + | ^~~~~~~~~~ > + | static_cast<uint32_t>( ) > +../../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] > + 160 | const uint32_t expectedData[] = { 0, -kMinInt32, kMaxUInt32 }; > + | ^~~~~~~~~~ > +1 warning and 1 error generated. > + > +Upstream-Status: Pending > +Signed-off-by: Khem Raj <raj.khem@gmail.com> > +--- > + test/Sign.cpp | 2 +- > + 1 file changed, 1 insertion(+), 1 deletion(-) > + > +diff --git a/test/Sign.cpp b/test/Sign.cpp > +index c339514..0d80fe6 100644 > +--- a/test/Sign.cpp > ++++ b/test/Sign.cpp > +@@ -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>(-static_cast<int64_t>(kMinInt32)), kMaxUInt32 }; > + for (int i=0; i<frameCount; i++) > + EXPECT_EQ(readData[i], expectedData[i]); > + }
Can you include this patch in your series as well ? and send v3 On Thu, Nov 13, 2025 at 11:44 PM Gyorgy Sarvari <skandigraun@gmail.com> wrote: > Works on my machine, lgtm > > On 11/14/25 02:35, Khem Raj wrote: > > When tests are enabled additional C++ code is compiled and clang does > > not like the code. > > > > Signed-off-by: Khem Raj <raj.khem@gmail.com> > > Cc: Gyorgy Sarvari <skandigraun@gmail.com> > > --- > > .../audiofile/audiofile_0.3.6.bb | 1 + > > ...test-sign.cpp-Fix-C-narrowing-errors.patch | 41 +++++++++++++++++++ > > 2 files changed, 42 insertions(+) > > create mode 100644 > meta-oe/recipes-multimedia/audiofile/files/0001-test-sign.cpp-Fix-C-narrowing-errors.patch > > > > diff --git a/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb > b/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb > > index cc7fef2a26..6ebb54e261 100644 > > --- a/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb > > +++ b/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb > > @@ -19,6 +19,7 @@ SRC_URI = " \ > > file://0006-Check-for-multiplication-overflow-in-sfconvert.patch \ > > file://0007-Actually-fail-when-error-occurs-in-parseFormat.patch \ > > > file://0008-Check-for-multiplication-overflow-in-MSADPCM-decodeS.patch \ > > + file://0001-test-sign.cpp-Fix-C-narrowing-errors.patch \ > > file://test-for-CVE-2015-7747.patch \ > > file://CVE-2019-13147.patch \ > > file://CVE-2022-24599.patch \ > > 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 @@ > > +From bed0eb57c3294bac1c743cbe4404168c1007287d Mon Sep 17 00:00:00 2001 > > +From: Khem Raj <raj.khem@gmail.com> > > +Date: Thu, 13 Nov 2025 17:00:59 -0800 > > +Subject: [PATCH] test/sign.cpp: Fix C++ narrowing errors > > + > > +The error is because -kMinInt32 is both overflowing and a narrowing > conversion in a brace initializer. > > +Fix it by doing the negation in a wider type and explicitly casting to > uint32_t in the initializer. > > + > > +Fixes > > + > > +../../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] > > + 160 | const uint32_t expectedData[] = { 0, -kMinInt32, > kMaxUInt32 }; > > + | ^~~~~~~~~~ > > +../../sources/audiofile-0.3.6/test/Sign.cpp:160:39: note: insert an > explicit cast to silence this issue > > + 160 | const uint32_t expectedData[] = { 0, -kMinInt32, > kMaxUInt32 }; > > + | ^~~~~~~~~~ > > + | > static_cast<uint32_t>( ) > > +../../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] > > + 160 | const uint32_t expectedData[] = { 0, -kMinInt32, > kMaxUInt32 }; > > + | ^~~~~~~~~~ > > +1 warning and 1 error generated. > > + > > +Upstream-Status: Pending > > +Signed-off-by: Khem Raj <raj.khem@gmail.com> > > +--- > > + test/Sign.cpp | 2 +- > > + 1 file changed, 1 insertion(+), 1 deletion(-) > > + > > +diff --git a/test/Sign.cpp b/test/Sign.cpp > > +index c339514..0d80fe6 100644 > > +--- a/test/Sign.cpp > > ++++ b/test/Sign.cpp > > +@@ -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>(-static_cast<int64_t>(kMinInt32)), kMaxUInt32 }; > > + for (int i=0; i<frameCount; i++) > > + EXPECT_EQ(readData[i], expectedData[i]); > > + } > >
diff --git a/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb b/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb index cc7fef2a26..6ebb54e261 100644 --- a/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb +++ b/meta-oe/recipes-multimedia/audiofile/audiofile_0.3.6.bb @@ -19,6 +19,7 @@ SRC_URI = " \ file://0006-Check-for-multiplication-overflow-in-sfconvert.patch \ file://0007-Actually-fail-when-error-occurs-in-parseFormat.patch \ file://0008-Check-for-multiplication-overflow-in-MSADPCM-decodeS.patch \ + file://0001-test-sign.cpp-Fix-C-narrowing-errors.patch \ file://test-for-CVE-2015-7747.patch \ file://CVE-2019-13147.patch \ file://CVE-2022-24599.patch \ 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 @@ +From bed0eb57c3294bac1c743cbe4404168c1007287d Mon Sep 17 00:00:00 2001 +From: Khem Raj <raj.khem@gmail.com> +Date: Thu, 13 Nov 2025 17:00:59 -0800 +Subject: [PATCH] test/sign.cpp: Fix C++ narrowing errors + +The error is because -kMinInt32 is both overflowing and a narrowing conversion in a brace initializer. +Fix it by doing the negation in a wider type and explicitly casting to uint32_t in the initializer. + +Fixes + +../../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] + 160 | const uint32_t expectedData[] = { 0, -kMinInt32, kMaxUInt32 }; + | ^~~~~~~~~~ +../../sources/audiofile-0.3.6/test/Sign.cpp:160:39: note: insert an explicit cast to silence this issue + 160 | const uint32_t expectedData[] = { 0, -kMinInt32, kMaxUInt32 }; + | ^~~~~~~~~~ + | static_cast<uint32_t>( ) +../../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] + 160 | const uint32_t expectedData[] = { 0, -kMinInt32, kMaxUInt32 }; + | ^~~~~~~~~~ +1 warning and 1 error generated. + +Upstream-Status: Pending +Signed-off-by: Khem Raj <raj.khem@gmail.com> +--- + test/Sign.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/Sign.cpp b/test/Sign.cpp +index c339514..0d80fe6 100644 +--- a/test/Sign.cpp ++++ b/test/Sign.cpp +@@ -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>(-static_cast<int64_t>(kMinInt32)), kMaxUInt32 }; + for (int i=0; i<frameCount; i++) + EXPECT_EQ(readData[i], expectedData[i]); + }
When tests are enabled additional C++ code is compiled and clang does not like the code. Signed-off-by: Khem Raj <raj.khem@gmail.com> Cc: Gyorgy Sarvari <skandigraun@gmail.com> --- .../audiofile/audiofile_0.3.6.bb | 1 + ...test-sign.cpp-Fix-C-narrowing-errors.patch | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 meta-oe/recipes-multimedia/audiofile/files/0001-test-sign.cpp-Fix-C-narrowing-errors.patch