[frameworks/kcodecs] /: [KEncodingProber] Explicitly initialize some structs

Stefan Brüns <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 380bf2eca54351b234b676b30249f7b523edd801 by Stefan Brüns.
Committed on 07/08/2026 at 13:10.
Pushed by bruns into branch 'master'.

[KEncodingProber] Explicitly initialize some structs

M  +3    -3    autotests/kencodingproberunittest.cpp
M  +7    -7    src/probers/nsCodingStateMachine.h

https://invent.kde.org/frameworks/kcodecs/-/commit/380bf2eca54351b234b676b30249f7b523edd801

diff --git a/autotests/kencodingproberunittest.cpp b/autotests/kencodingproberunittest.cpp
index 9c3b958..7f6fc9f 100644
--- a/autotests/kencodingproberunittest.cpp
+++ b/autotests/kencodingproberunittest.cpp
@@ -184,10 +184,10 @@ void KEncodingProberUnitTest::testUtf16_common_data()
     QTest::addRow("LE LS at start") << QByteArray("\x00\xDC", 2) << true << false;
 
     struct Utf16TestData {
-        const char *name;
+        const char *name = nullptr;
         const std::span<const char16_t> data;
-        bool validBig;
-        bool validLittle;
+        bool validBig = false;
+        bool validLittle = false;
     };
     using namespace std::string_view_literals;
     constexpr std::array<Utf16TestData, 7> utf16TestData = {
diff --git a/src/probers/nsCodingStateMachine.h b/src/probers/nsCodingStateMachine.h
index 4aeccc9..dcfc789 100644
--- a/src/probers/nsCodingStateMachine.h
+++ b/src/probers/nsCodingStateMachine.h
@@ -26,13 +26,13 @@ using nsClassTable = const std::array<const uint8_t, 256> &;
 using nsStateTable = std::span<const uint8_t>;
 
 // state machine model
-typedef struct {
-    nsClassTable classTable;
-    unsigned int classFactor;
-    nsStateTable stateTable;
-    const unsigned int *charLenTable;
-    const char *name;
-} SMModel;
+struct SMModel {
+    nsClassTable classTable = {};
+    unsigned int classFactor = {};
+    nsStateTable stateTable = {};
+    const unsigned int *charLenTable = nullptr;
+    const char *name = nullptr;
+};
 
 class KCODECS_NO_EXPORT nsCodingStateMachine
 {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.