[pim/libkleo] autotests: Fix logic error in EnvironmentVariableOverride helper

Ingo Klöcker <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit ebb7c849d5953288376c8ee15d42a45567f9d15e by Ingo Klöcker, on behalf of Ingo Klöcker.
Committed on 29/07/2026 at 08:02.
Pushed by kloecker into branch 'master'.

Fix logic error in EnvironmentVariableOverride helper

...and initialize mWasSet to avoid maybe-uninitialized warning

M  +2    -2    autotests/formattingtest.cpp

https://invent.kde.org/pim/libkleo/-/commit/ebb7c849d5953288376c8ee15d42a45567f9d15e

diff --git a/autotests/formattingtest.cpp b/autotests/formattingtest.cpp
index e5ec6f33..f992aae9 100644
--- a/autotests/formattingtest.cpp
+++ b/autotests/formattingtest.cpp
@@ -130,7 +130,7 @@ public:
 
     void set(const char *varName, QByteArrayView value)
     {
-        if (mVarName.isEmpty()) {
+        if (!mVarName.isEmpty()) {
             reset();
         }
         mWasSet = qEnvironmentVariableIsSet(varName);
@@ -156,7 +156,7 @@ public:
 
 private:
     QByteArray mVarName;
-    bool mWasSet;
+    bool mWasSet = false;
     QString mOldValue;
 };
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.