From e9077803ae4845311c84a325f878300e5560278c Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> Date: Tue, 9 Jul 2013 12:43:50 -0400 Subject: [PATCH] [ #27019 ] -Wzero-as-null-pointer-constant doesn't work that well after all --- src/CMakeLists.txt | 2 ++ src/abstractcontactbackend.cpp | 2 +- src/abstractcontactbackend.h | 5 ++++- src/account.h | 5 ++++- src/accountlist.h | 5 ++++- src/audiocodecmodel.h | 5 ++++- src/call.cpp | 2 +- src/call.h | 5 ++++- src/callmodel.cpp | 6 +++--- src/callmodel.h | 5 ++++- src/contact.h | 5 ++++- src/contactproxymodel.cpp | 2 +- src/contactproxymodel.h | 5 ++++- src/credentialmodel.h | 3 +++ src/historymodel.cpp | 2 +- src/historymodel.h | 5 ++++- src/instantmessagingmodel.cpp | 2 +- src/instantmessagingmodel.h | 6 ++++++ src/typedefs.h | 14 +++++++------- src/videocodecmodel.h | 3 +++ src/videomodel.h | 5 ++++- src/videorenderer.cpp | 10 ++++++++-- src/videorenderer.h | 3 +++ 23 files changed, 80 insertions(+), 27 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 125be1d4..ed00a333 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -179,6 +179,7 @@ ELSE() ) ENDIF(${ENABLE_QT5} MATCHES true) +# ADD_DEFINITIONS("-w") IF(${ENABLE_QT5} MATCHES true) QT5_WRAP_CPP(LIB_HEADER_MOC ${qtsflphone_LIB_HDRS}) ELSE() @@ -186,6 +187,7 @@ ELSE() ENDIF(${ENABLE_QT5} MATCHES true) add_library( qtsflphone SHARED ${qtsflphone_LIB_SRCS} ${LIB_HEADER_MOC} ) +# REMOVE_DEFINITIONS("-w") IF(${ENABLE_QT5} MATCHES true) QT5_USE_MODULES(qtsflphone Core DBus) diff --git a/src/abstractcontactbackend.cpp b/src/abstractcontactbackend.cpp index c473b4f6..81aa0ea9 100644 --- a/src/abstractcontactbackend.cpp +++ b/src/abstractcontactbackend.cpp @@ -160,7 +160,7 @@ int AbstractContactBackend::rowCount( const QModelIndex& par ) const Qt::ItemFlags AbstractContactBackend::flags( const QModelIndex& idx ) const { if (!idx.isValid()) - return 0; + return Qt::NoItemFlags; return Qt::ItemIsEnabled | ((idx.parent().isValid())?Qt::ItemIsSelectable:Qt::ItemIsEnabled); } diff --git a/src/abstractcontactbackend.h b/src/abstractcontactbackend.h index 3955f0db..86c46769 100644 --- a/src/abstractcontactbackend.h +++ b/src/abstractcontactbackend.h @@ -38,7 +38,10 @@ typedef QList<Contact*> ContactList; ///AbstractContactBackend: Allow different way to handle contact without poluting the library class LIB_EXPORT AbstractContactBackend : public QAbstractItemModel { - IGNORE_NULL(Q_OBJECT) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" + Q_OBJECT + #pragma GCC diagnostic pop public: enum Role { Organization = 100, diff --git a/src/account.h b/src/account.h index ae8e190d..b5d07f84 100644 --- a/src/account.h +++ b/src/account.h @@ -67,7 +67,10 @@ enum DtmfType { ///Account: a daemon account (SIP or AIX) class LIB_EXPORT Account : public QObject { - IGNORE_NULL(Q_OBJECT) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" + Q_OBJECT + #pragma GCC diagnostic pop public: ~Account(); diff --git a/src/accountlist.h b/src/accountlist.h index 3165782f..c951d378 100644 --- a/src/accountlist.h +++ b/src/accountlist.h @@ -32,7 +32,10 @@ class AccountListColorVisitor; ///AccountList: List of all daemon accounts class LIB_EXPORT AccountList : public QAbstractListModel { - IGNORE_NULL(Q_OBJECT) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" + Q_OBJECT + #pragma GCC diagnostic pop public: friend class Account; diff --git a/src/audiocodecmodel.h b/src/audiocodecmodel.h index 8ce996b9..c3a8b758 100644 --- a/src/audiocodecmodel.h +++ b/src/audiocodecmodel.h @@ -24,7 +24,10 @@ ///AudioCodecModel: A model for account audio codec class LIB_EXPORT AudioCodecModel : public QAbstractListModel { - IGNORE_NULL(Q_OBJECT) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" + Q_OBJECT + #pragma GCC diagnostic pop public: //friend class Account; //Roles diff --git a/src/call.cpp b/src/call.cpp index 6acd58b3..afab0b1b 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -168,7 +168,7 @@ Call::Call(Call::State startState, const QString& callId, QString peerName, QStr m_pContact(nullptr),m_pImModel(nullptr),m_LastContactCheck(-1),m_pTimer(nullptr),m_Recording(false),m_Account(account), m_PeerName(peerName),m_PeerPhoneNumber(peerNumber),m_CallId(callId),m_CurrentState(startState) { - qRegisterMetaType<Call*>(); +// qRegisterMetaType<Call*>(); changeCurrentState(startState); CallManagerInterface& callManager = DBus::CallManager::instance(); diff --git a/src/call.h b/src/call.h index 0950467e..3756b7fb 100644 --- a/src/call.h +++ b/src/call.h @@ -97,7 +97,10 @@ private: **/ class LIB_EXPORT Call : public QObject, public HistoryTreeBackend { - IGNORE_NULL(Q_OBJECT) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" + Q_OBJECT + #pragma GCC diagnostic pop public: //Enum enum Role { diff --git a/src/callmodel.cpp b/src/callmodel.cpp index d76723b8..eff0e367 100644 --- a/src/callmodel.cpp +++ b/src/callmodel.cpp @@ -96,7 +96,7 @@ CallModel::CallModel() : QAbstractItemModel(QCoreApplication::instance()) dbusInit = true; foreach(Call* call,HistoryModel::getHistory()){ - addCall(call,0); + addCall(call,nullptr); } } static bool m_sInstanceInit = false; @@ -586,7 +586,7 @@ int CallModel::rowCount( const QModelIndex& parentIdx ) const Qt::ItemFlags CallModel::flags( const QModelIndex& idx ) const { if (!idx.isValid()) - return 0; + return Qt::NoItemFlags; return Qt::ItemIsEnabled|Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | ((!idx.data(Call::Role::IsConference).toBool())?(Qt::ItemIsDropEnabled):Qt::ItemIsEnabled) @@ -934,7 +934,7 @@ void CallModel::slotCallChanged(Call* call) ///Add call slot void CallModel::slotAddPrivateCall(Call* call) { - addCall(call,0); + addCall(call,nullptr); } ///Notice views that a dtmf have been played diff --git a/src/callmodel.h b/src/callmodel.h index 360ee194..dc65f68d 100644 --- a/src/callmodel.h +++ b/src/callmodel.h @@ -35,7 +35,10 @@ typedef QList<Call*> CallList; ///CallModel: Central model/frontend to deal with sflphoned class LIB_EXPORT CallModel : public QAbstractItemModel { - IGNORE_NULL(Q_OBJECT) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" + Q_OBJECT + #pragma GCC diagnostic pop public: //Constructors, initializer and destructors virtual ~CallModel( ); diff --git a/src/contact.h b/src/contact.h index e2df9fb1..9d504b99 100644 --- a/src/contact.h +++ b/src/contact.h @@ -56,7 +56,10 @@ private: ///Contact: Abstract version of a contact class LIB_EXPORT Contact : public QObject, public ContactTreeBackend { - IGNORE_NULL(Q_OBJECT) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" + Q_OBJECT + #pragma GCC diagnostic pop public: ///PhoneNumber: represent a phone number class PhoneNumber { diff --git a/src/contactproxymodel.cpp b/src/contactproxymodel.cpp index 7993cf4e..02f99bf0 100644 --- a/src/contactproxymodel.cpp +++ b/src/contactproxymodel.cpp @@ -223,7 +223,7 @@ int ContactProxyModel::rowCount( const QModelIndex& parent ) const Qt::ItemFlags ContactProxyModel::flags( const QModelIndex& index ) const { if (!index.isValid()) - return 0; + return Qt::NoItemFlags; return Qt::ItemIsEnabled | Qt::ItemIsSelectable | (index.parent().isValid()?Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled:Qt::ItemIsEnabled); } diff --git a/src/contactproxymodel.h b/src/contactproxymodel.h index 55dba0b9..e59e2353 100644 --- a/src/contactproxymodel.h +++ b/src/contactproxymodel.h @@ -29,7 +29,10 @@ class AbstractContactBackend; class LIB_EXPORT ContactProxyModel : public QAbstractItemModel { - IGNORE_NULL(Q_OBJECT) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" + Q_OBJECT + #pragma GCC diagnostic pop public: friend class AbstractContactBackend; explicit ContactProxyModel(AbstractContactBackend* parent,int role = Qt::DisplayRole, bool showAll = false); diff --git a/src/credentialmodel.h b/src/credentialmodel.h index 279a7248..3b34d4f5 100644 --- a/src/credentialmodel.h +++ b/src/credentialmodel.h @@ -25,7 +25,10 @@ ///CredentialModel: A model for account credentials class LIB_EXPORT CredentialModel : public QAbstractListModel { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" Q_OBJECT + #pragma GCC diagnostic pop public: //Roles enum Role { diff --git a/src/historymodel.cpp b/src/historymodel.cpp index 5d971dae..1e0a7858 100644 --- a/src/historymodel.cpp +++ b/src/historymodel.cpp @@ -348,7 +348,7 @@ int HistoryModel::rowCount( const QModelIndex& parentIdx ) const Qt::ItemFlags HistoryModel::flags( const QModelIndex& idx ) const { if (!idx.isValid()) - return 0; + return Qt::NoItemFlags; return Qt::ItemIsEnabled | Qt::ItemIsSelectable | (idx.parent().isValid()?Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled:Qt::ItemIsEnabled); } diff --git a/src/historymodel.h b/src/historymodel.h index fb175e16..2f92bb22 100644 --- a/src/historymodel.h +++ b/src/historymodel.h @@ -34,7 +34,10 @@ typedef QList<Call*> CallList; ///HistoryModel: History call manager class LIB_EXPORT HistoryModel : public QAbstractItemModel { - IGNORE_NULL(Q_OBJECT) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" + Q_OBJECT + #pragma GCC diagnostic pop public: enum class HistoryConst : int { Today = 0 , diff --git a/src/instantmessagingmodel.cpp b/src/instantmessagingmodel.cpp index a40bd8ce..393b71ec 100644 --- a/src/instantmessagingmodel.cpp +++ b/src/instantmessagingmodel.cpp @@ -40,7 +40,7 @@ void InstantMessagingModelManager::init(CallModel* model) { } ///Constructor -InstantMessagingModelManager::InstantMessagingModelManager() : QObject(0) +InstantMessagingModelManager::InstantMessagingModelManager() : QObject(nullptr) { CallManagerInterface& callManager = DBus::CallManager::instance(); connect(&callManager, SIGNAL(incomingMessage(QString,QString,QString)), this, SLOT(newMessage(QString,QString,QString))); diff --git a/src/instantmessagingmodel.h b/src/instantmessagingmodel.h index 20976db2..63e90401 100644 --- a/src/instantmessagingmodel.h +++ b/src/instantmessagingmodel.h @@ -39,7 +39,10 @@ class InstantMessagingModel; ///Manager for all IM conversations class LIB_EXPORT InstantMessagingModelManager : public QObject { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" Q_OBJECT + #pragma GCC diagnostic pop public: //Singleton @@ -72,7 +75,10 @@ Q_SIGNALS: ///Qt model for the Instant Messaging (IM) features class LIB_EXPORT InstantMessagingModel : public QAbstractListModel { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" Q_OBJECT + #pragma GCC diagnostic pop friend class InstantMessagingModelManager; friend class Call; public: diff --git a/src/typedefs.h b/src/typedefs.h index f4910051..30364bcf 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -70,13 +70,13 @@ struct TypedStateMachine #define nullptr 0 #endif -#ifdef ENABLE_IGNORE_NULL -#define IGNORE_NULL(content) \ -_Pragma(STRINGIFY(GCC diagnostic push))\ - _Pragma(STRINGIFY(GCC diagnostic ignored "-Wzero-as-null-pointer-constant")\ - content\ - _Pragma(STRINGIFY(GCC diagnostic pop) +//Doesn't work +#if ((__GNUC_MINOR__ > 8) || (__GNUC_MINOR__ == 8)) + #define STRINGIFY(x) #x + #define IGNORE_NULL(content)\ + _Pragma(STRINGIFY(GCC diagnostic ignored "-Wzero-as-null-pointer-constant")) \ + content #else -#define IGNORE_NULL(content) content + #define IGNORE_NULL(content) content #endif //ENABLE_IGNORE_NULL #endif diff --git a/src/videocodecmodel.h b/src/videocodecmodel.h index f343ad52..2a943953 100644 --- a/src/videocodecmodel.h +++ b/src/videocodecmodel.h @@ -33,7 +33,10 @@ typedef QHash<QString,VideoCodec*> CodecHash; ///Abstract model for managing account video codec list class LIB_EXPORT VideoCodecModel : public QAbstractListModel { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" Q_OBJECT + #pragma GCC diagnostic pop friend class Account; public: //Roles diff --git a/src/videomodel.h b/src/videomodel.h index 4e0e1877..9c4b2006 100644 --- a/src/videomodel.h +++ b/src/videomodel.h @@ -32,7 +32,10 @@ struct SHMHeader; ///VideoModel: Video event dispatcher class LIB_EXPORT VideoModel : public QObject { - IGNORE_NULL(Q_OBJECT) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" + Q_OBJECT + #pragma GCC diagnostic pop public: //Singleton static VideoModel* instance(); diff --git a/src/videorenderer.cpp b/src/videorenderer.cpp index 9363189d..10a45221 100644 --- a/src/videorenderer.cpp +++ b/src/videorenderer.cpp @@ -48,7 +48,7 @@ struct SHMHeader { }; ///Constructor -VideoRenderer::VideoRenderer(QString shmPath, Resolution res): QObject(0), +VideoRenderer::VideoRenderer(QString shmPath, Resolution res): QObject(nullptr), m_Width(0), m_Height(0), m_ShmPath(QString()), fd(-1), m_pShmArea((SHMHeader*)MAP_FAILED), m_ShmAreaLen(0), m_BufferGen(0), m_isRendering(false),m_pTimer(nullptr),m_Res(res) @@ -144,7 +144,10 @@ bool VideoRenderer::startShm() return false; } m_ShmAreaLen = sizeof(SHMHeader); + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" m_pShmArea = (SHMHeader*) mmap(NULL, m_ShmAreaLen, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + #pragma GCC diagnostic pop if (m_pShmArea == MAP_FAILED) { qDebug() << "Could not map shm area, mmap failed"; return false; @@ -177,11 +180,14 @@ bool VideoRenderer::resizeShm() return false; } + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" m_pShmArea = (SHMHeader*) mmap(NULL, new_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + #pragma GCC diagnostic pop m_ShmAreaLen = new_size; if (!m_pShmArea) { - m_pShmArea = 0; + m_pShmArea = nullptr; qDebug() << "Could not remap shared area"; return false; } diff --git a/src/videorenderer.h b/src/videorenderer.h index b151d37f..cb109f34 100644 --- a/src/videorenderer.h +++ b/src/videorenderer.h @@ -31,7 +31,10 @@ struct SHMHeader; ///Manage shared memory and convert it to QByteArray class LIB_EXPORT VideoRenderer : public QObject { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" Q_OBJECT + #pragma GCC diagnostic pop public: //Constructor -- GitLab