From da6778934d6af101da5753321a061bd1e73074b8 Mon Sep 17 00:00:00 2001 From: Phenom Date: Mon, 8 Oct 2018 18:56:17 +0200 Subject: [PATCH 1/4] Fix Warnings in rsloginhandler.cc /libretroshare/src/rsserver/rsloginhandler.cc:122:2: warning: missing initializer for member 'SecretSchema::reserved' [-Wmissing-field- initializers] /libretroshare/src/rsserver/rsloginhandler.cc:122:2: warning: missing initializer for member 'SecretSchema::reserved1' [-Wmissing-field- initializers] /libretroshare/src/rsserver/rsloginhandler.cc:122:2: warning: missing initializer for member 'SecretSchema::reserved2' [-Wmissing-field- initializers] /libretroshare/src/rsserver/rsloginhandler.cc:122:2: warning: missing initializer for member 'SecretSchema::reserved3' [-Wmissing-field- initializers] /libretroshare/src/rsserver/rsloginhandler.cc:122:2: warning: missing initializer for member 'SecretSchema::reserved4' [-Wmissing-field- initializers] /libretroshare/src/rsserver/rsloginhandler.cc:122:2: warning: missing initializer for member 'SecretSchema::reserved5' [-Wmissing-field- initializers] /libretroshare/src/rsserver/rsloginhandler.cc:122:2: warning: missing initializer for member 'SecretSchema::reserved6' [-Wmissing-field- initializers] /libretroshare/src/rsserver/rsloginhandler.cc:122:2: warning: missing initializer for member 'SecretSchema::reserved7' [-Wmissing-field- initializers] /libretroshare/src/rsserver/rsloginhandler.cc:34: warning: zero as null pointer constant /libretroshare/src/rsserver/rsloginhandler.cc:55: warning: zero as null pointer constant /libretroshare/src/rsserver/rsloginhandler.cc:120: warning: use of old- style cast /libretroshare/src/rsserver/rsloginhandler.cc:122: warning: missing field 'reserved' initializer /libretroshare/src/rsserver/rsloginhandler.cc:243: warning: zero as null pointer constant /libretroshare/src/rsserver/rsloginhandler.cc:244: warning: zero as null pointer constant /libretroshare/src/rsserver/rsloginhandler.cc:248: warning: zero as null pointer constant /libretroshare/src/rsserver/rsloginhandler.cc:254: warning: zero as null pointer constant /libretroshare/src/rsserver/rsloginhandler.cc:443: warning: 'return' will never be executed /libretroshare/src/rsserver/rsloginhandler.cc:270: warning: 'return' will never be executed /libretroshare/src/rsserver/rsloginhandler.cc:468: warning: zero as null pointer constant /libretroshare/src/rsserver/rsloginhandler.cc:470: warning: use of old- style cast /libretroshare/src/rsserver/rsloginhandler.cc:470: warning: cast from 'const char *' to 'char *' drops const qualifier /libretroshare/src/rsserver/rsloginhandler.cc:471: warning: use of old- style cast /libretroshare/src/rsserver/rsloginhandler.cc:471: warning: cast from 'const char *' to 'char *' drops const qualifier /libretroshare/src/rsserver/rsloginhandler.cc:472: warning: zero as null pointer constant /libretroshare/src/rsserver/rsloginhandler.cc:476: warning: zero as null pointer constant /libretroshare/src/rsserver/rsloginhandler.cc:630: warning: 'return' will never be executed /libretroshare/src/rsserver/rsloginhandler.cc:650: warning: zero as null pointer constant /libretroshare/src/rsserver/rsloginhandler.cc:651: warning: zero as null pointer constant /libretroshare/src/rsserver/rsloginhandler.cc:655: warning: zero as null pointer constant --- libretroshare/src/rsserver/rsloginhandler.cc | 39 ++++++++++---------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/libretroshare/src/rsserver/rsloginhandler.cc b/libretroshare/src/rsserver/rsloginhandler.cc index f94c7115b..263d62ce3 100644 --- a/libretroshare/src/rsserver/rsloginhandler.cc +++ b/libretroshare/src/rsserver/rsloginhandler.cc @@ -31,7 +31,7 @@ bool RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile( FILE *sslPassphraseFile = RsDirUtil::rs_fopen( getSSLPasswdFileName(ssl_id).c_str(), "r"); - if(sslPassphraseFile != NULL) // already have it. + if(sslPassphraseFile) // already have it. { fclose(sslPassphraseFile); return true ; @@ -52,7 +52,7 @@ bool RsLoginHandler::getSSLPasswdFromGPGFile(const RsPeerId& ssl_id,std::string& FILE *sslPassphraseFile = RsDirUtil::rs_fopen( getSSLPasswdFileName(ssl_id).c_str(), "r"); - if (sslPassphraseFile == NULL) + if (!sslPassphraseFile) { std::cerr << "No password provided, and no sslPassphraseFile : " << getSSLPasswdFileName(ssl_id).c_str() << std::endl; @@ -117,8 +117,9 @@ const SecretSchema *libsecret_get_schema(void) "org.Retroshare.Password", SECRET_SCHEMA_NONE, { { "RetroShare SSL Id", SECRET_SCHEMA_ATTRIBUTE_STRING }, - { "NULL", (SecretSchemaAttributeType)0 }, - } + { "NULL", static_cast(0) }, + }, + 0,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr }; return &the_schema; } @@ -240,18 +241,18 @@ bool RsLoginHandler::tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd std::cerr << "Using attribute: " << ssl_id << std::endl; #endif - GError *error = NULL; - gchar *password = secret_password_lookup_sync (libsecret_get_schema(), NULL, &error, + GError *error = nullptr; + gchar *password = secret_password_lookup_sync (libsecret_get_schema(), nullptr, &error, "RetroShare SSL Id", ssl_id.toStdString().c_str(), NULL); - if (error != NULL) { + if (error) { g_error_free (error); #ifdef DEBUG_RSLOGINHANDLER std::cerr << "Could not get passwd using libsecret: error" << std::endl; #endif return false; - } else if (password == NULL) { + } else if (!password) { /* password will be null, if no matching password found */ #ifdef DEBUG_RSLOGINHANDLER std::cerr << "Could not get passwd using libsecret: not found" << std::endl; @@ -267,7 +268,7 @@ bool RsLoginHandler::tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd #ifdef DEBUG_RSLOGINHANDLER std::cerr << "Could not get passwd from gnome keyring: unknown" << std::endl; #endif - return false; + //return false; //Never used returned before #else /******************** OSX KeyChain stuff *****************************/ #ifdef __APPLE__ @@ -440,7 +441,7 @@ bool RsLoginHandler::tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd #endif /******************************** WINDOWS/UNIX SPECIFIC PART ******************/ - return false; + //return false; //never used } @@ -465,15 +466,15 @@ bool RsLoginHandler::enableAutoLogin(const RsPeerId& ssl_id,const std::string& s #elif defined(HAS_LIBSECRET) // do synchronous store - GError *error = NULL; + GError *error = nullptr; secret_password_store_sync (libsecret_get_schema(), SECRET_COLLECTION_DEFAULT, - (gchar*)("RetroShare password for SSL Id " + ssl_id.toStdString()).c_str(), - (gchar*)ssl_passwd.c_str(), - NULL, &error, + static_cast(("RetroShare password for SSL Id " + ssl_id.toStdString()).c_str()), + static_cast(ssl_passwd.c_str()), + nullptr, &error, "RetroShare SSL Id", ssl_id.toStdString().c_str(), NULL); - if (error != NULL) { + if (error) { g_error_free (error); std::cerr << "Could not store passwd using libsecret" << std::endl; return false; @@ -624,10 +625,10 @@ bool RsLoginHandler::enableAutoLogin(const RsPeerId& ssl_id,const std::string& s free(pbDataInput); free(pbDataEnt); LocalFree(DataOut.pbData); + return false; #endif /******************************** WINDOWS/UNIX SPECIFIC PART ******************/ - return false; #endif } @@ -647,12 +648,12 @@ bool RsLoginHandler::clearAutoLogin(const RsPeerId& ssl_id) #elif defined(HAS_LIBSECRET) // do synchronous clear - GError *error = NULL; - gboolean removed = secret_password_clear_sync (libsecret_get_schema(), NULL, &error, + GError *error = nullptr; + gboolean removed = secret_password_clear_sync (libsecret_get_schema(), nullptr, &error, "RetroShare SSL Id", ssl_id.toStdString().c_str(), NULL); - if (error != NULL) { + if (error) { g_error_free (error); std::cerr << "Could not clearpasswd for SSLID " << ssl_id << " using libsecret: error" << std::endl; return false ; From a30e2c34000684cd360afbf03c37c026a7ff543e Mon Sep 17 00:00:00 2001 From: Phenom Date: Mon, 8 Oct 2018 19:27:48 +0200 Subject: [PATCH 2/4] Fix Warnings in MouseEventFilter.cpp /retroshare-gui/src/util/MouseEventFilter.cpp:56: warning: catching polymorphic type 'class std::bad_cast' by value [-Wcatch-value=] /retroshare-gui/src/util/MouseEventFilter.cpp:77: warning: catching polymorphic type 'class std::bad_cast' by value [-Wcatch-value=] --- retroshare-gui/src/util/MouseEventFilter.cpp | 174 +++++++++---------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/retroshare-gui/src/util/MouseEventFilter.cpp b/retroshare-gui/src/util/MouseEventFilter.cpp index 2220dbefa..10240cbfd 100644 --- a/retroshare-gui/src/util/MouseEventFilter.cpp +++ b/retroshare-gui/src/util/MouseEventFilter.cpp @@ -17,90 +17,90 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - ****************************************************************/ - -#include - -#include -#include - -#include -#include - -MouseMoveEventFilter::MouseMoveEventFilter(QObject * receiver, const char * member) - : EventFilter(receiver, member) { -} - -bool MouseMoveEventFilter::eventFilter(QObject * watched, QEvent * event) { - if (event->type() == QEvent::MouseMove) { - filter(event); - return false; - } - return EventFilter::eventFilter(watched, event); -} - -MousePressEventFilter::MousePressEventFilter(QObject * receiver, const char * member, Qt::MouseButton button) - : EventFilter(receiver, member), - _button(button) { -} - -bool MousePressEventFilter::eventFilter(QObject * watched, QEvent * event) { - if (event->type() == QEvent::MouseButtonPress) { - try { - QMouseEvent * mouseEvent = dynamic_cast(event); - - if ((_button == Qt::NoButton) || (mouseEvent->button() == _button)) { - filter(event); - return false; - } - } catch (std::bad_cast) { - //LOG_FATAL("exception when casting a QEvent to a QMouseEvent"); - } - } - return EventFilter::eventFilter(watched, event); -} - -MouseReleaseEventFilter::MouseReleaseEventFilter(QObject * receiver, const char * member, Qt::MouseButton button) - : EventFilter(receiver, member), - _button(button) { -} - -bool MouseReleaseEventFilter::eventFilter(QObject * watched, QEvent * event) { - if (event->type() == QEvent::MouseButtonRelease) { - try { - QMouseEvent * mouseEvent = dynamic_cast(event); - - if ((_button == Qt::NoButton) || (mouseEvent->button() == _button)) { - filter(event); - return false; - } - } catch (std::bad_cast) { - //LOG_FATAL("exception when casting a QEvent to a QMouseEvent"); - } - } - return EventFilter::eventFilter(watched, event); -} - -MouseHoverEnterEventFilter::MouseHoverEnterEventFilter(QObject * receiver, const char * member) - : EventFilter(receiver, member) { -} - -bool MouseHoverEnterEventFilter::eventFilter(QObject * watched, QEvent * event) { - if (event->type() == QEvent::HoverEnter) { - filter(event); - return false; - } - return EventFilter::eventFilter(watched, event); -} - -MouseHoverLeaveEventFilter::MouseHoverLeaveEventFilter(QObject * receiver, const char * member) - : EventFilter(receiver, member) { -} - -bool MouseHoverLeaveEventFilter::eventFilter(QObject * watched, QEvent * event) { - if (event->type() == QEvent::HoverLeave) { - filter(event); - return false; - } - return EventFilter::eventFilter(watched, event); -} + ****************************************************************/ + +#include + +#include +#include + +#include +#include + +MouseMoveEventFilter::MouseMoveEventFilter(QObject * receiver, const char * member) + : EventFilter(receiver, member) { +} + +bool MouseMoveEventFilter::eventFilter(QObject * watched, QEvent * event) { + if (event->type() == QEvent::MouseMove) { + filter(event); + return false; + } + return EventFilter::eventFilter(watched, event); +} + +MousePressEventFilter::MousePressEventFilter(QObject * receiver, const char * member, Qt::MouseButton button) + : EventFilter(receiver, member), + _button(button) { +} + +bool MousePressEventFilter::eventFilter(QObject * watched, QEvent * event) { + if (event->type() == QEvent::MouseButtonPress) { + try { + QMouseEvent * mouseEvent = dynamic_cast(event); + + if ((_button == Qt::NoButton) || (mouseEvent->button() == _button)) { + filter(event); + return false; + } + } catch (const std::bad_cast&) { + //LOG_FATAL("exception when casting a QEvent to a QMouseEvent"); + } + } + return EventFilter::eventFilter(watched, event); +} + +MouseReleaseEventFilter::MouseReleaseEventFilter(QObject * receiver, const char * member, Qt::MouseButton button) + : EventFilter(receiver, member), + _button(button) { +} + +bool MouseReleaseEventFilter::eventFilter(QObject * watched, QEvent * event) { + if (event->type() == QEvent::MouseButtonRelease) { + try { + QMouseEvent * mouseEvent = dynamic_cast(event); + + if ((_button == Qt::NoButton) || (mouseEvent->button() == _button)) { + filter(event); + return false; + } + } catch (const std::bad_cast&) { + //LOG_FATAL("exception when casting a QEvent to a QMouseEvent"); + } + } + return EventFilter::eventFilter(watched, event); +} + +MouseHoverEnterEventFilter::MouseHoverEnterEventFilter(QObject * receiver, const char * member) + : EventFilter(receiver, member) { +} + +bool MouseHoverEnterEventFilter::eventFilter(QObject * watched, QEvent * event) { + if (event->type() == QEvent::HoverEnter) { + filter(event); + return false; + } + return EventFilter::eventFilter(watched, event); +} + +MouseHoverLeaveEventFilter::MouseHoverLeaveEventFilter(QObject * receiver, const char * member) + : EventFilter(receiver, member) { +} + +bool MouseHoverLeaveEventFilter::eventFilter(QObject * watched, QEvent * event) { + if (event->type() == QEvent::HoverLeave) { + filter(event); + return false; + } + return EventFilter::eventFilter(watched, event); +} From 358f27be06263c91873070476d4704ae8f799c61 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sat, 13 Oct 2018 15:50:14 +0200 Subject: [PATCH 3/4] Fix warnings in MessagePage.cpp /retroshare-gui/src/gui/settings/MessagePage.cpp:62:19: warning: deleting object of polymorphic class type 'Rs::Msgs::MsgTagType' which has non-virtual destructor might cause undefined behavior [-Wdelete-non- virtual-dtor] /retroshare-gui/src/gui/settings/MessagePage.cpp:62: warning: delete called on non-final 'Rs::Msgs::MsgTagType' that has virtual functions but non-virtual destructor /retroshare-gui/src/gui/settings/MessagePage.cpp:86: warning: use of old-style cast /retroshare-gui/src/gui/settings/MessagePage.cpp:172: warning: zero as null pointer constant /retroshare-gui/src/gui/settings/MessagePage.cpp:176: warning: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int') /retroshare-gui/src/gui/settings/MessagePage.cpp:203: warning: zero as null pointer constant /retroshare-gui/src/gui/settings/MessagePage.cpp:207: warning: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int') /retroshare-gui/src/gui/settings/MessagePage.cpp:261: warning: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int') /libretroshare/src/retroshare/rsmsgs.h:168: warning: 'Rs::Msgs::MessageInfo' has virtual functions but non-virtual destructor /libretroshare/src/retroshare/rsmsgs.h:168: warning: 'MessageInfo' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit /libretroshare/src/retroshare/rsmsgs.h:234: warning: 'Rs::Msgs::MsgInfoSummary' has virtual functions but non-virtual destructor /libretroshare/src/retroshare/rsmsgs.h:234: warning: 'MsgInfoSummary' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit /libretroshare/src/retroshare/rsmsgs.h:261: warning: 'Rs::Msgs::MsgTagInfo' has virtual functions but non-virtual destructor /libretroshare/src/retroshare/rsmsgs.h:328: warning: 'ChatId' has virtual functions but non-virtual destructor /libretroshare/src/retroshare/rsmsgs.h:400: warning: 'ChatLobbyInvite' has virtual functions but non-virtual destructor /libretroshare/src/retroshare/rsmsgs.h:420: warning: 'VisibleChatLobbyRecord' has virtual functions but non-virtual destructor /libretroshare/src/retroshare/rsmsgs.h:420: warning: 'VisibleChatLobbyRecord' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit /libretroshare/src/retroshare/rsmsgs.h:449: warning: 'ChatLobbyInfo' has virtual functions but non-virtual destructor /libretroshare/src/retroshare/rsmsgs.h:486: warning: 'RsMsgs' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit About vtable: https://stackoverflow.com/questions/23746941/what-is-the-meaning-of- clangs-wweak-vtables https://stackoverflow.com/questions/50463374/avoid-weak-vtable-warnings- for-classes-only-defined-in-a-source-file --- libretroshare/src/retroshare/rsmsgs.h | 26 +++++++++++++------ .../src/gui/settings/MessagePage.cpp | 14 +++++----- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index dda0d4bc7..ad189e03f 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -167,8 +167,10 @@ class MessageInfo_v2 struct MessageInfo : RsSerializable { - MessageInfo(): msgflags(0), size(0), count(0), ts(0) {} - std::string msgId; + MessageInfo(): msgflags(0), size(0), count(0), ts(0) {} + virtual ~MessageInfo() = default; + + std::string msgId; RsPeerId rspeerid_srcId; RsGxsId rsgxsid_srcId; @@ -230,10 +232,10 @@ struct MessageInfo : RsSerializable } }; - struct MsgInfoSummary : RsSerializable { MsgInfoSummary() : msgflags(0), count(0), ts(0) {} + virtual ~MsgInfoSummary() = default; std::string msgId; RsPeerId srcId; @@ -260,6 +262,8 @@ struct MsgInfoSummary : RsSerializable struct MsgTagInfo : RsSerializable { + virtual ~MsgTagInfo() = default; + std::string msgId; std::list tagIds; @@ -272,6 +276,7 @@ struct MsgTagInfo : RsSerializable struct MsgTagType : RsSerializable { + virtual ~MsgTagType() = default; /* map containing tagId -> pair (text, rgb color) */ std::map > types; @@ -326,7 +331,9 @@ struct DistantChatPeerInfo class ChatId : RsSerializable { public: - ChatId(); + ChatId(); + virtual ~ChatId() = default; + explicit ChatId(RsPeerId id); explicit ChatId(ChatLobbyId id); explicit ChatId(DistantChatPeerId id); @@ -398,6 +405,8 @@ public: class ChatLobbyInvite : RsSerializable { public: + virtual ~ChatLobbyInvite() = default; + ChatLobbyId lobby_id ; RsPeerId peer_id ; std::string lobby_name ; @@ -418,7 +427,8 @@ public: class VisibleChatLobbyRecord : RsSerializable { public: - VisibleChatLobbyRecord(): lobby_id(0), total_number_of_peers(0), last_report_time(0){} + VisibleChatLobbyRecord(): lobby_id(0), total_number_of_peers(0), last_report_time(0){} + virtual ~VisibleChatLobbyRecord() = default; ChatLobbyId lobby_id ; // unique id of the lobby std::string lobby_name ; // name to use for this lobby @@ -443,10 +453,11 @@ public: } }; - class ChatLobbyInfo : RsSerializable { public: + virtual ~ChatLobbyInfo() = default; + ChatLobbyId lobby_id ; // unique id of the lobby std::string lobby_name ; // name to use for this lobby std::string lobby_topic ; // topic to use for this lobby @@ -486,7 +497,7 @@ class RsMsgs public: RsMsgs() {} - virtual ~RsMsgs() {} + virtual ~RsMsgs() = default; /****************************************/ /* Message Items */ @@ -896,6 +907,5 @@ virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid)=0; }; - #endif diff --git a/retroshare-gui/src/gui/settings/MessagePage.cpp b/retroshare-gui/src/gui/settings/MessagePage.cpp index cc2b41ca8..5005c509b 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.cpp +++ b/retroshare-gui/src/gui/settings/MessagePage.cpp @@ -59,7 +59,7 @@ MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags) MessagePage::~MessagePage() { - delete(m_pTags); + delete(m_pTags); } void MessagePage::distantMsgsComboBoxChanged(int i) @@ -83,7 +83,7 @@ void MessagePage::distantMsgsComboBoxChanged(int i) void MessagePage::updateMsgToReadOnActivate() { Settings->setMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked()); } void MessagePage::updateLoadEmbededImages() { Settings->setMsgLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); } -void MessagePage::updateMsgOpen() { Settings->setMsgOpen((RshareSettings::enumMsgOpen) ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt());} +void MessagePage::updateMsgOpen() { Settings->setMsgOpen( static_cast(ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt()) ); } void MessagePage::updateDistantMsgs() { Settings->setValue("DistantMessages", ui.comboBox->currentIndex()); } void MessagePage::updateMsgTags() @@ -169,11 +169,11 @@ void MessagePage::addTag() void MessagePage::editTag() { QListWidgetItem *pItemWidget = ui.tags_listWidget->currentItem(); - if (pItemWidget == NULL) { + if (!pItemWidget) { return; } - uint32_t nId = pItemWidget->data(Qt::UserRole).toInt(); + uint32_t nId = pItemWidget->data(Qt::UserRole).toUInt(); if (nId == 0) { return; } @@ -200,11 +200,11 @@ void MessagePage::editTag() void MessagePage::deleteTag() { QListWidgetItem *pItemWidget = ui.tags_listWidget->currentItem(); - if (pItemWidget == NULL) { + if (!pItemWidget) { return; } - uint32_t nId = pItemWidget->data(Qt::UserRole).toInt(); + uint32_t nId = pItemWidget->data(Qt::UserRole).toUInt(); if (nId == 0) { return; } @@ -258,7 +258,7 @@ void MessagePage::currentRowChangedTag(int row) if (pItemWidget) { bEditEnable = true; - uint32_t nId = pItemWidget->data(Qt::UserRole).toInt(); + uint32_t nId = pItemWidget->data(Qt::UserRole).toUInt(); if (nId >= RS_MSGTAGTYPE_USER) { bDeleteEnable = true; From 89082f3420e0b0771d3dd1d615ca08413d670714 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sun, 14 Oct 2018 16:22:30 +0200 Subject: [PATCH 4/4] Fix warnings in RetroShareLink /retroshare-gui/src/gui/RetroShareLink.cpp:1556: warning: this statement may fall through [-Wimplicit-fallthrough=] /retroshare-gui/src/gui/RetroShareLink.cpp:400: warning: implicit conversion loses integer precision: 'qulonglong' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') /retroshare-gui/src/gui/RetroShareLink.cpp:736: warning: use of old- style cast /retroshare-gui/src/gui/RetroShareLink.cpp:733: warning: unannotated fall-through between switch labels /retroshare-gui/src/gui/RetroShareLink.cpp:1175: warning: implicit conversion changes signedness: 'char' to 'unsigned char' /retroshare-gui/src/gui/RetroShareLink.cpp:1193: warning: implicit conversion changes signedness: 'char' to 'unsigned char' /retroshare-gui/src/gui/RetroShareLink.cpp:1208: warning: implicit conversion changes signedness: 'char' to 'unsigned char' /retroshare-gui/src/gui/RetroShareLink.cpp:1228: warning: implicit conversion changes signedness: 'char' to 'unsigned char' /retroshare-gui/src/gui/RetroShareLink.cpp:1261: warning: implicit conversion changes signedness: 'int' to 'unsigned int' /retroshare-gui/src/gui/RetroShareLink.cpp:1507: warning: zero as null pointer constant /retroshare-gui/src/gui/RetroShareLink.cpp:1621: warning: zero as null pointer constant /retroshare-gui/src/gui/RetroShareLink.cpp:1696: warning: zero as null pointer constant /retroshare-gui/src/gui/RetroShareLink.cpp:1698: warning: zero as null pointer constant /retroshare-gui/src/gui/RetroShareLink.cpp:1742: warning: zero as null pointer constant /retroshare-gui/src/gui/RetroShareLink.cpp:1775: warning: implicit conversion changes signedness: 'int' to 'unsigned int' /retroshare-gui/src/gui/RetroShareLink.cpp:1779: warning: implicit conversion changes signedness: 'int' to 'unsigned int' /retroshare-gui/src/gui/RetroShareLink.cpp:1559: warning: unannotated fall-through between switch labels --- retroshare-gui/src/gui/RetroShareLink.cpp | 38 +++++++++++++---------- retroshare-gui/src/gui/RetroShareLink.h | 10 +++--- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 744826bbb..5ee98b938 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -397,7 +397,7 @@ void RetroShareLink::fromUrl(const QUrl& url) _name = decodedQueryItemValue(urlQuery, FILE_TREE_NAME); _size = urlQuery.queryItemValue(FILE_TREE_SIZE).toULongLong(&ok); _radix = decodedQueryItemValue(urlQuery, FILE_TREE_DATA); - _count = urlQuery.queryItemValue(FILE_TREE_COUNT).toULongLong(&ok); + _count = urlQuery.queryItemValue(FILE_TREE_COUNT).toUInt(&ok); #ifdef DEBUG_RSLINK std::cerr << "Got a file tree link!!" << std::endl; @@ -553,7 +553,10 @@ RetroShareLink RetroShareLink::createCertificate(const RsPeerId& ssl_id) RetroShareLink link; link.clear(); -#warning csoler 2012-08-14: This is baaaaaad code: +#ifndef RS_NO_WARN_CPP +#pragma message("csoler 2012-08-14: This is baaaaaad code") +#endif + // - we should not need to parse and re-read a cert in old format. // RsPeerDetails detail; @@ -730,10 +733,11 @@ void RetroShareLink::check() if(!checkSSLId(_SSLid)) _valid = false; // no break! We also test file stuff below. /* fallthrough */ + [[clang::fallthrough]]; case TYPE_FILE_TREE: /* fallthrough */ case TYPE_FILE: - if(_size > (((uint64_t)1)<<40)) // 1TB. Who has such large files? + if(_size > ((static_cast(1))<<40)) // 1TB. Who has such large files? _valid = false; if(!checkName(_name)) @@ -1172,9 +1176,9 @@ bool RetroShareLink::checkSSLId(const QString& ssl_id) for(int i=0;i47 && b<58) || (b>96 && b<103))) + if(!((b>='0' && b<='9') || (b>='a' && b<='f'))) return false ; } @@ -1190,9 +1194,9 @@ bool RetroShareLink::checkPGPId(const QString& pgp_id) for(int i=0;i47 && b<58) || (b>64 && b<71))) + if(!((b>='0' && b<='9') || (b>='A' && b<='F'))) return false ; } @@ -1205,9 +1209,9 @@ bool RetroShareLink::checkRadix64(const QString& s) for(int i=0;i 46 && b < 58) || (b > 64 && b < 91) || (b > 96 && b < 123) || b=='+' || b=='=')) + if(!( (b >= '0' && b <= '9') || (b >= 'A' && b <= 'Z') || (b >= 'a' && b <= 'z') || b=='/' || b=='+' || b=='=')) { std::cerr << "Character not allowed in radix: " << b << std::endl; return false; @@ -1225,9 +1229,9 @@ bool RetroShareLink::checkHash(const QString& hash) for(int i=0;i47 && b<58) || (b>96 && b<103))) + if(!((b>='0' && b<='9') || (b>='a' && b<='f'))) return false ; } @@ -1504,7 +1508,7 @@ static void processList(const QStringList &list, const QString &textSingular, co { if(gxs_details.mFlags & RS_IDENTITY_FLAGS_IS_OWN_ID) { - QMessageBox::warning(NULL,QString("Cannot send message to yourself"),QString("This identity is owned by you. You wouldn't want to send yourself a message right?")); + QMessageBox::warning(nullptr,QString("Cannot send message to yourself"),QString("This identity is owned by you. You wouldn't want to send yourself a message right?")); break ; } @@ -1556,6 +1560,8 @@ static void processList(const QStringList &list, const QString &textSingular, co } } //break; + /* fallthrough */ + [[clang::fallthrough]]; case TYPE_EXTRAFILE: { #ifdef DEBUG_RSLINK @@ -1618,7 +1624,7 @@ static void processList(const QStringList &list, const QString &textSingular, co question += QObject::tr("Before you do so, please make sure that this file does not contain malicious executable code."); question += "

" + cleanname + ""; - QMessageBox mb(QObject::tr("Confirmation"), question, QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No, links.size()>1 ? QMessageBox::NoToAll : 0, 0); + QMessageBox mb(QObject::tr("Confirmation"), question, QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No, links.size()>1 ? QMessageBox::NoToAll : 0, nullptr); int ret = mb.exec(); if(ret == QMessageBox::Yes) { ++countFileOpened; @@ -1693,9 +1699,9 @@ static void processList(const QStringList &list, const QString &textSingular, co case TYPE_IDENTITY: { if(rsIdentity->deserialiseIdentityFromMemory(link.radixGroupData().toStdString())) - QMessageBox::information(NULL,QObject::tr("Identity added to People"),QObject::tr("The identity was added to people. You can now chat with it, send messages to it, etc.")) ; + QMessageBox::information(nullptr,QObject::tr("Identity added to People"),QObject::tr("The identity was added to people. You can now chat with it, send messages to it, etc.")) ; else - QMessageBox::warning(NULL,QObject::tr("Identity cannot be added to People"),QObject::tr("The identity was not added to people. Some error occured. The link is probably corrupted.")) ; + QMessageBox::warning(nullptr,QObject::tr("Identity cannot be added to People"),QObject::tr("The identity was not added to people. Some error occured. The link is probably corrupted.")) ; } break; @@ -1739,7 +1745,7 @@ static void processList(const QStringList &list, const QString &textSingular, co else { ChatDialog* chatDialog = ChatDialog::getChat(chatId, Settings->getChatFlags()); - if (chatDialog != NULL) { + if (chatDialog) { chatroomFound.append(link.name()); } else { chatroomUnknown.append(link.name()); diff --git a/retroshare-gui/src/gui/RetroShareLink.h b/retroshare-gui/src/gui/RetroShareLink.h index d94588e18..0b304b0bb 100644 --- a/retroshare-gui/src/gui/RetroShareLink.h +++ b/retroshare-gui/src/gui/RetroShareLink.h @@ -43,12 +43,12 @@ #include -#define RSLINK_PROCESS_NOTIFY_SUCCESS 1 // notify on success -#define RSLINK_PROCESS_NOTIFY_ERROR 2 // notify on error -#define RSLINK_PROCESS_NOTIFY_ASK 4 // ask for add the links -#define RSLINK_PROCESS_NOTIFY_BAD_CHARS 8 // / or \\ characters in a filename +#define RSLINK_PROCESS_NOTIFY_SUCCESS 0x01u // notify on success +#define RSLINK_PROCESS_NOTIFY_ERROR 0x02u // notify on error +#define RSLINK_PROCESS_NOTIFY_ASK 0x04u // ask for add the links +#define RSLINK_PROCESS_NOTIFY_BAD_CHARS 0x08u // / or \\ characters in a filename -#define RSLINK_PROCESS_NOTIFY_ALL 15 +#define RSLINK_PROCESS_NOTIFY_ALL 0x0Fu #define RSLINK_SCHEME "retroshare"