Verified Commit cd02f4f8 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Clazy fixes

parent 4aecb866
......@@ -253,7 +253,7 @@ set_default_db_backend(${DATABASE_BACKEND})
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER MATCHES "icc" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wundef -Wcast-align -Wchar-subscripts -Wall -Wextra -Wpointer-arith -Wformat-security -fno-common -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wundef -Wcast-align -Wchar-subscripts -Wall -Wextra -Wpointer-arith -Wformat-security -fno-common -pedantic -Wno-deprecated-copy")
set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline" CACHE STRING "Flags used by the C++ compiler during debugfull builds." FORCE)
set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline" CACHE STRING "Flags used by the C compiler during debugfull builds." FORCE)
......
......@@ -20,47 +20,49 @@
#include "instance_p.h"
#include <QString>
#include <QGlobalStatic>
using namespace Akonadi;
namespace
{
static QString sIdentifier;
Q_GLOBAL_STATIC(QString, sIdentifier);
static void loadIdentifier()
{
sIdentifier = QString::fromUtf8(qgetenv("AKONADI_INSTANCE"));
if (sIdentifier.isNull()) {
*sIdentifier = QString::fromUtf8(qgetenv("AKONADI_INSTANCE"));
if (sIdentifier->isNull()) {
// QString is null by default, which means it wasn't initialized
// yet. Set it to empty when it is initialized
sIdentifier = QStringLiteral("");
*sIdentifier = QStringLiteral(""); // clazy:exclude=empty-qstringliteral
}
}
}
bool Instance::hasIdentifier()
{
if (::sIdentifier.isNull()) {
if (::sIdentifier->isNull()) {
::loadIdentifier();
}
return !sIdentifier.isEmpty();
return !sIdentifier->isEmpty();
}
void Instance::setIdentifier(const QString &identifier)
{
if (identifier.isNull()) {
qunsetenv("AKONADI_INSTANCE");
::sIdentifier = QStringLiteral("");
*::sIdentifier = QStringLiteral(""); // clazy:exclude=empty-qstringliteral
} else {
::sIdentifier = identifier;
*::sIdentifier = identifier;
qputenv("AKONADI_INSTANCE", identifier.toUtf8());
}
}
QString Instance::identifier()
{
if (::sIdentifier.isNull()) {
if (::sIdentifier->isNull()) {
::loadIdentifier();
}
return ::sIdentifier;
return *::sIdentifier;
}
......@@ -32,6 +32,8 @@
#include <cassert>
// clazy:excludeall=function-args-by-value
#undef AKONADI_DECLARE_PRIVATE
#define AKONADI_DECLARE_PRIVATE(Class) \
inline Class##Private* Class::d_func() {\
......
......@@ -42,6 +42,9 @@ public:
std::cerr << "ProtocolException thrown:" << what << std::endl;
}
ProtocolException(const ProtocolException &) = delete;
ProtocolException &operator=(const ProtocolException &) = delete;
const char *what() const throw() override {
return mWhat.constData();
}
......
......@@ -34,6 +34,7 @@
#include "tristate_p.h"
#include "scope_p.h"
//clazy:excludeall=function-args-by-value
/**
@file protocol_p.h Shared constants used in the communication protocol between
......
......@@ -60,6 +60,8 @@ void CppGenerator::writeHeaderHeader(DocumentNode const *node)
mHeader << "// This is an auto-generated file.\n"
"// Any changes to this file will be overwritten\n"
"\n"
"// clazy:excludeall=function-args-by-value\n"
"\n"
"namespace Akonadi {\n"
"namespace Protocol {\n"
"\n"
......@@ -88,6 +90,8 @@ void CppGenerator::writeImplHeader(DocumentNode const *node)
mImpl << "// This is an auto-generated file.\n"
"// Any changes to this file will be overwritten\n"
"\n"
"// clazy:excludeall=function-args-by-value\n"
"\n"
"namespace Akonadi {\n"
"namespace Protocol {\n"
"\n"
......
......@@ -31,22 +31,22 @@ namespace {
class Dummy;
static QHash<QByteArray, size_t> typeSizeLookup = {
{ "Scope", sizeof(QSharedDataPointer<Dummy>) },
{ "ScopeContext", sizeof(QSharedDataPointer<Dummy>) },
{ "QSharedPointer", sizeof(QSharedPointer<Dummy>) },
{ "Tristate", sizeof(qint8) },
{ "Akonadi::Protocol::Attributes", sizeof(QMap<int, Dummy>) },
{ "QSet", sizeof(QSet<Dummy>) },
{ "QVector", sizeof(QVector<Dummy>) }
};
// FIXME: This is based on hacks and guesses, does not work for generated types
// and does not consider alignment. It should be good enough (TM) for our needs,
// but it would be nice to make it smarter, for example by looking up type sizes
// from the Node tree and understanding enums and QFlags types.
size_t typeSize(const QString &typeName)
{
static QHash<QByteArray, size_t> typeSizeLookup = {
{ "Scope", sizeof(QSharedDataPointer<Dummy>) },
{ "ScopeContext", sizeof(QSharedDataPointer<Dummy>) },
{ "QSharedPointer", sizeof(QSharedPointer<Dummy>) },
{ "Tristate", sizeof(qint8) },
{ "Akonadi::Protocol::Attributes", sizeof(QMap<int, Dummy>) },
{ "QSet", sizeof(QSet<Dummy>) },
{ "QVector", sizeof(QVector<Dummy>) }
};
QByteArray tn;
// Don't you just loooove hacks?
// TODO: Extract underlying type during XML parsing
......
......@@ -36,8 +36,13 @@ public:
};
Node(NodeType type, Node *parent);
Node(const Node &) = delete;
Node(Node &&) = delete;
virtual ~Node();
Node &operator=(const Node &) = delete;
Node &operator=(Node &&) = delete;
NodeType type() const;
Node *parent() const;
......
......@@ -64,6 +64,8 @@ public:
HRID &operator=(const HRID &other);
HRID &operator=(HRID &&other);
~HRID() = default;
bool isEmpty() const;
bool operator==(const HRID &other) const;
......
......@@ -62,6 +62,7 @@ namespace {
class AkonadiDataStore : public DataStore
{
Q_OBJECT
public:
AkonadiDataStore(AkonadiServer &server):
DataStore(server)
......@@ -470,3 +471,5 @@ QString AkonadiServer::serverPath() const
{
return StandardDirs::saveDir("config");
}
#include "akonadi.moc"
......@@ -92,7 +92,7 @@ protected:
private Q_SLOTS:
void schedulerTimeout();
void startScheduler();
void scheduleCollection(/*sic!*/ Collection collection, bool shouldStartScheduler = true);
void scheduleCollection(/*sic!*/ Akonadi::Server::Collection collection, bool shouldStartScheduler = true);
private:
using ScheduleMap = QMultiMap<TimePoint /*timestamp*/, Collection>;
......
......@@ -50,15 +50,10 @@ public:
{
}
Exception(const Exception &other) throw()
: std::exception(other)
, mWhat(other.what())
{
}
Exception(const Exception &) = delete;
Exception &operator=(const Exception &) = delete;
virtual ~Exception() throw()
{
}
virtual ~Exception() throw() = default;
const char *what() const throw() override {
return mWhat.constData();
......
......@@ -56,7 +56,6 @@ protected:
bool hasChanged(const Collection &collection, const Collection &changed) override;
bool shouldScheduleCollection(const Collection &collection) override;
protected Q_SLOTS:
void collectionExpired(const Collection &collection) override;
private:
......
......@@ -40,10 +40,11 @@ class ResourceManager : public QObject
public:
explicit ResourceManager(Tracer &tracer);
QStringList resourceInstances() const;
public Q_SLOTS:
void addResourceInstance(const QString &name, const QStringList &capabilities);
void removeResourceInstance(const QString &name);
QStringList resourceInstances() const;
private:
Tracer &mTracer;
......
......@@ -96,7 +96,7 @@ private Q_SLOTS:
*
* This method has to be called using QMetaObject::invokeMethod.
*/
void updateSearchImpl(const Collection &collection);
void updateSearchImpl(const Akonadi::Server::Collection &collection);
private:
void init() override;
......
......@@ -43,8 +43,13 @@ class DataStore;
class DataStoreFactory
{
public:
explicit DataStoreFactory() = default;
virtual ~DataStoreFactory() = default;
virtual DataStore *createStore() = 0;
private:
Q_DISABLE_COPY_MOVE(DataStoreFactory)
};
class NotificationCollector;
......
......@@ -123,6 +123,8 @@ protected:
*/
int execute(const QString &cmd, const QStringList &args) const;
private:
Q_DISABLE_COPY(DbConfig);
qint64 mSizeThreshold;
};
......
......@@ -48,7 +48,7 @@ public:
const ItemRetrievalResult &result() const { return m_result; }
Q_SIGNALS:
void requestCompleted(AbstractItemRetrievalJob *job);
void requestCompleted(Akonadi::Server::AbstractItemRetrievalJob *job);
protected:
ItemRetrievalResult m_result;
......
......@@ -49,6 +49,9 @@ public:
virtual ~AbstractItemRetrievalJobFactory() = default;
virtual AbstractItemRetrievalJob *retrievalJob(ItemRetrievalRequest request, QObject *parent) = 0;
private:
Q_DISABLE_COPY_MOVE(AbstractItemRetrievalJobFactory)
};
/** Manages and processes item retrieval requests. */
......@@ -82,7 +85,7 @@ private Q_SLOTS:
void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner);
void processRequest();
void retrievalJobFinished(AbstractItemRetrievalJob *job);
void retrievalJobFinished(Akonadi::Server::AbstractItemRetrievalJob *job);
protected:
std::unique_ptr<AbstractItemRetrievalJobFactory> mJobFactory;
......
......@@ -40,7 +40,7 @@ class ItemRetrievalRequest
public:
struct Id {
explicit Id(uint32_t value): mValue(value) {};
bool operator==(const Id &other) const { return mValue == other.mValue; }
bool operator==(Id other) const { return mValue == other.mValue; }
private:
uint32_t mValue;
Id next() { return Id{++mValue}; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment