Merge ~xypron/ubuntu/+source/valentina:lp2134600 into ubuntu/+source/valentina:ubuntu/devel

Proposed by Heinrich Schuchardt
Status: Needs review
Proposed branch: ~xypron/ubuntu/+source/valentina:lp2134600
Merge into: ubuntu/+source/valentina:ubuntu/devel
Diff against target: 323 lines (+271/-1)
7 files modified
debian/changelog (+6/-0)
debian/control (+2/-1)
debian/patches/0001-libdxfrw-avoid-alignment-errors-in-dxfreader.cpp.patch (+111/-0)
debian/patches/0002-vposter-avoid-illegal-reinterpret_cast.patch (+48/-0)
debian/patches/0003-stylehelper-avoid-illegal-reinterpret_cast.patch (+52/-0)
debian/patches/0004-vptilefactory-avoid-illegal-reinterpret_cast.patch (+48/-0)
debian/patches/series (+4/-0)
Reviewer Review Type Date Requested Status
Ubuntu Sponsors Pending
git-ubuntu import Pending
Review via email: mp+497459@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Heinrich Schuchardt (xypron) wrote :

Local build in sbuild succeeded.
Waiting for build in ppa:xypron/merge-from-debian to complete

Revision history for this message
Heinrich Schuchardt (xypron) wrote :

valentina - 1.0.0~dfsg-4ubuntu1~ppa3 built successfully in ppa:xypron/merge-from-debian

Unmerged commits

8124612... by Heinrich Schuchardt

Update changelog

Signed-off-by: Heinrich Schuchardt <email address hidden>

8faefbd... by Heinrich Schuchardt

d/control: update maintainer

Signed-off-by: Heinrich Schuchardt <email address hidden>

7714e8c... by Heinrich Schuchardt

* Avoid alignment errors on riscv64 (LP: #2134600)

  d/p/0001-libdxfrw-avoid-alignment-errors-in-dxfreader.cpp.patch
  d/p/0002-vposter-avoid-illegal-reinterpret_cast.patch
  d/p/0003-stylehelper-avoid-illegal-reinterpret_cast.patch
  d/p/0004-vptilefactory-avoid-illegal-reinterpret_cast.patch

Signed-off-by: Heinrich Schuchardt <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 682e4d3..a8dd74d 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,9 @@
6+valentina (1.0.0~dfsg-4ubuntu1) UNRELEASED; urgency=medium
7+
8+ * Avoid alignment issues on riscv64 (LP: #2134600)
9+
10+ -- Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Thu, 11 Dec 2025 18:42:38 +0100
11+
12 valentina (1.0.0~dfsg-4) unstable; urgency=medium
13
14 * install russian measurement tables as non-example file,
15diff --git a/debian/control b/debian/control
16index f77fadd..1750e3b 100644
17--- a/debian/control
18+++ b/debian/control
19@@ -1,7 +1,8 @@
20 Source: valentina
21 Section: graphics
22 Priority: optional
23-Maintainer: Jonas Smedegaard <dr@jones.dk>
24+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
25+XSBC-Original-Maintainer: Jonas Smedegaard <dr@jones.dk>
26 Build-Depends:
27 chrpath,
28 dbus-daemon <!nocheck>,
29diff --git a/debian/patches/0001-libdxfrw-avoid-alignment-errors-in-dxfreader.cpp.patch b/debian/patches/0001-libdxfrw-avoid-alignment-errors-in-dxfreader.cpp.patch
30new file mode 100644
31index 0000000..b40615b
32--- /dev/null
33+++ b/debian/patches/0001-libdxfrw-avoid-alignment-errors-in-dxfreader.cpp.patch
34@@ -0,0 +1,111 @@
35+From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
36+Date: Thu, 11 Dec 2025 18:33:39 +0100
37+Subject: [PATCH 1/4] libdxfrw: avoid alignment errors in dxfreader.cpp
38+MIME-Version: 1.0
39+Content-Type: text/plain; charset=UTF-8
40+Content-Transfer-Encoding: 8bit
41+
42+Reinterpret_cast is only allowable if the from type satisfies the alignment
43+requirement of the target. Using GCC 15.2 on RISC-V the current code of
44+dxfreader leads to errors like
45+
46+ dxfreader.cpp:121:14: error: cast from ‘char*’ to ‘short unsigned int*’
47+ increases required alignment of target type [-Werror=cast-align]
48+
49+We can avoid reinterpret_cast by using unions.
50+
51+Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
52+Origin: https://gitlab.com/smart-pattern/valentina/-/commit/8b3fb765bebc858566e041448473bb0582df4f21
53+---
54+ src/libs/vdxf/libdxfrw/intern/dxfreader.cpp | 50 +++++++++++----------
55+ 1 file changed, 26 insertions(+), 24 deletions(-)
56+
57+diff --git a/src/libs/vdxf/libdxfrw/intern/dxfreader.cpp b/src/libs/vdxf/libdxfrw/intern/dxfreader.cpp
58+index bd0ba5898..6b18b0d89 100644
59+--- a/src/libs/vdxf/libdxfrw/intern/dxfreader.cpp
60++++ b/src/libs/vdxf/libdxfrw/intern/dxfreader.cpp
61+@@ -115,18 +115,18 @@ auto dxfReader::getHandleString() -> int
62+
63+ auto dxfReaderBinary::readCode(int *code) -> bool
64+ {
65+- unsigned short *int16p;
66+- char buffer[2];
67+- filestr->read(buffer,2);
68+- int16p = reinterpret_cast<unsigned short *>(buffer);
69++ union {
70++ unsigned short val;
71++ char buf[2];
72++ } buffer;
73++ filestr->read(buffer.buf,2);
74+ //exist a 32bits int (code 90) with 2 bytes???
75+- if ((*code == 90) && (*int16p>2000)){
76++ if ((*code == 90) && (buffer.val>2000)){
77+ DRW_DBG(*code); DRW_DBG(" de 16bits\n");
78+ filestr->seekg(-4, std::ios_base::cur);
79+- filestr->read(buffer,2);
80+- int16p = reinterpret_cast<unsigned short *>(buffer);
81++ filestr->read(buffer.buf,2);
82+ }
83+- *code = *int16p;
84++ *code = buffer.val;
85+ DRW_DBG(*code); DRW_DBG("\n");
86+
87+ return (filestr->good());
88+@@ -172,11 +172,12 @@ auto dxfReaderBinary::readInt16() -> bool
89+ auto dxfReaderBinary::readInt32() -> bool
90+ {
91+ type = INT32;
92+- unsigned *int32p;
93+- char buffer[4];
94+- filestr->read(buffer,4);
95+- int32p = reinterpret_cast<unsigned *>(buffer);
96+- intData = static_cast<signed int>(*int32p);
97++ union {
98++ signed int val;
99++ char buf[4];
100++ } buffer;
101++ filestr->read(buffer.buf,4);
102++ intData = buffer.val;
103+ // cppcheck-suppress danglingLifetime
104+ DRW_DBG(intData); DRW_DBG("\n");
105+ return (filestr->good());
106+@@ -185,11 +186,12 @@ auto dxfReaderBinary::readInt32() -> bool
107+ auto dxfReaderBinary::readInt64() -> bool
108+ {
109+ type = INT64;
110+- unsigned long long int *int64p; //64 bits integer pointer
111+- char buffer[8];
112+- filestr->read(buffer,8);
113+- int64p = reinterpret_cast<unsigned long long int *>(buffer);
114+- int64 = *int64p;
115++ union {
116++ unsigned long long int val;
117++ char buf[8];
118++ } buffer;
119++ filestr->read(buffer.buf,8);
120++ int64 = buffer.val;
121+ // cppcheck-suppress danglingLifetime
122+ DRW_DBG(int64); DRW_DBG(" int64\n");
123+ return (filestr->good());
124+@@ -198,12 +200,12 @@ auto dxfReaderBinary::readInt64() -> bool
125+ auto dxfReaderBinary::readDouble() -> bool
126+ {
127+ type = DOUBLE;
128+- double *result;
129+- char buffer[8];
130+- filestr->read(buffer,8);
131+- // cppcheck-suppress invalidPointerCast
132+- result = reinterpret_cast<double *>(buffer);
133+- doubleData = *result;
134++ union {
135++ double val;
136++ char buf[8];
137++ } buffer;
138++ filestr->read(buffer.buf,8);
139++ doubleData = buffer.val;
140+ // cppcheck-suppress danglingLifetime
141+ DRW_DBG(doubleData); DRW_DBG("\n");
142+ return (filestr->good());
143+--
144+2.51.0
145+
146diff --git a/debian/patches/0002-vposter-avoid-illegal-reinterpret_cast.patch b/debian/patches/0002-vposter-avoid-illegal-reinterpret_cast.patch
147new file mode 100644
148index 0000000..e8b2393
149--- /dev/null
150+++ b/debian/patches/0002-vposter-avoid-illegal-reinterpret_cast.patch
151@@ -0,0 +1,48 @@
152+From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
153+Date: Fri, 12 Dec 2025 11:18:17 +0100
154+Subject: [PATCH 2/4] vposter: avoid illegal reinterpret_cast
155+MIME-Version: 1.0
156+Content-Type: text/plain; charset=UTF-8
157+Content-Transfer-Encoding: 8bit
158+
159+A reinterpret_cast where the target has a higher alignment requirement
160+than the source leads to an error as observed with GCC 15.2 on riscv64:
161+
162+ vposter.cpp:73:30: error:
163+ cast from ‘uchar*’ {aka ‘unsigned char*’} to ‘QRgb*’
164+ {aka ‘unsigned int*’} increases required alignment of target type
165+ [-Werror=cast-align]
166+
167+As we know that QImage::scanLine() returns 32bit aligned data
168+use an unsafe conversion via a void * pointer instead.
169+
170+Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
171+Origin: https://gitlab.com/smart-pattern/valentina/-/commit/499a7df1975953d905b73e3857cd4029678c75f6
172+---
173+ src/libs/vlayout/vposter.cpp | 8 +++++---
174+ 1 file changed, 5 insertions(+), 3 deletions(-)
175+
176+diff --git a/src/libs/vlayout/vposter.cpp b/src/libs/vlayout/vposter.cpp
177+index 889fee0c0..05633c363 100644
178+--- a/src/libs/vlayout/vposter.cpp
179++++ b/src/libs/vlayout/vposter.cpp
180+@@ -66,11 +66,13 @@ auto Grayscale(QImage image) -> QImage
181+ {
182+ for (int ii = 0; ii < image.height(); ii++)
183+ {
184+- uchar *scan = image.scanLine(ii);
185+- int const depth = 4;
186++ // Scanline data is at least 32-bit aligned.
187++ // https://doc.qt.io/qt-6/qimage.html#scanLine
188++ void *voidPtr = image.scanLine(ii);
189++ auto *scan = static_cast<QRgb *>(voidPtr);
190+ for (int jj = 0; jj < image.width(); jj++)
191+ {
192+- auto *rgbpixel = reinterpret_cast<QRgb *>(scan + jj * depth);
193++ auto *rgbpixel = &scan[jj];
194+ int const gray = qGray(*rgbpixel);
195+ *rgbpixel = QColor(gray, gray, gray, qAlpha(*rgbpixel)).rgba();
196+ }
197+--
198+2.51.0
199+
200diff --git a/debian/patches/0003-stylehelper-avoid-illegal-reinterpret_cast.patch b/debian/patches/0003-stylehelper-avoid-illegal-reinterpret_cast.patch
201new file mode 100644
202index 0000000..d01fb62
203--- /dev/null
204+++ b/debian/patches/0003-stylehelper-avoid-illegal-reinterpret_cast.patch
205@@ -0,0 +1,52 @@
206+From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
207+Date: Fri, 12 Dec 2025 09:43:50 +0100
208+Subject: [PATCH 3/4] stylehelper: avoid illegal reinterpret_cast
209+MIME-Version: 1.0
210+Content-Type: text/plain; charset=UTF-8
211+Content-Transfer-Encoding: 8bit
212+
213+A reinterpret_cast where the target has a higher alignment requirement
214+than the source leads to an error as observed with GCC 15.2 on riscv64:
215+
216+ stylehelper.cpp:157:34: error:
217+ cast from ‘uchar*’ {aka ‘unsigned char*’} to ‘QRgb*’
218+ {aka ‘unsigned int*’} increases required alignment
219+ of target type [-Werror=cast-align]
220+
221+As we know that QImage::scanLine() returns 32bit aligned data
222+use an unsafe conversion via a void * pointer instead.
223+
224+Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
225+https://gitlab.com/smart-pattern/valentina/-/commit/b42d67d8bc0ea8afd9a9c9818dd6789891a0371f
226+---
227+ src/libs/vwidgets/fancytabbar/stylehelper.cpp | 9 ++++++---
228+ 1 file changed, 6 insertions(+), 3 deletions(-)
229+
230+diff --git a/src/libs/vwidgets/fancytabbar/stylehelper.cpp b/src/libs/vwidgets/fancytabbar/stylehelper.cpp
231+index 81f8617c4..120f02e8a 100644
232+--- a/src/libs/vwidgets/fancytabbar/stylehelper.cpp
233++++ b/src/libs/vwidgets/fancytabbar/stylehelper.cpp
234+@@ -154,14 +154,17 @@ void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect, QPain
235+
236+ for (int y = 0; y < im.height(); ++y)
237+ {
238+- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
239+- auto *scanLine = reinterpret_cast<QRgb *>(im.scanLine(y));
240++ // Scanline data is at least 32-bit aligned.
241++ // https://doc.qt.io/qt-6/qimage.html#scanLine
242++ void *voidPtr = im.scanLine(y);
243++ auto *scanLine = static_cast<QRgb *>(voidPtr);
244++
245+ for (int x = 0; x < im.width(); ++x)
246+ {
247+ QRgb const pixel = *scanLine;
248+ auto const intensity = static_cast<char>(qGray(pixel));
249+ *scanLine = qRgba(intensity, intensity, intensity, qAlpha(pixel));
250+- ++scanLine; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
251++ ++scanLine;
252+ }
253+ }
254+ px = QPixmap::fromImage(im);
255+--
256+2.51.0
257+
258diff --git a/debian/patches/0004-vptilefactory-avoid-illegal-reinterpret_cast.patch b/debian/patches/0004-vptilefactory-avoid-illegal-reinterpret_cast.patch
259new file mode 100644
260index 0000000..02209a1
261--- /dev/null
262+++ b/debian/patches/0004-vptilefactory-avoid-illegal-reinterpret_cast.patch
263@@ -0,0 +1,48 @@
264+From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
265+Date: Fri, 12 Dec 2025 12:37:45 +0100
266+Subject: [PATCH 4/4] vptilefactory: avoid illegal reinterpret_cast
267+MIME-Version: 1.0
268+Content-Type: text/plain; charset=UTF-8
269+Content-Transfer-Encoding: 8bit
270+
271+A reinterpret_cast where the target has a higher alignment requirement
272+than the source leads to an error as observed with GCC 15.2 on riscv64:
273+
274+ vptilefactory.cpp:120:30: error:
275+ cast from ‘uchar*’ {aka ‘unsigned char*’} to ‘QRgb*’
276+ {aka ‘unsigned int*’} increases required alignment of target type
277+ [-Werror=cast-align]
278+
279+As we know that QImage::constScanLine() returns 32bit aligned data
280+use an unsafe conversion via a void * pointer instead.
281+
282+Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
283+Origin: https://gitlab.com/smart-pattern/valentina/-/commit/3e523bc88da9f92f876a8deabd21f0557bd6d775
284+---
285+ src/app/puzzle/vptilefactory.cpp | 8 +++++---
286+ 1 file changed, 5 insertions(+), 3 deletions(-)
287+
288+diff --git a/src/app/puzzle/vptilefactory.cpp b/src/app/puzzle/vptilefactory.cpp
289+index 725768883..1100e477d 100644
290+--- a/src/app/puzzle/vptilefactory.cpp
291++++ b/src/app/puzzle/vptilefactory.cpp
292+@@ -113,11 +113,13 @@ auto Grayscale(QImage image) -> QImage
293+ {
294+ for (int ii = 0; ii < image.height(); ii++)
295+ {
296+- uchar *scan = image.scanLine(ii);
297+- int const depth = 4;
298++ // Scanline data is at least 32-bit aligned.
299++ // https://doc.qt.io/qt-6/qimage.html#scanLine
300++ void *voidPtr = image.scanLine(ii);
301++ auto *scan = static_cast<QRgb *>(voidPtr);
302+ for (int jj = 0; jj < image.width(); jj++)
303+ {
304+- auto *rgbpixel = reinterpret_cast<QRgb *>(scan + jj * depth); // NOLINT
305++ auto *rgbpixel = scan + jj;
306+ int const gray = qGray(*rgbpixel);
307+ *rgbpixel = QColor(gray, gray, gray, qAlpha(*rgbpixel)).rgba();
308+ }
309+--
310+2.51.0
311+
312diff --git a/debian/patches/series b/debian/patches/series
313index 7e4c070..862af75 100644
314--- a/debian/patches/series
315+++ b/debian/patches/series
316@@ -9,3 +9,7 @@
317 1001_open_helper_tools_only_from_PATH.patch
318 1002_path_to_tables.patch
319 2004_rename_helper_tools.patch
320+0001-libdxfrw-avoid-alignment-errors-in-dxfreader.cpp.patch
321+0002-vposter-avoid-illegal-reinterpret_cast.patch
322+0003-stylehelper-avoid-illegal-reinterpret_cast.patch
323+0004-vptilefactory-avoid-illegal-reinterpret_cast.patch

Subscribers

People subscribed via source and target branches