From 6e42cf420015a84d45b22050b1ff2dc76abd85a6 Mon Sep 17 00:00:00 2001 From: Phenom Date: Tue, 18 Apr 2017 11:56:25 +0200 Subject: [PATCH 01/12] Fix Clang warnings: field 'mPassword' will be initialized after field 'mPrevIsBad' warning: field 'mPassword' will be initialized after field 'mPrevIsBad' [-Wreorder] --- libresapi/src/api/RsControlModule.cpp | 4 ++-- libresapi/src/api/RsControlModule.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libresapi/src/api/RsControlModule.cpp b/libresapi/src/api/RsControlModule.cpp index cb3cdcdf2..ece94b7af 100644 --- a/libresapi/src/api/RsControlModule.cpp +++ b/libresapi/src/api/RsControlModule.cpp @@ -25,8 +25,8 @@ RsControlModule::RsControlModule(int argc, char **argv, StateTokenServer* sts, A mRunState(WAITING_INIT), mAutoLoginNextTime(false), mWantPassword(false), - mPassword(""), - mPrevIsBad(false) + mPrevIsBad(false), + mPassword("") { mStateToken = sts->getNewToken(); this->argc = argc; diff --git a/libresapi/src/api/RsControlModule.h b/libresapi/src/api/RsControlModule.h index 7e306405c..8b8b1f3f0 100644 --- a/libresapi/src/api/RsControlModule.h +++ b/libresapi/src/api/RsControlModule.h @@ -77,7 +77,7 @@ private: // to notify that a password callback is waiting // to answer the request, clear the flag and set the password bool mWantPassword; - bool mPrevIsBad; + bool mPrevIsBad ; std::string mTitle; std::string mKeyName; std::string mPassword; From 490f8d2f5462b3b4dc639b975a752703077566a3 Mon Sep 17 00:00:00 2001 From: Phenom Date: Tue, 18 Apr 2017 12:00:00 +0200 Subject: [PATCH 02/12] Fix Clang warnings: 'TYPE_IDENTITY' not handled warning: enumeration value 'TYPE_IDENTITY' not handled in switch [- Wswitch] --- retroshare-gui/src/util/HandleRichText.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/util/HandleRichText.cpp b/retroshare-gui/src/util/HandleRichText.cpp index 73801bd5b..c5f578d3a 100644 --- a/retroshare-gui/src/util/HandleRichText.cpp +++ b/retroshare-gui/src/util/HandleRichText.cpp @@ -230,12 +230,13 @@ bool RsHtml::canReplaceAnchor(QDomDocument &/*doc*/, QDomElement &/*element*/, c case RetroShareLink::TYPE_PERSON: case RetroShareLink::TYPE_FORUM: case RetroShareLink::TYPE_CHANNEL: - case RetroShareLink::TYPE_POSTED: case RetroShareLink::TYPE_SEARCH: case RetroShareLink::TYPE_MESSAGE: case RetroShareLink::TYPE_EXTRAFILE: case RetroShareLink::TYPE_PRIVATE_CHAT: case RetroShareLink::TYPE_PUBLIC_MSG: + case RetroShareLink::TYPE_POSTED: + case RetroShareLink::TYPE_IDENTITY: // not yet implemented break; From f22dc0f0df195524590edc378395130b7d712c8f Mon Sep 17 00:00:00 2001 From: Phenom Date: Tue, 18 Apr 2017 12:02:34 +0200 Subject: [PATCH 03/12] Fix Clang warnings: unused variable 'action' warning: unused variable 'action' [-Wunused-variable] QAction *action = contextMenu- >addAction(QIcon(":/images/chat_24.png"),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ; --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index aac7e3ba5..755dab9c9 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -2408,8 +2408,8 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) } } - if(n_selected_items==1) - QAction *action = contextMenu->addAction(QIcon(":/images/chat_24.png"),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ; + if (n_selected_items==1) + contextMenu->addAction(QIcon(":/images/chat_24.png"),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ; // always allow to send messages contextMenu->addAction(QIcon(":/images/mail_new.png"), tr("Send message"), this, SLOT(sendMsg())); From ff1908eda6293d5105fbe1d60d5c41641e1bb0e8 Mon Sep 17 00:00:00 2001 From: Phenom Date: Wed, 19 Apr 2017 11:50:24 +0200 Subject: [PATCH 04/12] Fix Clang Static Analyser: Undefined allocation of 0 bytes Unix API: Undefined allocation of 0 bytes (CERT MEM04-C; CWE-131): Call to 'malloc' has an allocation size of 0 bytes 1: Loop body executed 0 times in /home/phenom/GIT/RetroShare/trunk/ libbitdht/src/util/bdbloom.cc:223 2: Calling 'bloomFilter::getFilter' in /home/phenom/GIT/RetroShare/ trunk/libbitdht/src/util/bdbloom.cc:240 3: 'bytes' initialized to 0 in /home/phenom/GIT/RetroShare/trunk/ libbitdht/src/util/bdbloom.cc:141 4: Call to 'malloc' has an allocation size of 0 bytes in /home/phenom/ GIT/RetroShare/trunk/libbitdht/src/util/bdbloom.cc:148 --- libbitdht/src/util/bdbloom.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libbitdht/src/util/bdbloom.cc b/libbitdht/src/util/bdbloom.cc index 36f3a3bee..016808ea4 100644 --- a/libbitdht/src/util/bdbloom.cc +++ b/libbitdht/src/util/bdbloom.cc @@ -144,6 +144,11 @@ std::string bloomFilter::getFilter() bytes++; } + if (bytes==0) + { + std::cerr << "(EE) Error. Cannot allocate memory for 0 byte in " << __PRETTY_FUNCTION__ << std::endl; + return std::string(); + } // convert to binary array. uint8_t *tmparray = (uint8_t *) malloc(bytes); From b2b7d004cd4204c3ae06f1876329dd4800f38f98 Mon Sep 17 00:00:00 2001 From: Phenom Date: Wed, 19 Apr 2017 14:01:35 +0200 Subject: [PATCH 05/12] Fix CSA warnings: Called C++ object pointer is null Logic error: Called C++ object pointer is null 1: 'di' initialized here in /home/phenom/GIT/RetroShare/trunk/plugins/ VOIP/gui/VOIPGUIHandler.cpp:157 2: Assuming 'di' is null in /home/phenom/GIT/RetroShare/trunk/plugins/ VOIP/gui/VOIPGUIHandler.cpp:158 3: Called C++ object pointer is null in /home/phenom/GIT/RetroShare/ trunk/plugins/VOIP/gui/VOIPGUIHandler.cpp:161 --- plugins/VOIP/gui/VOIPGUIHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/VOIP/gui/VOIPGUIHandler.cpp b/plugins/VOIP/gui/VOIPGUIHandler.cpp index 6a7d7d703..f999ed437 100644 --- a/plugins/VOIP/gui/VOIPGUIHandler.cpp +++ b/plugins/VOIP/gui/VOIPGUIHandler.cpp @@ -155,7 +155,7 @@ void VOIPGUIHandler::ReceivedVoipBandwidthInfo(const RsPeerId &peer_id, int byte #endif ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ; - if(!di) + if(di) { ChatWidget *cw = di->getChatWidget(); From 90cd6233d8b3e446984ddc1b68b2e89fbf35995d Mon Sep 17 00:00:00 2001 From: Phenom Date: Wed, 19 Apr 2017 14:04:50 +0200 Subject: [PATCH 06/12] Fix CAS warnings: Potential leak of memory pointed to by 'toaster' Memory Error: Memory leak: Potential leak of memory pointed to by 'toaster' 1: Memory is allocated in /home/phenom/GIT/RetroShare/trunk/plugins/ VOIP/gui/VOIPToasterNotify.cpp:182 --- plugins/VOIP/gui/VOIPToasterNotify.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/VOIP/gui/VOIPToasterNotify.cpp b/plugins/VOIP/gui/VOIPToasterNotify.cpp index d2de3f6bd..eff862467 100644 --- a/plugins/VOIP/gui/VOIPToasterNotify.cpp +++ b/plugins/VOIP/gui/VOIPToasterNotify.cpp @@ -180,7 +180,7 @@ ToasterItem* VOIPToasterNotify::testToasterItem(QString tag) if (tag == "Invitation") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Invitation"), VOIPToasterItem::Invitation)); #endif if (tag == "AudioCall") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Audio Call"), VOIPToasterItem::AudioCall)); - if (tag == "VideoCall") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Video Call"), VOIPToasterItem::VideoCall)); + if (tag == "VideoCall" || toaster == NULL) toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Video Call"), VOIPToasterItem::VideoCall)); return toaster; } From 30632dcfeb5a065caee5b3b9d610ad50880a65b2 Mon Sep 17 00:00:00 2001 From: Phenom Date: Wed, 19 Apr 2017 14:06:56 +0200 Subject: [PATCH 07/12] Fix CSA warnings: Called C++ object pointer is null Logic error: Called C++ object pointer is null 1: Calling 'MainWindow::createNotifyIcons' in /home/phenom/GIT/ RetroShare/trunk/retroshare-gui/src/gui/MainWindow.cpp:291 2: Loop body executed 0 times in /home/phenom/GIT/RetroShare/trunk/ retroshare-gui/src/gui/MainWindow.cpp:600 3: Calling 'MainWindow::updateTrayCombine' in /home/phenom/GIT/ RetroShare/trunk/retroshare-gui/src/gui/MainWindow.cpp:605 4: Value assigned to field 'notifyMenu' in /home/phenom/GIT/RetroShare/ trunk/retroshare-gui/src/gui/MainWindow.cpp:654 5: Assuming pointer value is null in /home/phenom/GIT/RetroShare/trunk/ retroshare-gui/src/gui/MainWindow.cpp:658 6: Called C++ object pointer is null in /home/phenom/GIT/RetroShare/ trunk/retroshare-gui/src/gui/MainWindow.cpp:679 --- retroshare-gui/src/gui/MainWindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 8e8534345..af2e10574 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -676,7 +676,8 @@ void MainWindow::updateTrayCombine() } } - notifyMenu->menuAction()->setVisible(visible); + if (notifyMenu) + notifyMenu->menuAction()->setVisible(visible); // update tray icon updateFriends(); From 1f16f46aad3769457561e5a5d0d26fef81beec3c Mon Sep 17 00:00:00 2001 From: Phenom Date: Wed, 19 Apr 2017 14:15:34 +0200 Subject: [PATCH 08/12] Fix CSA warnings: Called C++ object pointer is null Logic error: Called C++ object pointer is null 1: Assuming pointer value is null in /home/phenom/GIT/RetroShare/trunk/ retroshare-gui/src/gui/common/MimeTextEdit.cpp:65 2: Called C++ object pointer is null in /home/phenom/GIT/RetroShare/ trunk/retroshare-gui/src/gui/common/MimeTextEdit.cpp:83 --- retroshare-gui/src/gui/common/MimeTextEdit.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/retroshare-gui/src/gui/common/MimeTextEdit.cpp b/retroshare-gui/src/gui/common/MimeTextEdit.cpp index 5ff657ce3..9c0395ffb 100644 --- a/retroshare-gui/src/gui/common/MimeTextEdit.cpp +++ b/retroshare-gui/src/gui/common/MimeTextEdit.cpp @@ -77,6 +77,7 @@ void MimeTextEdit::insertFromMimeData(const QMimeData* source) } } #endif + if (source == NULL) return; //insert retroshare links QList links; From 90aaace69c9a74509ed11992226c5c0d4c9dbcd6 Mon Sep 17 00:00:00 2001 From: Phenom Date: Wed, 19 Apr 2017 14:18:35 +0200 Subject: [PATCH 09/12] Fix CSA warnings: Called C++ object pointer is null Logic error: Called C++ object pointer is null 1: Value assigned to field 'mMainAction' in /home/phenom/GIT/ RetroShare/trunk/retroshare-gui/src/gui/common/UserNotify.cpp:94 2: Assuming pointer value is null in /home/phenom/GIT/RetroShare/trunk/ retroshare-gui/src/gui/common/UserNotify.cpp:95 3: Called C++ object pointer is null in /home/phenom/GIT/RetroShare/ trunk/retroshare-gui/src/gui/common/UserNotify.cpp:103 --- retroshare-gui/src/gui/common/UserNotify.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/common/UserNotify.cpp b/retroshare-gui/src/gui/common/UserNotify.cpp index 96cbf554b..6c70b3c9f 100644 --- a/retroshare-gui/src/gui/common/UserNotify.cpp +++ b/retroshare-gui/src/gui/common/UserNotify.cpp @@ -99,7 +99,7 @@ void UserNotify::initialize(QToolBar *mainToolBar, QAction *mainAction, QListWid } } mListItem = listItem; - if (mListItem && !mMainAction) { + if (mListItem && mMainAction) { mButtonText = mMainAction->text(); } } From 593c0cb7e65b13a2e07d74fdc15d563e93f78e75 Mon Sep 17 00:00:00 2001 From: Phenom Date: Wed, 19 Apr 2017 14:19:54 +0200 Subject: [PATCH 10/12] Fix CSA warnings: Called C++ object pointer is null Logic error: Called C++ object pointer is null 1: Null pointer value stored to field 'mInternalTokenQueue' in /home/ phenom/GIT/RetroShare/trunk/retroshare-gui/src/gui/gxs/ GxsGroupDialog.cpp:70 2: Calling 'GxsGroupDialog::init' in /home/phenom/GIT/RetroShare/trunk/ retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp:72 3: Calling 'GxsGroupDialog::initMode' in /home/phenom/GIT/RetroShare/ trunk/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp:136 4: Calling 'GxsGroupDialog::requestGroup' in /home/phenom/GIT/ RetroShare/trunk/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp:190 5: Called C++ object pointer is null in /home/phenom/GIT/RetroShare/ trunk/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp:866 --- retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp index b18ab3688..cd792623d 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp @@ -863,7 +863,8 @@ void GxsGroupDialog::requestGroup(const RsGxsGroupId &groupId) std::cerr << std::endl; uint32_t token; - mInternalTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, GXSGROUP_INTERNAL_LOADGROUP); + if (mInternalTokenQueue) + mInternalTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, GXSGROUP_INTERNAL_LOADGROUP) ; } void GxsGroupDialog::loadGroup(uint32_t token) From 3592d5bf5d35aee004742d06a949e4508a26bb32 Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 21 Apr 2017 19:55:37 +0200 Subject: [PATCH 11/12] =?UTF-8?q?Fix=20GCC=20warnings:=20unused=20paramete?= =?UTF-8?q?r=20=E2=80=98names=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /libretroshare/src/pqi/pqiservice.h:80: warning: unused parameter ‘names’ [-Wunused-parameter] virtual void getItemNames(std::map& names) const {} // This does nothing by default. Service should derive it in order to give info for the UI ^~~~~ --- libretroshare/src/pqi/pqiservice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretroshare/src/pqi/pqiservice.h b/libretroshare/src/pqi/pqiservice.h index b22a34aac..41c540d4c 100644 --- a/libretroshare/src/pqi/pqiservice.h +++ b/libretroshare/src/pqi/pqiservice.h @@ -77,7 +77,7 @@ public: virtual int tick() { return 0; } - virtual void getItemNames(std::map& names) const {} // This does nothing by default. Service should derive it in order to give info for the UI + virtual void getItemNames(std::map& /*names*/) const {} // This does nothing by default. Service should derive it in order to give info for the UI private: p3ServiceServerIface *mServiceServer; // const, no need for mutex. From 078913f0f34c6246e6f61290a308fb35b7a7886e Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 21 Apr 2017 21:29:20 +0200 Subject: [PATCH 12/12] =?UTF-8?q?Fix=20GCC=20warnings:=20enumeration=20val?= =?UTF-8?q?ue=20=E2=80=98TYPE=5FIDENTITY=E2=80=99=20not=20handled=20in=20s?= =?UTF-8?q?witch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit warning: enumeration value ‘TYPE_IDENTITY’ not handled in switch [- Wswitch] switch (link.type()) { ^ --- retroshare-gui/src/util/HandleRichText.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/util/HandleRichText.cpp b/retroshare-gui/src/util/HandleRichText.cpp index c5f578d3a..96fd36d73 100644 --- a/retroshare-gui/src/util/HandleRichText.cpp +++ b/retroshare-gui/src/util/HandleRichText.cpp @@ -260,12 +260,13 @@ void RsHtml::anchorStylesheetForImg(QDomDocument &/*doc*/, QDomElement &/*elemen case RetroShareLink::TYPE_PERSON: case RetroShareLink::TYPE_FORUM: case RetroShareLink::TYPE_CHANNEL: - case RetroShareLink::TYPE_POSTED: case RetroShareLink::TYPE_SEARCH: case RetroShareLink::TYPE_MESSAGE: case RetroShareLink::TYPE_EXTRAFILE: case RetroShareLink::TYPE_PRIVATE_CHAT: case RetroShareLink::TYPE_PUBLIC_MSG: + case RetroShareLink::TYPE_POSTED: + case RetroShareLink::TYPE_IDENTITY: // not yet implemented break;