Merge branch 'reduce-warnings'

This commit is contained in:
Adriaan de Groot 2019-04-18 12:42:10 +02:00
commit fd5097c466
52 changed files with 124 additions and 96 deletions

View File

@ -208,6 +208,8 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( CMAKE_TOOLCHAIN_PREFIX "llvm-" )
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )
set( CALAMARES_AUTOMOC_OPTIONS "-butils/moc-warnings.h" )
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-undefined" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--fatal-warnings -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type" )
@ -509,6 +511,7 @@ install(
"CMakeModules/CalamaresAddLibrary.cmake"
"CMakeModules/CalamaresAddBrandingSubdirectory.cmake"
"CMakeModules/CalamaresAddTranslations.cmake"
"CMakeModules/CalamaresAutomoc.cmake"
"CMakeModules/CMakeColors.cmake"
DESTINATION
"${CMAKE_INSTALL_CMAKEDIR}"

View File

@ -44,6 +44,7 @@
# flag (i.e. `-D`) so only state the name (optionally, also the value)
# without a `-D` prefixed to it. Pass in a CMake list as needed.
include( CMakeParseArguments )
include( CalamaresAutomoc )
function(calamares_add_library)
# parse arguments (name needs to be saved before passing ARGN into the macro)
@ -81,10 +82,8 @@ function(calamares_add_library)
add_library(${target} SHARED ${LIBRARY_SOURCES})
endif()
# definitions - can this be moved into set_target_properties below?
add_definitions(${QT_DEFINITIONS})
set_target_properties(${target} PROPERTIES AUTOMOC TRUE)
calamares_automoc(${target})
if(LIBRARY_EXPORT_MACRO)
set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS ${LIBRARY_EXPORT_MACRO})
endif()

View File

@ -0,0 +1,36 @@
# === This file is part of Calamares - <https://github.com/calamares> ===
#
# Calamares is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Calamares is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0+
# License-Filename: LICENSE
#
###
#
# Helper function for doing automoc on a target.
#
# Sets AUTOMOC TRUE for a target.
#
# If the global variable CALAMARES_AUTOMOC_OPTIONS is set, uses that
# as well to set options passed to MOC. This can be used to add
# libcalamares/utils/moc-warnings.h file to the moc, which in turn
# reduces compiler warnings in generated MOC code.
#
function(calamares_automoc TARGET)
set_target_properties( ${TARGET} PROPERTIES AUTOMOC TRUE )
if ( CALAMARES_AUTOMOC_OPTIONS )
set_target_properties( ${TARGET} PROPERTIES AUTOMOC_MOC_OPTIONS "${CALAMARES_AUTOMOC_OPTIONS}" )
endif()
endfunction()

View File

@ -38,10 +38,10 @@ set( final_src ${calamaresSources} ${calamaresRc} ${trans_outfile} )
add_executable( calamares_bin ${final_src} )
set_target_properties(calamares_bin
PROPERTIES
AUTOMOC TRUE
ENABLE_EXPORTS TRUE
RUNTIME_OUTPUT_NAME calamares
)
calamares_automoc( calamares_bin )
if( WITH_KF5Crash )
set( LINK_LIBRARIES

View File

@ -84,9 +84,7 @@ ProgressTreeRoot::ProgressTreeRoot()
QVariant
ProgressTreeRoot::data( int role ) const
ProgressTreeRoot::data( int ) const
{
if ( role == ProgressTreeModel::ProgressTreeItemRole )
return this;
return QVariant();
}

View File

@ -98,9 +98,9 @@ ProgressTreeModel::data( const QModelIndex& index, int role ) const
QVariant
ProgressTreeModel::headerData( int section, Qt::Orientation orientation, int role ) const
{
Q_UNUSED( section );
Q_UNUSED( orientation );
Q_UNUSED( role );
Q_UNUSED( section )
Q_UNUSED( orientation )
Q_UNUSED( role )
return QVariant();
}

View File

@ -35,7 +35,6 @@ class ProgressTreeModel : public QAbstractItemModel
public:
enum Role
{
ProgressTreeItemRole = Qt::UserRole + 10,
ProgressTreeItemCurrentRole = Qt::UserRole + 11
};

View File

@ -46,15 +46,13 @@ void
ViewStepItem::appendChild( ProgressTreeItem* item )
{
Q_ASSERT( false );
Q_UNUSED( item );
Q_UNUSED( item )
}
QVariant
ViewStepItem::data( int role ) const
{
if ( role == ProgressTreeModel::ProgressTreeItemRole )
return this;
if ( role == Qt::DisplayRole )
{
return m_step ? m_step->prettyName()

View File

@ -84,10 +84,10 @@ endif()
add_library( calamares SHARED ${libSources} ${kdsagSources} ${utilsSources} )
set_target_properties( calamares
PROPERTIES
AUTOMOC TRUE
VERSION ${CALAMARES_VERSION_SHORT}
SOVERSION ${CALAMARES_VERSION_SHORT}
)
calamares_automoc( calamares )
target_link_libraries( calamares
LINK_PRIVATE
@ -114,7 +114,7 @@ if ( ECM_FOUND AND BUILD_TESTING )
Qt5::Core
Qt5::Test
)
set_target_properties( libcalamarestest PROPERTIES AUTOMOC TRUE )
calamares_automoc( libcalamarestest )
endif()
# Make symlink lib/calamares/libcalamares.so to lib/libcalamares.so.VERSION so

View File

@ -41,7 +41,7 @@ CppJob::setModuleInstanceKey( const QString& instanceKey )
void
CppJob::setConfigurationMap( const QVariantMap& configurationMap )
{
Q_UNUSED( configurationMap );
Q_UNUSED( configurationMap )
}
}

View File

@ -35,7 +35,6 @@ namespace Calamares
class JobThread : public QThread
{
Q_OBJECT
public:
JobThread( JobQueue* queue )
: QThread( queue )
@ -44,6 +43,8 @@ public:
{
}
virtual ~JobThread() override;
void setJobs( const JobList& jobs )
{
m_jobs = jobs;
@ -122,6 +123,10 @@ private:
}
};
JobThread::~JobThread()
{
}
JobQueue* JobQueue::s_instance = nullptr;
@ -184,5 +189,3 @@ JobQueue::enqueue( const JobList& jobs )
}
} // namespace Calamares
#include "JobQueue.moc"

View File

@ -92,7 +92,7 @@ BOOST_PYTHON_MODULE( libcalamares )
bp::object utilsModule( bp::handle<>( bp::borrowed( PyImport_AddModule( "libcalamares.utils" ) ) ) );
bp::scope().attr( "utils" ) = utilsModule;
bp::scope utilsScope = utilsModule;
Q_UNUSED( utilsScope );
Q_UNUSED( utilsScope )
bp::def(
"debug",

View File

@ -27,8 +27,6 @@
#include <QFile>
#include <QPair>
#include <yaml-cpp/yaml.h>
static bool
hasValue( const YAML::Node& v )
{

View File

@ -34,7 +34,7 @@ public:
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 );
explicit KDSingleApplicationGuard( const QStringList & arguments, Policy policy, QObject * parent=nullptr );
~KDSingleApplicationGuard();
bool isOperational() const;

View File

@ -27,7 +27,7 @@ static Version kdParseQtVersion( const char * const version ) {
return result;
}
bool _kdCheckQtVersion_impl( int major, int minor, int patchlevel ) {
bool _kdCheckQtVersion_impl( unsigned int major, unsigned int minor, unsigned int patchlevel ) {
static const Version actual = kdParseQtVersion( qVersion() ); // do this only once each run...
const Version requested = { { static_cast< unsigned char >( major ),
static_cast< unsigned char >( minor ),

View File

@ -78,7 +78,7 @@ inline T & __kdtools__dereference_for_methodcall( T * o ) {
#define KDAB_SET_OBJECT_NAME( x ) __kdtools__dereference_for_methodcall( x ).setObjectName( QLatin1String( #x ) )
KDTOOLSCORE_EXPORT bool _kdCheckQtVersion_impl( int major, int minor=0, int patchlevel=0 );
KDTOOLSCORE_EXPORT bool _kdCheckQtVersion_impl( unsigned int major, unsigned int minor=0, unsigned int patchlevel=0 );
static inline bool kdCheckQtVersion( unsigned int major, unsigned int minor=0, unsigned int patchlevel=0 ) {
return (major<<16|minor<<8|patchlevel) <= static_cast<unsigned int>(QT_VERSION)
|| _kdCheckQtVersion_impl( major, minor, patchlevel );

View File

@ -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"
@ -40,5 +40,5 @@ namespace kdtools {
} // namespace kdtools
#endif
#endif /* KDTOOLSCORE__PIMPL_PTR_H */
#endif /* KDTOOLSCORE_PIMPL_PTR_H */

View File

@ -99,12 +99,10 @@ log( const char* msg, unsigned int debugLevel )
static void
CalamaresLogHandler( QtMsgType type, const QMessageLogContext& context, const QString& msg )
CalamaresLogHandler( QtMsgType type, const QMessageLogContext&, const QString& msg )
{
static QMutex s_mutex;
Q_UNUSED( context );
QByteArray ba = msg.toUtf8();
const char* message = ba.constData();

View File

@ -269,7 +269,7 @@ protected:
template<class impl, class ParentType>
static QObject* createInstance( QWidget* parentWidget, QObject* parent )
{
Q_UNUSED( parentWidget );
Q_UNUSED( parentWidget )
ParentType* p = nullptr;
if ( parent )
{

View File

@ -20,8 +20,6 @@
#include "utils/Logger.h"
#include <yaml-cpp/yaml.h>
#include <QByteArray>
#include <QFile>
#include <QFileInfo>

View File

@ -26,11 +26,21 @@
class QByteArray;
class QFileInfo;
namespace YAML
{
class Node;
class Exception;
}
// The yaml-cpp headers are not C++11 warning-proof, especially
// with picky compilers like Clang 8. Since we use Clang for the
// find-all-the-warnings case, switch those warnings off for
// the we-can't-change-them system headers.
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#pragma clang diagnostic ignored "-Wshadow"
#endif
#include <yaml-cpp/yaml.h>
#ifdef __clang__
#pragma clang diagnostic pop
#endif
/// @brief Appends all te elements of @p node to the string list @p v
void operator>>( const YAML::Node& node, QStringList& v );

View File

@ -0,0 +1,4 @@
#ifdef __clang__
#pragma clang diagnostic ignored "-Wextra-semi-stmt"
#pragma clang diagnostic ignored "-Wredundant-parens"
#endif

View File

@ -32,9 +32,6 @@
#include <QPixmap>
#include <QVariantMap>
#include <yaml-cpp/yaml.h>
namespace Calamares
{

View File

@ -36,8 +36,6 @@
#include "PythonQtViewModule.h"
#endif
#include <yaml-cpp/yaml.h>
#include <QDir>
#include <QFile>
#include <QFileInfo>

View File

@ -28,8 +28,6 @@
#include "utils/Logger.h"
#include "utils/YamlUtils.h"
#include <yaml-cpp/yaml.h>
#include <QApplication>
#include <QDir>
#include <QTimer>

View File

@ -40,7 +40,7 @@ static int s_defaultFontHeight = 0;
QPixmap
defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
{
Q_UNUSED( mode );
Q_UNUSED( mode )
QPixmap pixmap;
switch ( type )

View File

@ -71,7 +71,7 @@ ViewStep::setModuleInstanceKey( const QString& instanceKey )
void
ViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
Q_UNUSED( configurationMap );
Q_UNUSED( configurationMap )
}

View File

@ -43,7 +43,7 @@ FixedAspectRatioLabel::setPixmap( const QPixmap& pixmap )
void
FixedAspectRatioLabel::resizeEvent( QResizeEvent* event )
{
Q_UNUSED( event );
Q_UNUSED( event )
QLabel::setPixmap( m_pixmap.scaled(
contentsRect().size(),
Qt::KeepAspectRatio,

View File

@ -21,5 +21,5 @@ if( ECM_FOUND AND BUILD_TESTING )
Qt5::Core
Qt5::Test
)
set_target_properties( contextualprocesstest PROPERTIES AUTOMOC TRUE )
calamares_automoc( contextualprocesstest )
endif()

View File

@ -22,8 +22,6 @@
#include "utils/CommandList.h"
#include "utils/YamlUtils.h"
#include <yaml-cpp/yaml.h>
#include <QtTest/QtTest>
#include <QFileInfo>

View File

@ -125,7 +125,7 @@ FinishedPage::focusInEvent( QFocusEvent* e )
void
FinishedPage::onInstallationFailed( const QString& message, const QString& details )
{
Q_UNUSED( details );
Q_UNUSED( details )
if ( Calamares::Settings::instance()->isSetupMode() )
ui->mainText->setText( tr( "<h1>Setup Failed</h1><br/>"
"%1 has not been set up on your computer.<br/>"

View File

@ -148,8 +148,8 @@ FinishedViewStep::jobs() const
void
FinishedViewStep::onInstallationFailed( const QString& message, const QString& details )
{
Q_UNUSED( message );
Q_UNUSED( details );
Q_UNUSED( message )
Q_UNUSED( details )
installFailed = true;
}

View File

@ -25,8 +25,6 @@
#include "utils/Logger.h"
#include "utils/YamlUtils.h"
#include <yaml-cpp/yaml.h>
#include <QtTest/QtTest>
#include <QFileInfo>

View File

@ -32,7 +32,7 @@ KeyboardLayoutModel::KeyboardLayoutModel( QObject* parent )
int
KeyboardLayoutModel::rowCount( const QModelIndex& parent ) const
{
Q_UNUSED( parent );
Q_UNUSED( parent )
return m_layouts.count();
}

View File

@ -436,7 +436,7 @@ void
KeyboardPage::onListLayoutCurrentItemChanged( const QModelIndex& current,
const QModelIndex& previous )
{
Q_UNUSED( previous );
Q_UNUSED( previous )
if ( !current.isValid() )
return;
@ -446,9 +446,9 @@ KeyboardPage::onListLayoutCurrentItemChanged( const QModelIndex& current,
/* Returns stringlist with suitable setxkbmap command-line arguments
* to set the given @p layout and @p variant.
*/
static inline QStringList xkbmap_args( QStringList&& r, const QString& layout, const QString& variant )
static inline QStringList xkbmap_args( const QString& layout, const QString& variant )
{
r << "-layout" << layout;
QStringList r{ "-layout", layout };
if ( !variant.isEmpty() )
r << "-variant" << variant;
return r;
@ -457,7 +457,7 @@ static inline QStringList xkbmap_args( QStringList&& r, const QString& layout, c
void
KeyboardPage::onListVariantCurrentItemChanged( QListWidgetItem* current, QListWidgetItem* previous )
{
Q_UNUSED( previous );
Q_UNUSED( previous )
QPersistentModelIndex layoutIndex = ui->listLayout->currentIndex();
LayoutItem* variantItem = dynamic_cast< LayoutItem* >( current );
@ -483,7 +483,7 @@ KeyboardPage::onListVariantCurrentItemChanged( QListWidgetItem* current, QListWi
connect( &m_setxkbmapTimer, &QTimer::timeout,
this, [=]
{
QProcess::execute( "setxkbmap", xkbmap_args( QStringList(), layout, variant ) );
QProcess::execute( "setxkbmap", xkbmap_args( layout, variant ) );
cDebug() << "xkbmap selection changed to: " << layout << '-' << variant;
m_setxkbmapTimer.disconnect( this );
} );

View File

@ -87,8 +87,7 @@ LicensePage::LicensePage(QWidget *parent)
CALAMARES_RETRANSLATE(
ui->acceptCheckBox->setText( tr( "I accept the terms and conditions above." ) );
);
)
}

View File

@ -54,7 +54,7 @@ if( ECM_FOUND AND BUILD_TESTING )
${geoip_libs}
${YAMLCPP_LIBRARY}
)
set_target_properties( geoiptest PROPERTIES AUTOMOC TRUE )
calamares_automoc( geoiptest )
ecm_add_test(
Tests.cpp
@ -65,10 +65,11 @@ if( ECM_FOUND AND BUILD_TESTING )
calamares
Qt5::Test
)
set_target_properties( localetest PROPERTIES AUTOMOC TRUE )
calamares_automoc( localetest )
endif()
if( BUILD_TESTING )
add_executable( test_geoip test_geoip.cpp ${geoip_src} )
target_link_libraries( test_geoip calamaresui Qt5::Network ${geoip_libs} ${YAMLCPP_LIBRARY} )
calamares_automoc( test_geoip )
endif()

View File

@ -25,8 +25,6 @@
#include <QByteArray>
#include <yaml-cpp/yaml.h>
GeoIPJSON::GeoIPJSON(const QString& attribute)
: GeoIP( attribute.isEmpty() ? QStringLiteral( "time_zone" ) : attribute )
{

View File

@ -101,7 +101,7 @@ LocalePage::LocalePage( QWidget* parent )
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
[this]( int currentIndex )
{
Q_UNUSED( currentIndex );
Q_UNUSED( currentIndex )
QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations();
if ( !regions.contains( m_regionCombo->currentData().toString() ) )
return;

View File

@ -42,8 +42,6 @@
#include <QNetworkReply>
#include <QtConcurrent/QtConcurrentRun>
#include <yaml-cpp/yaml.h>
CALAMARES_PLUGIN_FACTORY_DEFINITION( LocaleViewStepFactory, registerPlugin<LocaleViewStep>(); )

View File

@ -36,8 +36,6 @@
#include <QHeaderView>
#include <yaml-cpp/yaml.h>
using CalamaresUtils::yamlToVariant;
NetInstallPage::NetInstallPage( QWidget* parent )

View File

@ -127,7 +127,7 @@ bool
PackageModel::setHeaderData( int section, Qt::Orientation orientation,
const QVariant& value, int role )
{
Q_UNUSED( role );
Q_UNUSED( role )
if ( orientation == Qt::Horizontal )
{

View File

@ -27,7 +27,10 @@
#include <QObject>
#include <QString>
#include <yaml-cpp/yaml.h>
namespace YAML
{
class Node;
}
class PackageModel : public QAbstractItemModel
{

View File

@ -540,7 +540,7 @@ void
ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current,
const QModelIndex& previous )
{
Q_UNUSED( previous );
Q_UNUSED( previous )
if ( !current.isValid() )
return;
@ -718,7 +718,7 @@ void
ChoicePage::onPartitionToReplaceSelected( const QModelIndex& current,
const QModelIndex& previous )
{
Q_UNUSED( previous );
Q_UNUSED( previous )
if ( !current.isValid() )
return;

View File

@ -100,7 +100,7 @@ PartitionLabelsView::sizeHint() const
void
PartitionLabelsView::paintEvent( QPaintEvent* event )
{
Q_UNUSED( event );
Q_UNUSED( event )
QPainter painter( viewport() );
painter.fillRect( rect(), palette().window() );
@ -478,7 +478,7 @@ PartitionLabelsView::visualRect( const QModelIndex& idx ) const
QRegion
PartitionLabelsView::visualRegionForSelection( const QItemSelection& selection ) const
{
Q_UNUSED( selection );
Q_UNUSED( selection )
return QRegion();
}
@ -543,8 +543,8 @@ PartitionLabelsView::setExtendedPartitionHidden( bool hidden )
QModelIndex
PartitionLabelsView::moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers )
{
Q_UNUSED( cursorAction );
Q_UNUSED( modifiers );
Q_UNUSED( cursorAction )
Q_UNUSED( modifiers )
return QModelIndex();
}
@ -553,7 +553,7 @@ PartitionLabelsView::moveCursor( CursorAction cursorAction, Qt::KeyboardModifier
bool
PartitionLabelsView::isIndexHidden( const QModelIndex& index ) const
{
Q_UNUSED( index );
Q_UNUSED( index )
return false;
}
@ -598,7 +598,7 @@ PartitionLabelsView::mouseMoveEvent( QMouseEvent* event )
void
PartitionLabelsView::leaveEvent( QEvent* event )
{
Q_UNUSED( event );
Q_UNUSED( event )
QGuiApplication::restoreOverrideCursor();
if ( m_hoveredIndex.isValid() )

View File

@ -286,7 +286,7 @@ PartitionSplitterWidget::minimumSizeHint() const
void
PartitionSplitterWidget::paintEvent( QPaintEvent* event )
{
Q_UNUSED( event );
Q_UNUSED( event )
QPainter painter( this );
painter.fillRect( rect(), palette().window() );
@ -401,7 +401,7 @@ PartitionSplitterWidget::mouseMoveEvent( QMouseEvent* event )
void
PartitionSplitterWidget::mouseReleaseEvent( QMouseEvent* event )
{
Q_UNUSED( event );
Q_UNUSED( event )
m_resizing = false;
}

View File

@ -20,5 +20,5 @@ if( ECM_FOUND AND BUILD_TESTING )
Qt5::Core
Qt5::Test
)
set_target_properties( shellprocesstest PROPERTIES AUTOMOC TRUE )
calamares_automoc( shellprocesstest )
endif()

View File

@ -26,8 +26,6 @@
#include "utils/Logger.h"
#include "utils/YamlUtils.h"
#include <yaml-cpp/yaml.h>
#include <QtTest/QtTest>
#include <QFileInfo>

View File

@ -41,7 +41,7 @@ SummaryPage::SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent )
, m_contentWidget( nullptr )
, m_scrollArea( new QScrollArea( this ) )
{
Q_UNUSED( parent );
Q_UNUSED( parent )
Q_ASSERT( m_thisViewStep );
QVBoxLayout* layout = new QVBoxLayout( this );
layout->setContentsMargins( 0, 0, 0, 0 );

View File

@ -21,13 +21,13 @@
* shipped with each module for correctness -- well, for parseability.
*/
#include "utils/YamlUtils.h"
#include <unistd.h>
#include <stdlib.h>
#include <iostream>
#include <yaml-cpp/yaml.h>
#include <QFile>
#include <QByteArray>

View File

@ -51,5 +51,5 @@ if( ECM_FOUND AND BUILD_TESTING )
Qt5::Test
${CRYPT_LIBRARIES}
)
set_target_properties( passwordtest PROPERTIES AUTOMOC TRUE )
calamares_automoc( passwordtest )
endif()

View File

@ -278,7 +278,7 @@ bool
GeneralRequirements::checkEnoughStorage( qint64 requiredSpace )
{
#ifdef WITHOUT_LIBPARTED
Q_UNUSED( requiredSpace );
Q_UNUSED( requiredSpace )
cWarning() << "GeneralRequirements is configured without libparted.";
return false;
#else