From 6cfb5a9c8816df5afe35ac85a14fc555a7b4ded6 Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 11:49:26 +0200
Subject: [PATCH 01/14] [welcome] Reduce unused-parameter warnings

 - Don't use this if we don't need it (QObject::tr is static).
 - C++14 allows (copy) binding to arbitrary expresstions in lambda's,
   so detach from this.
---
 .../welcome/checker/GeneralRequirements.cpp   | 28 ++++++++-----------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/src/modules/welcome/checker/GeneralRequirements.cpp b/src/modules/welcome/checker/GeneralRequirements.cpp
index dd43baafd..067105b28 100644
--- a/src/modules/welcome/checker/GeneralRequirements.cpp
+++ b/src/modules/welcome/checker/GeneralRequirements.cpp
@@ -105,44 +105,40 @@ Calamares::RequirementsList GeneralRequirements::checkRequirements()
         if ( entry == "storage" )
             checkEntries.append( {
                 entry,
-                [this]{ return tr( "has at least %1 GB available drive space" )
-                    .arg( m_requiredStorageGB ); },
-                [this]{ return tr( "There is not enough drive space. At least %1 GB is required." )
-                    .arg( m_requiredStorageGB ); },
+                [req=m_requiredStorageGB]{ return tr( "has at least %1 GB available drive space" ).arg( req ); },
+                [req=m_requiredStorageGB]{ return tr( "There is not enough drive space. At least %1 GB is required." ).arg( req ); },
                 enoughStorage,
                 m_entriesToRequire.contains( entry )
             } );
         else if ( entry == "ram" )
             checkEntries.append( {
                 entry,
-                [this]{ return tr( "has at least %1 GB working memory" )
-                    .arg( m_requiredRamGB ); },
-                [this]{ return tr( "The system does not have enough working memory. At least %1 GB is required." )
-                    .arg( m_requiredRamGB ); },
+                [req=m_requiredRamGB]{ return tr( "has at least %1 GB working memory" ).arg( req ); },
+                [req=m_requiredRamGB]{ return tr( "The system does not have enough working memory. At least %1 GB is required." ).arg( req ); },
                 enoughRam,
                 m_entriesToRequire.contains( entry )
             } );
         else if ( entry == "power" )
             checkEntries.append( {
                 entry,
-                [this]{ return tr( "is plugged in to a power source" ); },
-                [this]{ return tr( "The system is not plugged in to a power source." ); },
+                []{ return tr( "is plugged in to a power source" ); },
+                []{ return tr( "The system is not plugged in to a power source." ); },
                 hasPower,
                 m_entriesToRequire.contains( entry )
             } );
         else if ( entry == "internet" )
             checkEntries.append( {
                 entry,
-                [this]{ return tr( "is connected to the Internet" ); },
-                [this]{ return tr( "The system is not connected to the Internet." ); },
+                []{ return tr( "is connected to the Internet" ); },
+                []{ return tr( "The system is not connected to the Internet." ); },
                 hasInternet,
                 m_entriesToRequire.contains( entry )
             } );
         else if ( entry == "root" )
             checkEntries.append( {
                 entry,
-                [this]{ return QString(); }, //we hide it
-                [this]{ return Calamares::Settings::instance()->isSetupMode()
+                []{ return QString(); }, //we hide it
+                []{ return Calamares::Settings::instance()->isSetupMode()
                             ? tr( "The setup program is not running with administrator rights." )
                             : tr( "The installer is not running with administrator rights." ); },
                 isRoot,
@@ -151,8 +147,8 @@ Calamares::RequirementsList GeneralRequirements::checkRequirements()
         else if ( entry == "screen" )
             checkEntries.append( {
                 entry,
-                [this]{ return QString(); }, // we hide it
-                [this]{ return Calamares::Settings::instance()->isSetupMode()
+                []{ return QString(); }, // we hide it
+                []{ return Calamares::Settings::instance()->isSetupMode()
                             ? tr( "The screen is too small to display the setup program." )
                             : tr( "The screen is too small to display the installer." ); },
                 enoughScreen,

From 189e192c83785cba54e17df0eb1740cf1050ba31 Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 12:13:30 +0200
Subject: [PATCH 02/14] [shellprocess] Reduce warnings

 - The old-style cast still causes a warning, but do the
   more idiomatic (void) rather then casting to (void*)
---
 src/modules/shellprocess/Tests.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/shellprocess/Tests.cpp b/src/modules/shellprocess/Tests.cpp
index 068aefda5..4928e28dd 100644
--- a/src/modules/shellprocess/Tests.cpp
+++ b/src/modules/shellprocess/Tests.cpp
@@ -176,9 +176,9 @@ script:
 )" ) ).toMap().value( "script" );
 
     if ( !Calamares::JobQueue::instance() )
-        (void *)new Calamares::JobQueue( nullptr );
+        (void)new Calamares::JobQueue( nullptr );
     if ( !Calamares::Settings::instance() )
-        (void *)new Calamares::Settings( QString(), true );
+        (void)new Calamares::Settings( QString(), true );
 
     Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
     QVERIFY( gs != nullptr );

From 620d2a769a69a14016abd2f8deb17f3e1c25557e Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 14:59:25 +0200
Subject: [PATCH 03/14] [users] Reduce compile warnings

 - Avoid C-style casts
 - Unfortunately needs some verbose casting machinery to do
   it "right" wrt. C++ type system.
---
 src/modules/users/CheckPWQuality.cpp | 50 +++++++++++++++++++---------
 1 file changed, 34 insertions(+), 16 deletions(-)

diff --git a/src/modules/users/CheckPWQuality.cpp b/src/modules/users/CheckPWQuality.cpp
index a78edd754..e44729168 100644
--- a/src/modules/users/CheckPWQuality.cpp
+++ b/src/modules/users/CheckPWQuality.cpp
@@ -93,6 +93,25 @@ DEFINE_CHECK_FUNC( maxLength )
 }
 
 #ifdef HAVE_LIBPWQUALITY
+/* NOTE:
+ * 
+ * The munge*() functions are here because libpwquality uses void* to
+ * represent user-data in callbacks and as a general "pass some parameter"
+ * type. These need to be munged to the right C++ type.
+ */
+
+/// @brief Handle libpwquality using void* to represent a long
+static inline long mungeLong( void* p )
+{
+    return static_cast<long>( reinterpret_cast<intptr_t>( p ) );
+}
+
+/// @brief Handle libpwquality using void* to represent a char*
+static inline const char* mungeString( void* p )
+{
+    return reinterpret_cast<const char*>( p );
+}
+
 /**
  * Class that acts as a RAII placeholder for pwquality_settings_t pointers.
  * Gets a new pointer and ensures it is deleted only once; provides
@@ -111,7 +130,6 @@ public:
 
     ~PWSettingsHolder()
     {
-        cDebug() << "Freeing PWQ@" << ( void* )m_settings;
         pwquality_free_settings( m_settings );
     }
 
@@ -155,7 +173,7 @@ public:
         case PWQ_ERROR_MEM_ALLOC:
             if ( auxerror )
             {
-                QString s = QCoreApplication::translate( "PWQ", "Memory allocation error when setting '%1'" ).arg( ( const char* )auxerror );
+                QString s = QCoreApplication::translate( "PWQ", "Memory allocation error when setting '%1'" ).arg( mungeString( auxerror ) );
                 free( auxerror );
                 return s;
             }
@@ -176,41 +194,41 @@ public:
             return QCoreApplication::translate( "PWQ", "The password contains forbidden words in some form" );
         case PWQ_ERROR_MIN_DIGITS:
             if ( auxerror )
-                return QCoreApplication::translate( "PWQ", "The password contains less than %1 digits" ).arg( ( long )auxerror );
+                return QCoreApplication::translate( "PWQ", "The password contains less than %1 digits" ).arg( mungeLong( auxerror ) );
             return QCoreApplication::translate( "PWQ", "The password contains too few digits" );
         case PWQ_ERROR_MIN_UPPERS:
             if ( auxerror )
-                return QCoreApplication::translate( "PWQ", "The password contains less than %1 uppercase letters" ).arg( ( long )auxerror );
+                return QCoreApplication::translate( "PWQ", "The password contains less than %1 uppercase letters" ).arg( mungeLong( auxerror ) );
             return QCoreApplication::translate( "PWQ", "The password contains too few uppercase letters" );
         case PWQ_ERROR_MIN_LOWERS:
             if ( auxerror )
-                return QCoreApplication::translate( "PWQ", "The password contains less than %1 lowercase letters" ).arg( ( long )auxerror );
+                return QCoreApplication::translate( "PWQ", "The password contains less than %1 lowercase letters" ).arg( mungeLong( auxerror ) );
             return QCoreApplication::translate( "PWQ", "The password contains too few lowercase letters" );
         case PWQ_ERROR_MIN_OTHERS:
             if ( auxerror )
-                return QCoreApplication::translate( "PWQ", "The password contains less than %1 non-alphanumeric characters" ).arg( ( long )auxerror );
+                return QCoreApplication::translate( "PWQ", "The password contains less than %1 non-alphanumeric characters" ).arg( mungeLong( auxerror ) );
             return QCoreApplication::translate( "PWQ", "The password contains too few non-alphanumeric characters" );
         case PWQ_ERROR_MIN_LENGTH:
             if ( auxerror )
-                return QCoreApplication::translate( "PWQ", "The password is shorter than %1 characters" ).arg( ( long )auxerror );
+                return QCoreApplication::translate( "PWQ", "The password is shorter than %1 characters" ).arg( mungeLong( auxerror ) );
             return QCoreApplication::translate( "PWQ", "The password is too short" );
         case PWQ_ERROR_ROTATED:
             return QCoreApplication::translate( "PWQ", "The password is just rotated old one" );
         case PWQ_ERROR_MIN_CLASSES:
             if ( auxerror )
-                return QCoreApplication::translate( "PWQ", "The password contains less than %1 character classes" ).arg( ( long )auxerror );
+                return QCoreApplication::translate( "PWQ", "The password contains less than %1 character classes" ).arg( mungeLong( auxerror ) );
             return QCoreApplication::translate( "PWQ", "The password does not contain enough character classes" );
         case PWQ_ERROR_MAX_CONSECUTIVE:
             if ( auxerror )
-                return QCoreApplication::translate( "PWQ", "The password contains more than %1 same characters consecutively" ).arg( ( long )auxerror );
+                return QCoreApplication::translate( "PWQ", "The password contains more than %1 same characters consecutively" ).arg( mungeLong( auxerror ) );
             return QCoreApplication::translate( "PWQ", "The password contains too many same characters consecutively" );
         case PWQ_ERROR_MAX_CLASS_REPEAT:
             if ( auxerror )
-                return QCoreApplication::translate( "PWQ", "The password contains more than %1 characters of the same class consecutively" ).arg( ( long )auxerror );
+                return QCoreApplication::translate( "PWQ", "The password contains more than %1 characters of the same class consecutively" ).arg( mungeLong( auxerror ) );
             return QCoreApplication::translate( "PWQ", "The password contains too many characters of the same class consecutively" );
         case PWQ_ERROR_MAX_SEQUENCE:
             if ( auxerror )
-                return QCoreApplication::translate( "PWQ", "The password contains monotonic sequence longer than %1 characters" ).arg( ( long )auxerror );
+                return QCoreApplication::translate( "PWQ", "The password contains monotonic sequence longer than %1 characters" ).arg( mungeLong( auxerror ) );
             return QCoreApplication::translate( "PWQ", "The password contains too long of a monotonic character sequence" );
         case PWQ_ERROR_EMPTY_PASSWORD:
             return QCoreApplication::translate( "PWQ", "No password supplied" );
@@ -222,13 +240,13 @@ public:
             if ( auxerror )
             {
                 /* Here the string comes from cracklib, don't free? */
-                return QCoreApplication::translate( "PWQ", "The password fails the dictionary check - %1" ).arg( ( const char* )auxerror );
+                return QCoreApplication::translate( "PWQ", "The password fails the dictionary check - %1" ).arg( mungeString( auxerror ) );
             }
             return QCoreApplication::translate( "PWQ", "The password fails the dictionary check" );
         case PWQ_ERROR_UNKNOWN_SETTING:
             if ( auxerror )
             {
-                QString s = QCoreApplication::translate( "PWQ", "Unknown setting - %1" ).arg( ( const char* )auxerror );
+                QString s = QCoreApplication::translate( "PWQ", "Unknown setting - %1" ).arg( mungeString( auxerror ) );
                 free( auxerror );
                 return s;
             }
@@ -236,7 +254,7 @@ public:
         case PWQ_ERROR_INTEGER:
             if ( auxerror )
             {
-                QString s = QCoreApplication::translate( "PWQ", "Bad integer value of setting - %1" ).arg( ( const char* )auxerror );
+                QString s = QCoreApplication::translate( "PWQ", "Bad integer value of setting - %1" ).arg( mungeString( auxerror ) );
                 free( auxerror );
                 return s;
             }
@@ -244,7 +262,7 @@ public:
         case PWQ_ERROR_NON_INT_SETTING:
             if ( auxerror )
             {
-                QString s = QCoreApplication::translate( "PWQ", "Setting %1 is not of integer type" ).arg( ( const char* )auxerror );
+                QString s = QCoreApplication::translate( "PWQ", "Setting %1 is not of integer type" ).arg( mungeString( auxerror ) );
                 free( auxerror );
                 return s;
             }
@@ -252,7 +270,7 @@ public:
         case PWQ_ERROR_NON_STR_SETTING:
             if ( auxerror )
             {
-                QString s = QCoreApplication::translate( "PWQ", "Setting %1 is not of string type" ).arg( ( const char* )auxerror );
+                QString s = QCoreApplication::translate( "PWQ", "Setting %1 is not of string type" ).arg( mungeString( auxerror ) );
                 free( auxerror );
                 return s;
             }

From b10c7ad9c6f441c001a556ba9c6cd61b183364b8 Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 15:12:24 +0200
Subject: [PATCH 04/14] [locale] Reduce warnings for gcount()

 - The read is at most sizeof(arr), so int is fine. Do
   the cast explicitly.
---
 src/modules/locale/test_geoip.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/locale/test_geoip.cpp b/src/modules/locale/test_geoip.cpp
index 5ba43f72e..89c1b6030 100644
--- a/src/modules/locale/test_geoip.cpp
+++ b/src/modules/locale/test_geoip.cpp
@@ -54,8 +54,8 @@ int main(int argc, char** argv)
     QByteArray ba;
     while( !std::cin.eof() ) {
         char arr[1024];
-        std::cin.read(arr,sizeof(arr));
-        int s = std::cin.gcount();
+        std::cin.read(arr, sizeof(arr));
+        int s = static_cast<int>( std::cin.gcount() );
         ba.append(arr, s);
     }
 

From b416842c205567c49900578e5b3c7f1f19fa8248 Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 12:14:04 +0200
Subject: [PATCH 05/14] [calamares] Reduce compile warnings in tests

 - Switch debug-level to unsigned
 - Don't shadow usings; the first TR type is enough
 - The (bogus) return values were commented as // NOTREACHED,
   but still yield unreachable code warnings. Drop them
   instead, and rely on the compiler understanding [[noreturn]]
   on parser.usage().
---
 src/calamares/testmain.cpp | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/calamares/testmain.cpp b/src/calamares/testmain.cpp
index 7fcbec666..69c2f0884 100644
--- a/src/calamares/testmain.cpp
+++ b/src/calamares/testmain.cpp
@@ -80,9 +80,9 @@ handle_args( QCoreApplication& a )
     if ( parser.isSet( debugLevelOption ) )
     {
         bool ok = true;
-        int l = parser.value( debugLevelOption ).toInt( &ok );
+        unsigned int l = parser.value( debugLevelOption ).toUInt( &ok );
         unsigned int dlevel = 0;
-        if ( !ok || ( l < 0 ) )
+        if ( !ok )
             dlevel = Logger::LOGVERBOSE;
         else
             dlevel = l;
@@ -94,20 +94,20 @@ handle_args( QCoreApplication& a )
     {
         cError() << "Missing <module> path.\n";
         parser.showHelp();
-        return ModuleConfig();  // NOTREACHED
     }
-    if ( args.size() > 2 )
+    else if ( args.size() > 2 )
     {
         cError() << "More than one <module> path.\n";
         parser.showHelp();
-        return ModuleConfig();  // NOTREACHED
     }
+    else
+    {
+        QString jobSettings( parser.value( jobOption ) );
+        if ( jobSettings.isEmpty() && ( args.size() == 2 ) )
+            jobSettings = args.at(1);
 
-    QString jobSettings( parser.value( jobOption ) );
-    if ( jobSettings.isEmpty() && ( args.size() == 2 ) )
-        jobSettings = args.at(1);
-
-    return ModuleConfig{ args.first(), jobSettings, parser.value( globalOption ), parser.value( langOption ) };
+        return ModuleConfig{ args.first(), jobSettings, parser.value( globalOption ), parser.value( langOption ) };
+    }
 }
 
 
@@ -207,7 +207,7 @@ main( int argc, char* argv[] )
         return 1;
     }
 
-    using TR = Logger::DebugRow<const char*, const QString&>;
+    using TR = Logger::DebugRow<const char*, const QString>;
 
     cDebug() << "Module metadata"
         << TR( "name", m->name() )
@@ -223,7 +223,6 @@ main( int argc, char* argv[] )
         Calamares::JobResult r = p->exec();
         if ( !r )
         {
-            using TR = Logger::DebugRow<QString, QString>;
             cDebug() << count << ".. failed"
                 << TR( "summary", r.message() )
                 << TR( "details", r.details() );

From d2941d335ea840d8656d9a222c84c478b855f8a3 Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 12:11:03 +0200
Subject: [PATCH 06/14] [libcalamares] Reduce unused-parameter warnings

 - The tag-class "parameters" are empty anyway
---
 src/libcalamares/utils/Logger.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/libcalamares/utils/Logger.cpp b/src/libcalamares/utils/Logger.cpp
index 31dd44978..3061e0a5e 100644
--- a/src/libcalamares/utils/Logger.cpp
+++ b/src/libcalamares/utils/Logger.cpp
@@ -193,28 +193,28 @@ static const char continuation[] = "\n    ";
 static const char subentry[] = " .. ";
 
 QDebug&
-operator<<( QDebug& s, Continuation c )
+operator<<( QDebug& s, Continuation )
 {
     s << continuation;
     return s;
 }
 
 QDebug&
-operator<<( QDebug& s, SubEntry l )
+operator<<( QDebug& s, SubEntry )
 {
     s << subentry;
     return s;
 }
 
 CDebug&
-operator<<( CDebug&& s, Continuation c )
+operator<<( CDebug&& s, Continuation )
 {
     s << continuation;
     return s;
 }
 
 CDebug&
-operator<<( CDebug&& s, SubEntry l )
+operator<<( CDebug&& s, SubEntry )
 {
     s << subentry;
     return s;

From c13c7c4891e762d0524796808d497ef575774790 Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 12:31:57 +0200
Subject: [PATCH 07/14] [libcalamares] Don't use (bare) endl

 - Use '\n' instead of endl (which should have been std::endl).
---
 src/libcalamares/utils/CalamaresUtils.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libcalamares/utils/CalamaresUtils.cpp b/src/libcalamares/utils/CalamaresUtils.cpp
index 4a8b1f528..8441218d2 100644
--- a/src/libcalamares/utils/CalamaresUtils.cpp
+++ b/src/libcalamares/utils/CalamaresUtils.cpp
@@ -62,7 +62,7 @@ isWritableDir( const QDir& dir )
     {
         if ( !dir.mkpath( "." ) )
         {
-            cerr << "warning: failed to create " << qPrintable( path ) << endl;
+            cerr << "warning: failed to create " << qPrintable( path ) << '\n';
             return false;
         }
         return true;

From 5279e78c9f1b10cdd8c466a22f2c1cfb04dc30c5 Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 13:09:01 +0200
Subject: [PATCH 08/14] [libcalamares] Reduce warnings

 - improve variable names, don't shadow
---
 src/libcalamares/utils/CommandList.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/libcalamares/utils/CommandList.cpp b/src/libcalamares/utils/CommandList.cpp
index 8e332a066..6a9d68bef 100644
--- a/src/libcalamares/utils/CommandList.cpp
+++ b/src/libcalamares/utils/CommandList.cpp
@@ -45,21 +45,21 @@ static CommandLine get_variant_object( const QVariantMap& m )
 static CommandList_t get_variant_stringlist( const QVariantList& l )
 {
     CommandList_t retl;
-    unsigned int c = 0;
+    unsigned int count = 0;
     for ( const auto& v : l )
     {
         if ( v.type() == QVariant::String )
             retl.append( CommandLine( v.toString(), CommandLine::TimeoutNotSet ) );
         else if ( v.type() == QVariant::Map )
         {
-            auto c( get_variant_object( v.toMap() ) );
-            if ( c.isValid() )
-                retl.append( c );
+            auto command( get_variant_object( v.toMap() ) );
+            if ( command.isValid() )
+                retl.append( command );
             // Otherwise warning is already given
         }
         else
-            cWarning() << "Bad CommandList element" << c << v.type() << v;
-        ++c;
+            cWarning() << "Bad CommandList element" << count << v.type() << v;
+        ++count;
     }
     return retl;
 }

From 2777b5dd30071d8ffe837833eb0a27f1c51a4a3d Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 13:26:02 +0200
Subject: [PATCH 09/14] [libcalamares] Reduce copying and warnings

---
 src/libcalamares/utils/NamedEnum.h   | 4 ++--
 src/libcalamares/utils/NamedSuffix.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libcalamares/utils/NamedEnum.h b/src/libcalamares/utils/NamedEnum.h
index 047ae6f19..b4c7dcd56 100644
--- a/src/libcalamares/utils/NamedEnum.h
+++ b/src/libcalamares/utils/NamedEnum.h
@@ -66,7 +66,7 @@ struct NamedEnumTable
     {
         ok = false;
 
-        for ( const auto p : table )
+        for ( const auto& p : table )
             if ( 0 == QString::compare( s, p.first, Qt::CaseInsensitive ) )
             {
                 ok = true;
@@ -87,7 +87,7 @@ struct NamedEnumTable
     {
         ok = false;
 
-        for ( const auto p : table )
+        for ( const auto &p : table )
             if ( s == p.second)
             {
                 ok = true;
diff --git a/src/libcalamares/utils/NamedSuffix.h b/src/libcalamares/utils/NamedSuffix.h
index 97568d1da..d4a0ed4b7 100644
--- a/src/libcalamares/utils/NamedSuffix.h
+++ b/src/libcalamares/utils/NamedSuffix.h
@@ -72,7 +72,7 @@ public:
     NamedSuffix( const NamedEnumTable<T>& table, const QString& s )
         : NamedSuffix()
     {
-        for( const auto suffix : table.table )
+        for( const auto& suffix : table.table )
             if ( s.endsWith( suffix.first ) )
             {
                 m_value = s.left( s.length() - suffix.first.length() ).toInt();

From 365f83b7899b6c9bdaad4634f637c1d411514dcf Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 15:13:26 +0200
Subject: [PATCH 10/14] [libcalamares] Reduce warnings in KDAB code

 - Use nullptr and suitable include guards
---
 .../kdsingleapplicationguard.h                       | 12 ++++++------
 .../kdsingleapplicationguard/kdtoolsglobal.h         |  6 +++---
 .../kdsingleapplicationguard/pimpl_ptr.h             |  8 ++++----
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/libcalamares/kdsingleapplicationguard/kdsingleapplicationguard.h b/src/libcalamares/kdsingleapplicationguard/kdsingleapplicationguard.h
index 7b744e110..3bd1e644d 100644
--- a/src/libcalamares/kdsingleapplicationguard/kdsingleapplicationguard.h
+++ b/src/libcalamares/kdsingleapplicationguard/kdsingleapplicationguard.h
@@ -1,5 +1,5 @@
-#ifndef __KDTOOLSCORE_KDSINGLEAPPLICATIONGUARD_H__
-#define __KDTOOLSCORE_KDSINGLEAPPLICATIONGUARD_H__
+#ifndef KDTOOLSCORE_KDSINGLEAPPLICATIONGUARD_H
+#define KDTOOLSCORE_KDSINGLEAPPLICATIONGUARD_H
 
 #include <QtCore/QObject>
 
@@ -31,9 +31,9 @@ public:
         AutoKillOtherInstances = 1
     };
 
-    explicit KDSingleApplicationGuard( QObject * parent=0 );
-    explicit KDSingleApplicationGuard( Policy policy, QObject * parent=0 );
-    explicit KDSingleApplicationGuard( const QStringList & arguments, QObject * parent=0 );
+    explicit KDSingleApplicationGuard( QObject * parent=nullptr );
+    explicit KDSingleApplicationGuard( Policy policy, QObject * parent=nullptr );
+    explicit KDSingleApplicationGuard( const QStringList & arguments, QObject * parent=nullptr );
     explicit KDSingleApplicationGuard( const QStringList & arguments, Policy policy, QObject * parent=0 );
     ~KDSingleApplicationGuard();
 
@@ -138,4 +138,4 @@ QT_END_NAMESPACE
 
 #endif // QT_NO_SHAREDMEMORY
 
-#endif /* __KDTOOLSCORE_KDSINGLEAPPLICATIONGUARD_H__ */
+#endif /* KDTOOLSCORE_KDSINGLEAPPLICATIONGUARD_H */
diff --git a/src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.h b/src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.h
index a0f004589..e23b78965 100644
--- a/src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.h
+++ b/src/libcalamares/kdsingleapplicationguard/kdtoolsglobal.h
@@ -1,5 +1,5 @@
-#ifndef __KDTOOLS_KDTOOLSGLOBAL_H__
-#define __KDTOOLS_KDTOOLSGLOBAL_H__
+#ifndef KDTOOLS_KDTOOLSGLOBAL_H
+#define KDTOOLS_KDTOOLSGLOBAL_H
 
 #include <QtCore/QtGlobal>
 
@@ -110,5 +110,5 @@ private:                                                                \
     void init(bool)
 
 
-#endif /* __KDTOOLS_KDTOOLSGLOBAL_H__ */
+#endif /* KDTOOLS_KDTOOLSGLOBAL_H */
 
diff --git a/src/libcalamares/kdsingleapplicationguard/pimpl_ptr.h b/src/libcalamares/kdsingleapplicationguard/pimpl_ptr.h
index 7b7f36839..6f01cd64c 100644
--- a/src/libcalamares/kdsingleapplicationguard/pimpl_ptr.h
+++ b/src/libcalamares/kdsingleapplicationguard/pimpl_ptr.h
@@ -1,5 +1,5 @@
-#ifndef __KDTOOLSCORE__PIMPL_PTR_H__
-#define __KDTOOLSCORE__PIMPL_PTR_H__
+#ifndef KDTOOLSCORE__PIMPL_PTR_H
+#define KDTOOLSCORE__PIMPL_PTR_H
 
 #include "kdtoolsglobal.h"
 
@@ -14,7 +14,7 @@ namespace kdtools {
     public:
         pimpl_ptr() : d( new T ) {}
         explicit pimpl_ptr( T * t ) : d( t ) {}
-        ~pimpl_ptr() { delete d; d = 0; }
+        ~pimpl_ptr() { delete d; d = nullptr; }
 
         T * get() { return d; }
         const T * get() const { return d; }
@@ -40,5 +40,5 @@ namespace kdtools {
 } // namespace kdtools
 #endif
 
-#endif /* __KDTOOLSCORE__PIMPL_PTR_H__ */
+#endif /* KDTOOLSCORE__PIMPL_PTR_H */
 

From 8dd22dcbbfffae39e0a3bec4b6fb084ad7038b7b Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 12:35:38 +0200
Subject: [PATCH 11/14] [libcalamaresui] bail() is a [[noreturn]] function

---
 src/libcalamaresui/Branding.cpp | 2 +-
 src/libcalamaresui/Branding.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp
index 15c1c6125..e24e80472 100644
--- a/src/libcalamaresui/Branding.cpp
+++ b/src/libcalamaresui/Branding.cpp
@@ -353,7 +353,7 @@ Branding::initSimpleSettings( const YAML::Node& doc )
 }
 
 
-void
+[[noreturn]] void
 Branding::bail( const QString& message )
 {
     cError() << "FATAL in"
diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h
index d97e0595a..5063a1df1 100644
--- a/src/libcalamaresui/Branding.h
+++ b/src/libcalamaresui/Branding.h
@@ -132,7 +132,7 @@ private:
     static const QStringList s_imageEntryStrings;
     static const QStringList s_styleEntryStrings;
 
-    void bail( const QString& message );
+    [[noreturn]] void bail( const QString& message );
 
     QString m_descriptorPath;
     QString m_componentName;

From 1008a91eba842aafc3189cb56b592045f5cf8361 Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 13:09:31 +0200
Subject: [PATCH 12/14] [libcalamaresui] Reduce warnings

 - getting a (sensible) uint from an int is tougher than you might think
---
 src/libcalamaresui/modulesystem/RequirementsChecker.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/libcalamaresui/modulesystem/RequirementsChecker.cpp b/src/libcalamaresui/modulesystem/RequirementsChecker.cpp
index c7f4625eb..1e98a3968 100644
--- a/src/libcalamaresui/modulesystem/RequirementsChecker.cpp
+++ b/src/libcalamaresui/modulesystem/RequirementsChecker.cpp
@@ -143,8 +143,9 @@ RequirementsChecker::reportProgress()
     auto remaining = std::count_if( m_watchers.cbegin(), m_watchers.cend(), []( const Watcher *w ) { return w && !w->isFinished(); } );
     if ( remaining > 0 )
     {
+        unsigned int posInterval = ( m_progressTimer->interval() < 0 ) ? 1000 : uint( m_progressTimer->interval() );
         QString waiting = tr( "Waiting for %n module(s).", "", remaining );
-        QString elapsed = tr( "(%n second(s))", "", m_progressTimeouts * m_progressTimer->interval() / 1000 );
+        QString elapsed = tr( "(%n second(s))", "", m_progressTimeouts * posInterval / 1000 );
         emit requirementsProgress( waiting + QString( " " ) + elapsed );
     }
     else

From 6560c194ad3e1df590865909cecad6514d348a89 Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 13:15:10 +0200
Subject: [PATCH 13/14] [libcalamaresui] Reduce 0-for-nullptr warnings in 3rd
 party code

 - replace = 0 with = nullptr to reduce warnings; not a meaningful
   or copyrightable change.
---
 src/libcalamaresui/utils/qjsonitem.h              | 4 ++--
 src/libcalamaresui/utils/qjsonmodel.h             | 2 +-
 src/libcalamaresui/widgets/waitingspinnerwidget.h | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/libcalamaresui/utils/qjsonitem.h b/src/libcalamaresui/utils/qjsonitem.h
index 5a8b2134f..113c9da97 100644
--- a/src/libcalamaresui/utils/qjsonitem.h
+++ b/src/libcalamaresui/utils/qjsonitem.h
@@ -13,7 +13,7 @@
 class QJsonTreeItem
 {
 public:
-    QJsonTreeItem(QJsonTreeItem * parent = 0);
+    QJsonTreeItem(QJsonTreeItem * parent = nullptr);
     ~QJsonTreeItem();
     void appendChild(QJsonTreeItem * item);
     QJsonTreeItem *child(int row);
@@ -28,7 +28,7 @@ public:
     QJsonValue::Type type() const;
 
 
-    static QJsonTreeItem* load(const QJsonValue& value, QJsonTreeItem * parent = 0);
+    static QJsonTreeItem* load(const QJsonValue& value, QJsonTreeItem * parent = nullptr);
 
 protected:
 
diff --git a/src/libcalamaresui/utils/qjsonmodel.h b/src/libcalamaresui/utils/qjsonmodel.h
index 0d1b3232d..fc2c4abe1 100644
--- a/src/libcalamaresui/utils/qjsonmodel.h
+++ b/src/libcalamaresui/utils/qjsonmodel.h
@@ -16,7 +16,7 @@ class QJsonModel : public QAbstractItemModel
 {
     Q_OBJECT
 public:
-    explicit QJsonModel(QObject *parent = 0);
+    explicit QJsonModel(QObject *parent = nullptr);
     ~QJsonModel();
     bool load(const QString& fileName);
     bool load(QIODevice * device);
diff --git a/src/libcalamaresui/widgets/waitingspinnerwidget.h b/src/libcalamaresui/widgets/waitingspinnerwidget.h
index 0ed8e69d3..d71976ef8 100644
--- a/src/libcalamaresui/widgets/waitingspinnerwidget.h
+++ b/src/libcalamaresui/widgets/waitingspinnerwidget.h
@@ -37,7 +37,7 @@ class WaitingSpinnerWidget : public QWidget {
 public:
     /*! Constructor for "standard" widget behaviour - use this
    * constructor if you wish to, e.g. embed your widget in another. */
-    WaitingSpinnerWidget(QWidget *parent = 0,
+    WaitingSpinnerWidget(QWidget *parent = nullptr,
                          bool centerOnParent = true,
                          bool disableParentWhenSpinning = true);
 
@@ -47,7 +47,7 @@ public:
    * QtWaitingSpinner automatically centres itself on it, if not,
    * "centreOnParent" is ignored. */
     WaitingSpinnerWidget(Qt::WindowModality modality,
-                         QWidget *parent = 0,
+                         QWidget *parent = nullptr,
                          bool centerOnParent = true,
                          bool disableParentWhenSpinning = true);
 

From 5a95bf507fd7be505cdef63fac204204a1e5363a Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Thu, 11 Apr 2019 14:26:16 +0200
Subject: [PATCH 14/14] [libcalamaresui] Improve WindowDimensions class

 - Make sure the class knows its own suffixes
---
 src/libcalamaresui/Branding.cpp | 13 ++++---------
 src/libcalamaresui/Branding.h   |  5 ++++-
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp
index e24e80472..e31130520 100644
--- a/src/libcalamaresui/Branding.cpp
+++ b/src/libcalamaresui/Branding.cpp
@@ -78,8 +78,8 @@ const QStringList Branding::s_styleEntryStrings =
     "sidebarTextHighlight"
 };
 
-static const NamedEnumTable<Branding::WindowDimensionUnit>&
-windowDimensions()
+const NamedEnumTable<Branding::WindowDimensionUnit>&
+Branding::WindowDimension::suffixes()
 {
     using Unit = Branding::WindowDimensionUnit;
     static const NamedEnumTable<Unit> names{
@@ -323,11 +323,6 @@ Branding::initSimpleSettings( const YAML::Node& doc )
         { QStringLiteral( "fullscreen" ), WindowExpansion::Fullscreen },
         { QStringLiteral( "noexpand" ), WindowExpansion::Fixed }
     };
-    static const NamedEnumTable< WindowDimensionUnit > dimensionNames{
-        { QStringLiteral( "px" ), WindowDimensionUnit::Pixies },
-        { QStringLiteral( "em" ), WindowDimensionUnit::Fonties }
-    };
-
     bool ok = false;
 
     m_welcomeStyleCalamares = doc[ "welcomeStyleCalamares" ].as< bool >( false );
@@ -342,8 +337,8 @@ Branding::initSimpleSettings( const YAML::Node& doc )
         auto l = windowSize.split( ',' );
         if ( l.count() == 2 )
         {
-            m_windowWidth = WindowDimension( dimensionNames, l[0] );
-            m_windowHeight = WindowDimension( dimensionNames, l[1] );
+            m_windowWidth = WindowDimension( l[0] );
+            m_windowHeight = WindowDimension( l[1] );
         }
     }
     if ( !m_windowWidth.isValid() )
diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h
index 5063a1df1..197cb8ee2 100644
--- a/src/libcalamaresui/Branding.h
+++ b/src/libcalamaresui/Branding.h
@@ -89,8 +89,11 @@ public:
     class WindowDimension : public NamedSuffix<WindowDimensionUnit, WindowDimensionUnit::None>
     {
     public:
-        using NamedSuffix::NamedSuffix;
+        static  const NamedEnumTable< WindowDimensionUnit >& suffixes();
         bool isValid() const;
+
+        using NamedSuffix::NamedSuffix;
+        WindowDimension( const QString& s ) : NamedSuffix( suffixes(), s ) {}
     } ;
 
     static Branding* instance();