From 633a6cf8c2fc40b4eb40b8dcb2778b5dfa78b550 Mon Sep 17 00:00:00 2001 From: Gio Date: Wed, 12 Oct 2016 20:43:38 +0200 Subject: [PATCH] Fixed a bunch of warnings in safe ways --- libresapi/src/api/IdentityHandler.cpp | 2 +- libresapi/src/api/json.cpp | 2 - libretroshare/src/file_sharing/hash_cache.cc | 2 +- libretroshare/src/file_sharing/p3filelists.cc | 39 ++++++++++--------- libretroshare/src/ft/ftcontroller.cc | 6 +-- libretroshare/src/ft/ftserver.cc | 2 +- libretroshare/src/gxs/rsgenexchange.cc | 10 ++--- libretroshare/src/rsserver/rsaccounts.cc | 2 +- libretroshare/src/serialiser/rsbaseserial.cc | 2 +- libretroshare/src/services/p3banlist.cc | 16 ++++---- retroshare-gui/src/gui/FriendsDialog.cpp | 2 +- .../src/gui/gxs/GxsMessageFramePostWidget.cpp | 2 +- retroshare-nogui/src/TerminalApiClient.cpp | 2 +- 13 files changed, 41 insertions(+), 48 deletions(-) diff --git a/libresapi/src/api/IdentityHandler.cpp b/libresapi/src/api/IdentityHandler.cpp index 6d017fad8..f707e3596 100644 --- a/libresapi/src/api/IdentityHandler.cpp +++ b/libresapi/src/api/IdentityHandler.cpp @@ -29,7 +29,7 @@ private: std::vector mIds; StateToken mStateToken; protected: - virtual void gxsDoWork(Request &req, Response &resp) + virtual void gxsDoWork(Request& /*req*/, Response &resp) { resp.mDataStream.getStreamToMember(); for(std::vector::iterator vit = mIds.begin(); vit != mIds.end(); ++vit) diff --git a/libresapi/src/api/json.cpp b/libresapi/src/api/json.cpp index d921e6b80..2bcec7e81 100644 --- a/libresapi/src/api/json.cpp +++ b/libresapi/src/api/json.cpp @@ -824,7 +824,6 @@ static Value DeserializeValue(std::string& str, bool* had_error, std::stack::iterator it(mFiles.begin());it!=mFiles.end();) - if(it->second.time_stamp + duration < (uint64_t)now) + if((uint64_t)(it->second.time_stamp + duration) < (uint64_t)now) { #ifdef HASHSTORAGE_DEBUG std::cerr << " Entry too old: " << it->first << ", ts=" << it->second.time_stamp << std::endl ; diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index f8f87c701..0b1335410 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -621,29 +621,30 @@ void p3FileDatabase::requestDirUpdate(void *ref) } } -bool p3FileDatabase::findChildPointer(void *ref, int row, void *& result, FileSearchFlags flags) const +bool p3FileDatabase::findChildPointer( void *ref, int row, void *& result, + FileSearchFlags flags ) const { - RS_STACK_MUTEX(mFLSMtx) ; + RS_STACK_MUTEX(mFLSMtx); - result = NULL ; + result = NULL; - if (ref == NULL) - if(flags & RS_FILE_HINTS_LOCAL) - { - if(row != 0) - return false ; + if (ref == NULL) + { + if(flags & RS_FILE_HINTS_LOCAL) + { + if(row != 0) return false; - convertEntryIndexToPointer(0,0,result); + convertEntryIndexToPointer(0,0,result); - return true ; - } - else if((uint32_t)row < mRemoteDirectories.size()) - { - convertEntryIndexToPointer(mRemoteDirectories[row]->root(),row+1,result); - return true; - } - else - return false; + return true; + } + else if((uint32_t)row < mRemoteDirectories.size()) + { + convertEntryIndexToPointer(mRemoteDirectories[row]->root(), row+1, result); + return true; + } + else return false; + } uint32_t fi; DirectoryStorage::EntryIndex e ; @@ -667,8 +668,8 @@ bool p3FileDatabase::findChildPointer(void *ref, int row, void *& result, FileSe return res; } -// This function converts a pointer into directory details, to be used by the AbstractItemModel for browsing the files. +// This function converts a pointer into directory details, to be used by the AbstractItemModel for browsing the files. int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags flags) const { RS_STACK_MUTEX(mFLSMtx) ; diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index ae90dfe50..821bd1ea0 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -727,14 +727,13 @@ bool ftController::completeFile(const RsFileHash& hash) std::string path; std::string name; uint64_t size = 0; - uint32_t state = 0; uint32_t period = 0; TransferRequestFlags flags ; TransferRequestFlags extraflags ; uint32_t completeCount = 0; { - RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ + RS_STACK_MUTEX(ctrlMutex); #ifdef CONTROL_DEBUG std::cerr << "ftController:completeFile(" << hash << ")"; @@ -816,7 +815,6 @@ bool ftController::completeFile(const RsFileHash& hash) name = fc->mName; //hash = fc->mHash; size = fc->mSize; - state = fc->mState; period = 30 * 24 * 3600; /* 30 days */ extraflags.clear() ; @@ -837,7 +835,7 @@ bool ftController::completeFile(const RsFileHash& hash) if(flags & RS_FILE_REQ_ANONYMOUS_ROUTING) mTurtle->stopMonitoringTunnels(hash_to_suppress) ; - } /******* UNLOCKED ********/ + } // UNLOCK: RS_STACK_MUTEX(ctrlMutex); /******************** NO Mutex from Now ******************** diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index 832530ade..f259b388f 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -543,7 +543,7 @@ int ftServer::RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags { return mFileDatabase->RequestDirDetails(ref,details,flags) ; } -uint32_t ftServer::getType(void *ref, FileSearchFlags flags) +uint32_t ftServer::getType(void *ref, FileSearchFlags /*flags*/) { return mFileDatabase->getType(ref) ; } diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index d2ebedd85..3ff86cdf6 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -1691,7 +1691,7 @@ void RsGenExchange::processMsgMetaChanges() { MsgLocMetaData& m = mit->second; - int32_t value, mask; + int32_t value, mask; bool ok = true; bool changed = false; @@ -1717,7 +1717,7 @@ void RsGenExchange::processMsgMetaChanges() { RsGxsMsgMetaData* meta = *(msgMetaV.begin()); value = (meta->mMsgStatus & ~mask) | (mask & value); - changed = (meta->mMsgStatus != value); + changed = (static_cast(meta->mMsgStatus) != value); m.val.put(RsGeneralDataService::MSG_META_STATUS, value); delete meta; ok = true; @@ -2822,10 +2822,8 @@ void RsGenExchange::processRecvdMessages() mNetService->rejectMessage(*it) ; } -bool RsGenExchange::acceptNewGroup(const RsGxsGrpMetaData *grpMeta) -{ - return true; -} +bool RsGenExchange::acceptNewGroup(const RsGxsGrpMetaData* /*grpMeta*/ ) +{ return true; } void RsGenExchange::processRecvdGroups() { diff --git a/libretroshare/src/rsserver/rsaccounts.cc b/libretroshare/src/rsserver/rsaccounts.cc index c55fadd53..09c3e7d63 100644 --- a/libretroshare/src/rsserver/rsaccounts.cc +++ b/libretroshare/src/rsserver/rsaccounts.cc @@ -1059,7 +1059,7 @@ bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const s X509_print_ex(bio_out, x509, nmflag, reqflag); - BIO_flush(bio_out); + (void) BIO_flush(bio_out); BIO_free(bio_out); /* Save cert to file */ diff --git a/libretroshare/src/serialiser/rsbaseserial.cc b/libretroshare/src/serialiser/rsbaseserial.cc index 283c4f50e..b34c9f1fd 100644 --- a/libretroshare/src/serialiser/rsbaseserial.cc +++ b/libretroshare/src/serialiser/rsbaseserial.cc @@ -231,7 +231,7 @@ uint32_t getRawStringSize(const std::string &outStr) bool getRawString(void *data, uint32_t size, uint32_t *offset, std::string &outStr) { -#warning I had to change this. It seems like a bug to not clear the string. Should make sure it's not introducing any side effect. +#warning "I had to change this. It seems like a bug to not clear the string. Should make sure it's not introducing any side effect." outStr.clear(); uint32_t len = 0; diff --git a/libretroshare/src/services/p3banlist.cc b/libretroshare/src/services/p3banlist.cc index 9595510bd..fd4540f0a 100644 --- a/libretroshare/src/services/p3banlist.cc +++ b/libretroshare/src/services/p3banlist.cc @@ -206,27 +206,25 @@ void p3BanList::autoFigureOutBanRanges() { RS_STACK_MUTEX(mBanMtx) ; - bool changed = false ; - // clear automatic ban ranges - for(std::map::iterator it(mBanRanges.begin());it!=mBanRanges.end();) + for(std::map::iterator it(mBanRanges.begin()); + it!=mBanRanges.end(); ) + { if(it->second.reason == RSBANLIST_REASON_AUTO_RANGE) { std::map::iterator it2=it ; ++it2 ; mBanRanges.erase(it) ; it=it2 ; - - changed = true ; } - else - ++it; + else ++it; + } IndicateConfigChanged(); - if(!mAutoRangeIps) - return ; + if(!mAutoRangeIps) return; + #ifdef DEBUG_BANLIST std::cerr << "Automatically figuring out IP ranges from banned IPs." << std::endl; #endif diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index 4590ccdc5..52d25d5e3 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -54,7 +54,7 @@ #define IMAGE_NETWORK2 ":/icons/png/netgraph.png" #define IMAGE_PEERS ":/icons/png/keyring.png" #define IMAGE_IDENTITY ":/images/identity/identities_32.png" -#define IMAGE_CIRCLES ":/icons/png/circles.png" +//#define IMAGE_CIRCLES ":/icons/png/circles.png" /****** * #define FRIENDS_DEBUG 1 diff --git a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp index f9808a4d9..df5442bcd 100644 --- a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp @@ -59,7 +59,7 @@ void GxsMessageFramePostWidget::groupIdChanged() fillComplete(); } -QString GxsMessageFramePostWidget::groupName(bool withUnreadCount) +QString GxsMessageFramePostWidget::groupName(bool /*withUnreadCount*/) { QString name = groupId().isNull () ? tr("No name") : mGroupName; diff --git a/retroshare-nogui/src/TerminalApiClient.cpp b/retroshare-nogui/src/TerminalApiClient.cpp index 6822004b4..6a08218c1 100644 --- a/retroshare-nogui/src/TerminalApiClient.cpp +++ b/retroshare-nogui/src/TerminalApiClient.cpp @@ -246,7 +246,7 @@ void TerminalApiClient::data_tick() if(!ask_for_password && runstate == "waiting_account_select" && last_char >= '0' && last_char <= '9' - && (last_char-'0') < accounts.size()) + && static_cast(last_char-'0') < accounts.size()) { std::string acc = accounts[last_char-'0']; JsonStream reqs;