summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-extended/7zip/bit7z/0001-Fix-reinterpret-cast-compiler-errors.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-oe/recipes-extended/7zip/bit7z/0001-Fix-reinterpret-cast-compiler-errors.patch')
-rw-r--r--meta-oe/recipes-extended/7zip/bit7z/0001-Fix-reinterpret-cast-compiler-errors.patch52
1 files changed, 52 insertions, 0 deletions
diff --git a/meta-oe/recipes-extended/7zip/bit7z/0001-Fix-reinterpret-cast-compiler-errors.patch b/meta-oe/recipes-extended/7zip/bit7z/0001-Fix-reinterpret-cast-compiler-errors.patch
new file mode 100644
index 0000000000..08b64f4999
--- /dev/null
+++ b/meta-oe/recipes-extended/7zip/bit7z/0001-Fix-reinterpret-cast-compiler-errors.patch
@@ -0,0 +1,52 @@
1From bedeec4d57d29be7de91697277ace00ba87d3e75 Mon Sep 17 00:00:00 2001
2From: Peter Marko <peter.marko@siemens.com>
3Date: Tue, 1 Apr 2025 15:23:51 +0200
4Subject: [PATCH] Fix reinterpret-cast compiler errors
5
6Building on 32-bit arm, following warning/error occurs:
7
8src/internal/windows.cpp: In function 'bit7z::OLECHAR* AllocStringBuffer(LPCSTR, uint32_t)':
9src/internal/windows.cpp:79:6: error: cast from 'unsigned char*' to 'bstr_prefix_t*' {aka 'unsigned int*'} increases required alignment of target type [-Werror=cast-align]
10 79 | *reinterpret_cast< bstr_prefix_t* >( bstrBuffer ) = byteLength;
11 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12git/src/internal/windows.cpp:83:19: error: cast from 'unsigned char*' to 'bit7z::BSTR' {aka 'wchar_t*'} increases required alignment of target type [-Werror=cast-align]
13 83 | BSTR result = reinterpret_cast< BSTR >( bstrBuffer + sizeof( bstr_prefix_t ) );
14 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15cc1plus: all warnings being treated as errors
16
17Fix it by using the desired variable size right away and thus avoid
18casting to an array with different alignment.
19
20Upstream-Status: Backport [https://github.com/rikyoz/bit7z/commit/b2789ea9b0fbb2a74dbf6764ddb72d60659a3bce]
21Signed-off-by: Peter Marko <peter.marko@siemens.com>
22---
23 src/internal/windows.cpp | 7 +++----
24 1 file changed, 3 insertions(+), 4 deletions(-)
25
26diff --git a/src/internal/windows.cpp b/src/internal/windows.cpp
27index 9304aed7..7bee5959 100644
28--- a/src/internal/windows.cpp
29+++ b/src/internal/windows.cpp
30@@ -68,19 +68,18 @@ auto AllocStringBuffer( LPCSTR str, uint32_t byteLength ) -> BSTR {
31
32 // Allocating memory for storing the BSTR as a byte array.
33 // NOLINTNEXTLINE(cppcoreguidelines-no-malloc, cppcoreguidelines-owning-memory)
34- auto* bstrBuffer = static_cast< byte_t* >( std::calloc( bufferSize, sizeof( byte_t ) ) );
35+ auto* bstrBuffer = static_cast< bstr_prefix_t* >( std::calloc( bufferSize, sizeof( byte_t ) ) );
36
37 if ( bstrBuffer == nullptr ) { // Failed to allocate memory for the BSTR buffer.
38 return nullptr;
39 }
40
41 // Storing the number of bytes of the BSTR as a prefix of it.
42- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
43- *reinterpret_cast< bstr_prefix_t* >( bstrBuffer ) = byteLength;
44+ *bstrBuffer = byteLength;
45
46 // The actual BSTR must point after the byteLength prefix.
47 // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic, cppcoreguidelines-pro-type-reinterpret-cast)
48- BSTR result = reinterpret_cast< BSTR >( bstrBuffer + sizeof( bstr_prefix_t ) );
49+ BSTR result = reinterpret_cast< BSTR >( bstrBuffer + 1 );
50 if ( str != nullptr ) {
51 // Copying byte-by-byte the input string to the BSTR.
52 // Note: flawfinder warns about not checking for buffer overflows; this is a false alarm,