diff --git a/libbitdht/src/bitdht/bdhistory.cc b/libbitdht/src/bitdht/bdhistory.cc index 49a664e1c..637a1ce7d 100644 --- a/libbitdht/src/bitdht/bdhistory.cc +++ b/libbitdht/src/bitdht/bdhistory.cc @@ -36,7 +36,6 @@ void bdMsgHistoryList::printHistory(std::ostream &out, int mode, time_t start_ts sit = msgHistory.lower_bound(start_ts); eit = msgHistory.upper_bound(end_ts); time_t curr_ts = 0; - time_t old_ts = 0; bool time_changed = false; bool first_line = true; @@ -45,7 +44,6 @@ void bdMsgHistoryList::printHistory(std::ostream &out, int mode, time_t start_ts time_changed = false; if (curr_ts != it->first) { - old_ts = curr_ts; curr_ts = it->first; time_changed = true; } diff --git a/libbitdht/src/bitdht/bdmanager.cc b/libbitdht/src/bitdht/bdmanager.cc index e0bb28bec..55030d179 100644 --- a/libbitdht/src/bitdht/bdmanager.cc +++ b/libbitdht/src/bitdht/bdmanager.cc @@ -168,7 +168,7 @@ bool bdNodeManager::setAttachMode(bool on) } /* Friend Tracking */ -void bdNodeManager::addBadPeer(const struct sockaddr_in &addr, uint32_t source, uint32_t reason, uint32_t age) +void bdNodeManager::addBadPeer(const struct sockaddr_in &/*addr*/, uint32_t /*source*/, uint32_t /*reason*/, uint32_t /*age*/) { std::cerr << "bdNodeManager::addBadPeer() not implemented yet!"; std::cerr << std::endl; diff --git a/libbitdht/src/bitdht/bdpeer.cc b/libbitdht/src/bitdht/bdpeer.cc index 3d68dafbb..d5c4eeaa8 100644 --- a/libbitdht/src/bitdht/bdpeer.cc +++ b/libbitdht/src/bitdht/bdpeer.cc @@ -27,6 +27,7 @@ #include "bitdht/bdpeer.h" #include "util/bdnet.h" #include "util/bdrandom.h" +#include "util/bdstring.h" #include "bitdht/bdiface.h" #include @@ -941,13 +942,13 @@ int bdSpace::printDHT() if (size) { if (doPrint) - fprintf(stderr, "Estimated NetSize >> %llu\n", no_nets); + bd_fprintf(stderr, "Estimated NetSize >> %llu\n", no_nets); } else { #ifdef BITDHT_DEBUG if (doPrint) - fprintf(stderr, " Bucket = Net / >> %llu\n", no_nets); + bd_fprintf(stderr, " Bucket = Net / >> %llu\n", no_nets); #endif } } @@ -957,14 +958,14 @@ int bdSpace::printDHT() if (size) { if (doPrint) - fprintf(stderr, "Estimated NetSize = %llu\n", no_peers); + bd_fprintf(stderr, "Estimated NetSize = %llu\n", no_peers); } else { #ifdef BITDHT_DEBUG if (doPrint) - fprintf(stderr, " Bucket = Net / %llu\n", no_nets); + bd_fprintf(stderr, " Bucket = Net / %llu\n", no_nets); #endif } @@ -994,7 +995,7 @@ int bdSpace::printDHT() } else { - fprintf(stderr, "Estimated Network Size = (%llu / %d) = %llu\n", sum, count, sum / count); + bd_fprintf(stderr, "Estimated Network Size = (%llu / %d) = %llu\n", sum, count, sum / count); } return 1; diff --git a/libbitdht/src/bitdht/bdquery.cc b/libbitdht/src/bitdht/bdquery.cc index b3f1624b4..9bcf36525 100644 --- a/libbitdht/src/bitdht/bdquery.cc +++ b/libbitdht/src/bitdht/bdquery.cc @@ -364,7 +364,6 @@ int bdQuery::addClosestPeer(const bdId *id, uint32_t mode) #ifdef DEBUG_QUERY fprintf(stderr, "Dropping Peer that dont reply\n"); #endif - bool removed = false; for(it = mClosest.begin(); it != mClosest.end(); ++it) { time_t sendts = ts - it->second.mLastSendTime; @@ -379,7 +378,6 @@ int bdQuery::addClosestPeer(const bdId *id, uint32_t mode) fprintf(stderr, "\n"); #endif mClosest.erase(it); - removed = true; break ; } } @@ -568,12 +566,10 @@ int bdQuery::updatePotentialPeer(const bdId *id, uint32_t mode, uint32_t addType sit = mPotentialPeers.lower_bound(dist); eit = mPotentialPeers.upper_bound(dist); - bool found = false; for(it = sit; it != eit; it++) { if (mFns->bdSimilarId(id, &(it->second.mPeerId))) { - found = true; it->second.mPeerFlags |= mode; it->second.mLastRecvTime = now; diff --git a/libbitdht/src/bitdht/bdstore.cc b/libbitdht/src/bitdht/bdstore.cc index 10046ba2e..bf51b16f4 100644 --- a/libbitdht/src/bitdht/bdstore.cc +++ b/libbitdht/src/bitdht/bdstore.cc @@ -161,7 +161,6 @@ void bdStore::addStore(bdPeer *peer) #endif /* remove old entry */ - bool removed = false; std::list::iterator it; for(it = store.begin(); it != store.end(); ) @@ -169,7 +168,6 @@ void bdStore::addStore(bdPeer *peer) if ((it->mPeerId.addr.sin_addr.s_addr == peer->mPeerId.addr.sin_addr.s_addr) && (it->mPeerId.addr.sin_port == peer->mPeerId.addr.sin_port)) { - removed = true; #ifdef DEBUG_STORE std::cerr << "bdStore::addStore() Removed Existing Entry: "; mFns->bdPrintId(std::cerr, &(it->mPeerId)); diff --git a/libbitdht/src/bitdht/bencode.c b/libbitdht/src/bitdht/bencode.c index 60bc75660..598dc7615 100644 --- a/libbitdht/src/bitdht/bencode.c +++ b/libbitdht/src/bitdht/bencode.c @@ -22,6 +22,7 @@ #include #include /* malloc() realloc() free() strtoll() */ #include /* memset() */ +#include "util/bdstring.h" #include "bitdht/bencode.h" @@ -425,7 +426,7 @@ int be_encode(be_node *node, char *str, int len) switch (node->type) { case BE_STR: - snprintf(str, len, "%lli:", be_str_len(node)); + bd_snprintf(str, len, "%lli:", be_str_len(node)); loc += strlen(&(str[loc])); memcpy(&(str[loc]), node->val.s, be_str_len(node)); @@ -433,7 +434,7 @@ int be_encode(be_node *node, char *str, int len) break; case BE_INT: - snprintf(str, len, "i%llie", node->val.i); + bd_snprintf(str, len, "i%llie", node->val.i); loc += strlen(&(str[loc])); break; diff --git a/libbitdht/src/libbitdht.pro b/libbitdht/src/libbitdht.pro index c2f6c8874..7b2ab6c79 100644 --- a/libbitdht/src/libbitdht.pro +++ b/libbitdht/src/libbitdht.pro @@ -19,6 +19,10 @@ debug { QMAKE_CXXFLAGS *= -g -fno-omit-frame-pointer } +# treat warnings as error for better removing +#QMAKE_CFLAGS += -Werror +#QMAKE_CXXFLAGS += -Werror + ################################# Linux ########################################## linux-* { DESTDIR = lib @@ -59,6 +63,10 @@ win32 { #DEFINES *= WINDOWS_SYS WIN32 STATICLIB MINGW DESTDIR = lib + # Switch on extra warnings + QMAKE_CFLAGS += -Wextra + QMAKE_CXXFLAGS += -Wextra + # Switch off optimization for release version QMAKE_CXXFLAGS_RELEASE -= -O2 QMAKE_CXXFLAGS_RELEASE += -O0 @@ -107,6 +115,7 @@ HEADERS += \ util/bdnet.h \ util/bdthreads.h \ util/bdrandom.h \ + util/bdstring.h \ udp/udplayer.h \ udp/udpstack.h \ udp/udpbitdht.h \ diff --git a/libbitdht/src/util/bdstring.h b/libbitdht/src/util/bdstring.h new file mode 100644 index 000000000..fc7105d0d --- /dev/null +++ b/libbitdht/src/util/bdstring.h @@ -0,0 +1,35 @@ +#ifndef BITDHT_UTILS_BDSTRING_H +#define BITDHT_UTILS_BDSTRING_H + +/**************************************************************** + * libbitdht is distributed under the following license: + * + * Copyright (C) 2012 RetroShare Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#ifdef WIN32 +// for proper handling of %ll +#define bd_snprintf __mingw_snprintf +#define bd_fprintf __mingw_fprintf +#else +#define bd_snprintf snprintf +#define bd_fprintf fprintf +#endif + + +#endif diff --git a/libretroshare/src/dht/p3bitdht.h b/libretroshare/src/dht/p3bitdht.h index 969639241..bc7ad3b56 100644 --- a/libretroshare/src/dht/p3bitdht.h +++ b/libretroshare/src/dht/p3bitdht.h @@ -343,9 +343,9 @@ int addKnownNode(const bdId *id, uint32_t flags); private: -DhtPeerDetails *addInternalPeer_locked(const std::string pid, int type); +DhtPeerDetails *addInternalPeer_locked(const std::string pid, uint32_t type); int removeInternalPeer_locked(const std::string pid); -DhtPeerDetails *findInternalDhtPeer_locked(const bdNodeId *id, int type); +DhtPeerDetails *findInternalDhtPeer_locked(const bdNodeId *id, uint32_t type); DhtPeerDetails *findInternalRsPeer_locked(const std::string &pid); bool havePeerTranslation_locked(const std::string &pid); diff --git a/libretroshare/src/dht/p3bitdht_peernet.cc b/libretroshare/src/dht/p3bitdht_peernet.cc index d7f6e6513..448382f0b 100644 --- a/libretroshare/src/dht/p3bitdht_peernet.cc +++ b/libretroshare/src/dht/p3bitdht_peernet.cc @@ -46,7 +46,7 @@ * -> do we care if we know them? not really! */ -int p3BitDht::InfoCallback(const bdId *id, uint32_t type, uint32_t flags, std::string info) +int p3BitDht::InfoCallback(const bdId *id, uint32_t /*type*/, uint32_t /*flags*/, std::string /*info*/) { /* translate info */ std::string rsid; @@ -1893,7 +1893,7 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const std::cerr << std::endl; #endif - uint32_t touConnectMode = 0; +// uint32_t touConnectMode = 0; std::string rsId; { @@ -1923,7 +1923,7 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const { default: case BITDHT_CONNECT_MODE_DIRECT: - touConnectMode = RSDHT_TOU_MODE_DIRECT; +// touConnectMode = RSDHT_TOU_MODE_DIRECT; connectFlags |= RS_CB_FLAG_MODE_UDP_DIRECT; delay = delayOrBandwidth; break; @@ -1941,12 +1941,12 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const delay = delayOrBandwidth; if (useProxyPort) { - touConnectMode = RSDHT_TOU_MODE_PROXY; +// touConnectMode = RSDHT_TOU_MODE_PROXY; connectFlags |= RS_CB_FLAG_MODE_UDP_PROXY; } else { - touConnectMode = RSDHT_TOU_MODE_DIRECT; +// touConnectMode = RSDHT_TOU_MODE_DIRECT; connectFlags |= RS_CB_FLAG_MODE_UDP_DIRECT; } @@ -1954,7 +1954,7 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const break; case BITDHT_CONNECT_MODE_RELAY: - touConnectMode = RSDHT_TOU_MODE_RELAY; +// touConnectMode = RSDHT_TOU_MODE_RELAY; connectFlags |= RS_CB_FLAG_MODE_UDP_RELAY; bandwidth = delayOrBandwidth; break; diff --git a/libretroshare/src/dht/p3bitdht_peers.cc b/libretroshare/src/dht/p3bitdht_peers.cc index c3f5622c9..c16a742a9 100644 --- a/libretroshare/src/dht/p3bitdht_peers.cc +++ b/libretroshare/src/dht/p3bitdht_peers.cc @@ -184,7 +184,7 @@ bool p3BitDht::dropPeer(std::string pid) ********************************* Basic Peer Details ************************************* ******************************************************************************************/ -int p3BitDht::addBadPeer(const struct sockaddr_in &addr, uint32_t reason, uint32_t flags, uint32_t age) +int p3BitDht::addBadPeer(const struct sockaddr_in &addr, uint32_t /*reason*/, uint32_t /*flags*/, uint32_t /*age*/) { //mUdpBitDht->updateKnownPeer(&id, 0, bdflags); @@ -359,7 +359,7 @@ int p3BitDht::removePeer(const std::string pid) ********************************* Basic Peer Details ************************************* ******************************************************************************************/ -DhtPeerDetails *p3BitDht::addInternalPeer_locked(const std::string pid, int type) +DhtPeerDetails *p3BitDht::addInternalPeer_locked(const std::string pid, uint32_t type) { /* create the data structure */ if (!havePeerTranslation_locked(pid)) @@ -417,7 +417,7 @@ int p3BitDht::removeInternalPeer_locked(const std::string pid) /* indexed by bdNodeId, as this is the more used call interface */ -DhtPeerDetails *p3BitDht::findInternalDhtPeer_locked(const bdNodeId *id, int type) +DhtPeerDetails *p3BitDht::findInternalDhtPeer_locked(const bdNodeId *id, uint32_t type) { std::map::iterator it = mPeers.find(*id); if (it == mPeers.end()) diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index 18757ba8e..c45ee7201 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -66,13 +66,13 @@ * #define DEBUG_DWLQUEUE 1 *****/ -static const uint32_t SAVE_TRANSFERS_DELAY = 61 ; // save transfer progress every 61 seconds. -static const uint32_t INACTIVE_CHUNKS_CHECK_DELAY = 240 ; // time after which an inactive chunk is released -static const uint32_t MAX_TIME_INACTIVE_REQUEUED = 120 ; // time after which an inactive ftFileControl is bt-queued -static const uint32_t TIMOUT_CACHE_FILE_TRANSFER = 800 ; // time after which cache transfer gets cancelled if inactive. +static const int32_t SAVE_TRANSFERS_DELAY = 61 ; // save transfer progress every 61 seconds. +static const int32_t INACTIVE_CHUNKS_CHECK_DELAY = 240 ; // time after which an inactive chunk is released +static const int32_t MAX_TIME_INACTIVE_REQUEUED = 120 ; // time after which an inactive ftFileControl is bt-queued +static const int32_t TIMOUT_CACHE_FILE_TRANSFER = 800 ; // time after which cache transfer gets cancelled if inactive. -static const uint32_t FT_FILECONTROL_QUEUE_ADD_END = 0 ; -static const uint32_t FT_FILECONTROL_QUEUE_ADD_AFTER_CACHE = 1 ; +static const int32_t FT_FILECONTROL_QUEUE_ADD_END = 0 ; +static const int32_t FT_FILECONTROL_QUEUE_ADD_AFTER_CACHE = 1 ; ftFileControl::ftFileControl() :mTransfer(NULL), mCreator(NULL), diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 952efd482..994514cee 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -28,7 +28,9 @@ release { #DEFINES *= PQI_DISABLE_UDP } - +# treat warnings as error for better removing +#QMAKE_CFLAGS += -Werror +#QMAKE_CXXFLAGS += -Werror testnetwork { # used in rsserver/rsinit.cc Enabled Port Restrictions, and makes Proxy Port next to Dht Port. @@ -262,40 +264,44 @@ win32-x-g++ { win32 { - QMAKE_CC = g++ - OBJECTS_DIR = temp/obj - MOC_DIR = temp/moc - DEFINES *= WINDOWS_SYS WIN32 STATICLIB MINGW - DEFINES *= MINIUPNPC_VERSION=13 - DESTDIR = lib + QMAKE_CC = g++ + OBJECTS_DIR = temp/obj + MOC_DIR = temp/moc + DEFINES *= WINDOWS_SYS WIN32 STATICLIB MINGW + DEFINES *= MINIUPNPC_VERSION=13 + DESTDIR = lib - # Switch off optimization for release version - QMAKE_CXXFLAGS_RELEASE -= -O2 - QMAKE_CXXFLAGS_RELEASE += -O0 - QMAKE_CFLAGS_RELEASE -= -O2 - QMAKE_CFLAGS_RELEASE += -O0 + # Switch on extra warnings + QMAKE_CFLAGS += -Wextra + QMAKE_CXXFLAGS += -Wextra - # Switch on optimization for debug version - #QMAKE_CXXFLAGS_DEBUG += -O2 - #QMAKE_CFLAGS_DEBUG += -O2 + # Switch off optimization for release version + QMAKE_CXXFLAGS_RELEASE -= -O2 + QMAKE_CXXFLAGS_RELEASE += -O0 + QMAKE_CFLAGS_RELEASE -= -O2 + QMAKE_CFLAGS_RELEASE += -O0 - DEFINES += USE_CMD_ARGS + # Switch on optimization for debug version + #QMAKE_CXXFLAGS_DEBUG += -O2 + #QMAKE_CFLAGS_DEBUG += -O2 - #miniupnp implementation files - HEADERS += upnp/upnputil.h - SOURCES += upnp/upnputil.c + DEFINES += USE_CMD_ARGS + + #miniupnp implementation files + HEADERS += upnp/upnputil.h + SOURCES += upnp/upnputil.c - UPNPC_DIR = ../../../../miniupnpc-1.3 - GPG_ERROR_DIR = ../../../../libgpg-error-1.7 - GPGME_DIR = ../../../../gpgme-1.1.8 + UPNPC_DIR = ../../../../miniupnpc-1.3 + GPG_ERROR_DIR = ../../../../libgpg-error-1.7 + GPGME_DIR = ../../../../gpgme-1.1.8 - PTHREADS_DIR = ../../../../pthreads-w32-2-8-0-release - ZLIB_DIR = ../../../../zlib-1.2.3 - SSL_DIR = ../../../../OpenSSL + PTHREADS_DIR = ../../../../pthreads-w32-2-8-0-release + ZLIB_DIR = ../../../../zlib-1.2.3 + SSL_DIR = ../../../../OpenSSL - INCLUDEPATH += . $${SSL_DIR}/include $${UPNPC_DIR} $${PTHREADS_DIR} $${ZLIB_DIR} $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src + INCLUDEPATH += . $${SSL_DIR}/include $${UPNPC_DIR} $${PTHREADS_DIR} $${ZLIB_DIR} $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src } diff --git a/libretroshare/src/plugins/dlfcn_win32.cc b/libretroshare/src/plugins/dlfcn_win32.cc index 58aa8ffb1..c7ce8f70e 100644 --- a/libretroshare/src/plugins/dlfcn_win32.cc +++ b/libretroshare/src/plugins/dlfcn_win32.cc @@ -197,7 +197,7 @@ void *dlopen( const char *file, int mode ) else { char lpFileName[MAX_PATH]; - int i; + unsigned int i; /* MSDN says backslashes *must* be used instead of forward slashes. */ for( i = 0 ; i < sizeof(lpFileName)-1 ; i++ ) diff --git a/libretroshare/src/pqi/p3cfgmgr.cc b/libretroshare/src/pqi/p3cfgmgr.cc index 36f33288b..a1965a30f 100644 --- a/libretroshare/src/pqi/p3cfgmgr.cc +++ b/libretroshare/src/pqi/p3cfgmgr.cc @@ -329,10 +329,10 @@ bool p3ConfigMgr::backedUpFileSave(const std::string& fname, const std::string& return true; } - if(size_file != fwrite(config_buff,1, size_file, file)) + if(size_file != (int) fwrite(config_buff,1, size_file, file)) getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "Write error", "Error while writing backup configuration file " + fname_backup + "\nIs your disc full or out of quota ?"); - if(size_sign != fwrite(sign_buff, 1, size_sign, sign)) + if(size_sign != (int) fwrite(sign_buff, 1, size_sign, sign)) getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "Write error", "Error while writing main signature file " + sign_fname_backup + "\nIs your disc full or out of quota ?"); fclose(file); @@ -1124,7 +1124,7 @@ bool p3Config::backedUpFileSave(const std::string& cfg_fname, const std::string& #endif } - if(size_file != fwrite(buff, 1, size_file, cfg_file)) + if(size_file != (int) fwrite(buff, 1, size_file, cfg_file)) { getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "Write error", "Error while writing backup configuration file " + cfg_fname_backup + "\nIs your disc full or out of quota ?"); fclose(cfg_file); diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index c62198aba..a5e55d6ac 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -270,7 +270,7 @@ bool p3PeerMgrIMPL::getGpgId(const std::string &ssl_id, std::string &gpgId) } // Placeholder until we implement this functionality. -uint32_t p3PeerMgrIMPL::getConnectionType(const std::string &sslId) +uint32_t p3PeerMgrIMPL::getConnectionType(const std::string &/*sslId*/) { return RS_NET_CONN_TYPE_FRIEND; } diff --git a/libretroshare/src/pqi/pqiarchive.cc b/libretroshare/src/pqi/pqiarchive.cc index 71deff4bf..54354fe93 100644 --- a/libretroshare/src/pqi/pqiarchive.cc +++ b/libretroshare/src/pqi/pqiarchive.cc @@ -351,7 +351,7 @@ int pqiarchive::writePkt(RsItem *pqi) out << "Writing Pkt Body" << std::endl; // write packet. - if (len != bio->senddata(ptr, len)) + if ((int) len != bio->senddata(ptr, len)) { out << "Problems with Send Data!"; out << std::endl; diff --git a/libretroshare/src/pqi/pqistore.cc b/libretroshare/src/pqi/pqistore.cc index bed3d33a5..8c07e04be 100644 --- a/libretroshare/src/pqi/pqistore.cc +++ b/libretroshare/src/pqi/pqistore.cc @@ -294,7 +294,7 @@ int pqistore::writePkt(RsItem *pqi) out << "Writing Pkt Body" << std::endl; #endif // write packet. - if (len != bio->senddata(ptr, len)) + if (len != (uint32_t) bio->senddata(ptr, len)) { #ifdef PQISTORE_DEBUG out << "Problems with Send Data!"; diff --git a/libretroshare/src/services/p3banlist.cc b/libretroshare/src/services/p3banlist.cc index ce99d00f2..52beb6ecd 100644 --- a/libretroshare/src/services/p3banlist.cc +++ b/libretroshare/src/services/p3banlist.cc @@ -143,7 +143,7 @@ bool p3BanList::recvBanItem(RsBanListItem *item) } /* overloaded from pqiNetAssistSharePeer */ -void p3BanList::updatePeer(std::string id, struct sockaddr_in addr, int type, int reason, int age) +void p3BanList::updatePeer(std::string /*id*/, struct sockaddr_in addr, int /*type*/, int /*reason*/, int age) { std::string ownId = mLinkMgr->getOwnId(); @@ -160,7 +160,7 @@ void p3BanList::updatePeer(std::string id, struct sockaddr_in addr, int type, in } -bool p3BanList::addBanEntry(const std::string &peerId, const struct sockaddr_in &addr, uint32_t level, uint32_t reason, uint32_t age) +bool p3BanList::addBanEntry(const std::string &peerId, const struct sockaddr_in &addr, int level, uint32_t reason, uint32_t age) { RsStackMutex stack(mBanMtx); /****** LOCKED MUTEX *******/ @@ -217,7 +217,7 @@ bool p3BanList::addBanEntry(const std::string &peerId, const struct sockaddr_in /* see if it needs an update */ if ((mit->second.reason != reason) || (mit->second.level != level) || - (mit->second.mTs < now - age)) + (mit->second.mTs < (time_t) (now - age))) { /* update */ mit->second.addr = addr; diff --git a/libretroshare/src/services/p3banlist.h b/libretroshare/src/services/p3banlist.h index 0ba5bbbd3..56d3651d3 100644 --- a/libretroshare/src/services/p3banlist.h +++ b/libretroshare/src/services/p3banlist.h @@ -94,7 +94,7 @@ class p3BanList: /* public RsBanList, */ public p3Service, public pqiNetAssistPe bool recvBanItem(RsBanListItem *item); bool addBanEntry(const std::string &peerId, const struct sockaddr_in &addr, - uint32_t level, uint32_t reason, uint32_t age); + int level, uint32_t reason, uint32_t age); void sendBanLists(); int sendBanSet(std::string peerid); diff --git a/libretroshare/src/services/p3chatservice.cc b/libretroshare/src/services/p3chatservice.cc index 1cb4bc248..7d9223489 100644 --- a/libretroshare/src/services/p3chatservice.cc +++ b/libretroshare/src/services/p3chatservice.cc @@ -708,7 +708,7 @@ void p3ChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *item) std::cerr << "Received ChatLobbyEvent item of type " << (int)(item->event_type) << ", and string=" << item->string1 << std::endl; #endif - if(time(NULL)+100 > item->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep minus 100 seconds ! It's too old, and is going to make an echo! + if(time(NULL)+100 > (time_t) item->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep minus 100 seconds ! It's too old, and is going to make an echo! { std::cerr << "Received severely outdated lobby event item! Dropping it!" << std::endl; std::cerr << "Message item is:" << std::endl; @@ -820,7 +820,7 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *ci) return true ; } - if(now+100 > cli->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep plus 100 seconds ! It's too old, and is going to make an echo! + if(now+100 > (time_t) cli->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep plus 100 seconds ! It's too old, and is going to make an echo! { std::cerr << "Received severely outdated message!Dropping it!" << std::endl; std::cerr << "Message item is:" << std::endl; diff --git a/libretroshare/src/tcponudp/tou.cc b/libretroshare/src/tcponudp/tou.cc index 3e5f05dcc..9ea873ba9 100644 --- a/libretroshare/src/tcponudp/tou.cc +++ b/libretroshare/src/tcponudp/tou.cc @@ -95,7 +95,7 @@ int tou_init(void **in_udpsubrecvs, int *type, int number) } noUdpSR = number; - int i; + uint32_t i; for(i = 0; i < noUdpSR; i++) { udpSR[i] = usrArray[i]; @@ -110,7 +110,7 @@ int tou_init(void **in_udpsubrecvs, int *type, int number) /* open - allocates a sockfd, and checks that the type is okay */ -int tou_socket(int recvIdx, int type, int /*protocol*/) +int tou_socket(uint32_t recvIdx, uint32_t type, int /*protocol*/) { if (!tou_inited) { diff --git a/libretroshare/src/tcponudp/tou.h b/libretroshare/src/tcponudp/tou.h index 905c7387b..0c2522764 100644 --- a/libretroshare/src/tcponudp/tou.h +++ b/libretroshare/src/tcponudp/tou.h @@ -104,7 +104,7 @@ int tou_init(void **udpSubRecvs, int *udpTypes, int nUdps); */ /* creation/connections */ -int tou_socket(int domain, int type, int protocol); +int tou_socket(uint32_t domain, uint32_t type, int protocol); int tou_bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen); /* null op now */ int tou_listen(int sockfd, int backlog); /* null op now */ int tou_connect(int sockfd, const struct sockaddr *serv_addr, diff --git a/libretroshare/src/tcponudp/udpstunner.cc b/libretroshare/src/tcponudp/udpstunner.cc index eeb386a53..3f5cea0fb 100644 --- a/libretroshare/src/tcponudp/udpstunner.cc +++ b/libretroshare/src/tcponudp/udpstunner.cc @@ -41,9 +41,9 @@ static const int STUN_TTL = 64; //#define DEBUG_UDP_STUNNER 1 -const int32_t TOU_STUN_MAX_FAIL_COUNT = 3; /* 3 tries (could be higher?) */ +const uint32_t TOU_STUN_MAX_FAIL_COUNT = 3; /* 3 tries (could be higher?) */ const int32_t TOU_STUN_MAX_SEND_RATE = 5; /* every 5 seconds */ -const int32_t TOU_STUN_MAX_RECV_RATE = 25; /* every 25 seconds */ +const uint32_t TOU_STUN_MAX_RECV_RATE = 25; /* every 25 seconds */ // TIMEOUT is now tied to STUN RATE ... const int32_t TOU_STUN_ADDR_MAX_AGE = 120; /* 2 minutes */ const int32_t TOU_STUN_DEFAULT_TARGET_RATE = 15; /* 20 secs is minimum to keep a NAT UDP port open */ @@ -384,7 +384,7 @@ bool UdpStunner::externalAddr(struct sockaddr_in &external, uint8_t &stable) /* address timeout * no timeout if in exclusive mode */ - if ((time(NULL) - eaddrTime > (mTargetStunPeriod * 2)) && (!mExclusiveMode)) + if ((time(NULL) - eaddrTime > (long) (mTargetStunPeriod * 2)) && (!mExclusiveMode)) { std::cerr << "UdpStunner::externalAddr() eaddr expired"; std::cerr << std::endl; @@ -839,7 +839,7 @@ bool UdpStunner::attemptStun() { RsStackMutex stack(stunMtx); /********** LOCK MUTEX *********/ - int i; + size_t i; for(i = 0; ((i < mStunList.size()) && (mStunList.size() > 0) && (!found)); i++) { /* extract entry */ @@ -1053,7 +1053,7 @@ bool UdpStunner::locked_checkExternalAddress() #else (isExternalNet(&(it->eaddr.sin_addr))) && #endif - (it->failCount == 0) && (age < (mTargetStunPeriod * 2))) + (it->failCount == 0) && (age < (long) (mTargetStunPeriod * 2))) { if (!found1) { diff --git a/libretroshare/src/upnp/UPnPBase.cpp b/libretroshare/src/upnp/UPnPBase.cpp index d8dc401ae..e4fb6ca9c 100644 --- a/libretroshare/src/upnp/UPnPBase.cpp +++ b/libretroshare/src/upnp/UPnPBase.cpp @@ -955,6 +955,9 @@ m_WanService(NULL) #ifdef UPNP_DEBUG std::cerr << "UPnPControlPoint::CUPnPControlPoint() bound to " << ipAddress << ":" << port << "." << std::endl; +#else + // unused variable + (void)port; #endif ret = UpnpRegisterClient( diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 3f1edc905..b69502e70 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -22,6 +22,10 @@ minimal { DEFINES += MINIMAL_RSGUI } +# treat warnings as error for better removing +#QMAKE_CFLAGS += -Werror +#QMAKE_CXXFLAGS += -Werror + ################################# Linux ########################################## # Put lib dir in QMAKE_LFLAGS so it appears before -L/usr/lib linux-* { @@ -91,36 +95,40 @@ win32-x-g++ { #################################### Windows ##################################### win32 { - # Switch off optimization for release version - QMAKE_CXXFLAGS_RELEASE -= -O2 - QMAKE_CXXFLAGS_RELEASE += -O0 - QMAKE_CFLAGS_RELEASE -= -O2 - QMAKE_CFLAGS_RELEASE += -O0 + # Switch on extra warnings + QMAKE_CFLAGS += -Wextra + QMAKE_CXXFLAGS += -Wextra - # Switch on optimization for debug version - #QMAKE_CXXFLAGS_DEBUG += -O2 - #QMAKE_CFLAGS_DEBUG += -O2 + # Switch off optimization for release version + QMAKE_CXXFLAGS_RELEASE -= -O2 + QMAKE_CXXFLAGS_RELEASE += -O0 + QMAKE_CFLAGS_RELEASE -= -O2 + QMAKE_CFLAGS_RELEASE += -O0 - OBJECTS_DIR = temp/obj - #LIBS += -L"D/Qt/2009.03/qt/plugins/imageformats" - #QTPLUGIN += qjpeg + # Switch on optimization for debug version + #QMAKE_CXXFLAGS_DEBUG += -O2 + #QMAKE_CFLAGS_DEBUG += -O2 - PRE_TARGETDEPS += ../../libretroshare/src/lib/libretroshare.a + OBJECTS_DIR = temp/obj + #LIBS += -L"D/Qt/2009.03/qt/plugins/imageformats" + #QTPLUGIN += qjpeg - LIBS += ../../libretroshare/src/lib/libretroshare.a - LIBS += -L"../../../../lib" - LIBS += -lssl -lcrypto -lgpgme -lpthreadGC2d -lminiupnpc -lz + PRE_TARGETDEPS += ../../libretroshare/src/lib/libretroshare.a + + LIBS += ../../libretroshare/src/lib/libretroshare.a + LIBS += -L"../../../../lib" + LIBS += -lssl -lcrypto -lgpgme -lpthreadGC2d -lminiupnpc -lz # added after bitdht # LIBS += -lws2_32 - LIBS += -luuid -lole32 -liphlpapi -lcrypt32-cygwin -lgdi32 - LIBS += -lole32 -lwinmm - RC_FILE = gui/images/retroshare_win.rc + LIBS += -luuid -lole32 -liphlpapi -lcrypt32-cygwin -lgdi32 + LIBS += -lole32 -lwinmm + RC_FILE = gui/images/retroshare_win.rc - DEFINES += WINDOWS_SYS + DEFINES += WINDOWS_SYS - GPG_ERROR_DIR = ../../../../libgpg-error-1.7 - GPGME_DIR = ../../../../gpgme-1.1.8 - INCLUDEPATH += . $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src + GPG_ERROR_DIR = ../../../../libgpg-error-1.7 + GPGME_DIR = ../../../../gpgme-1.1.8 + INCLUDEPATH += . $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src } ##################################### MacOS ###################################### diff --git a/retroshare-gui/src/gui/AboutDialog.cpp b/retroshare-gui/src/gui/AboutDialog.cpp index f9eed23fe..39f8174e5 100644 --- a/retroshare-gui/src/gui/AboutDialog.cpp +++ b/retroshare-gui/src/gui/AboutDialog.cpp @@ -285,13 +285,13 @@ void AWidget::addBlob(int x, int y, int radius, int height) { // Set up the pointers int *newptr; - int *oldptr; +// int *oldptr; if (page == 0) { newptr = &heightField1.front(); - oldptr = &heightField2.front(); +// oldptr = &heightField2.front(); } else { newptr = &heightField2.front(); - oldptr = &heightField1.front(); +// oldptr = &heightField1.front(); } int rquad = radius * radius; diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 983e5f77b..f15d7a243 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -31,7 +31,7 @@ #define IMAGE_UNSUBSCRIBE "" ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WFlags flags) - : RsAutoUpdatePage(5000,parent) + : RsAutoUpdatePage(5000, parent, flags) { setupUi(this); @@ -330,7 +330,7 @@ void ChatLobbyWidget::unsubscribeItem() rsMsgs->unsubscribeChatLobby(id); } -void ChatLobbyWidget::itemDoubleClicked(QTreeWidgetItem *item, int column) +void ChatLobbyWidget::itemDoubleClicked(QTreeWidgetItem *item, int /*column*/) { subscribeLobby(item); } diff --git a/retroshare-gui/src/gui/RsAutoUpdatePage.cpp b/retroshare-gui/src/gui/RsAutoUpdatePage.cpp index d7a12702d..de1e7c1af 100644 --- a/retroshare-gui/src/gui/RsAutoUpdatePage.cpp +++ b/retroshare-gui/src/gui/RsAutoUpdatePage.cpp @@ -4,8 +4,8 @@ bool RsAutoUpdatePage::_locked = false ; -RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period,QWidget *parent) - : MainPage(parent) +RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period, QWidget *parent, Qt::WindowFlags flags) + : MainPage(parent, flags) { _timer = new QTimer ; _timer->setInterval(ms_update_period); diff --git a/retroshare-gui/src/gui/RsAutoUpdatePage.h b/retroshare-gui/src/gui/RsAutoUpdatePage.h index 2116a7200..6bb5513fc 100644 --- a/retroshare-gui/src/gui/RsAutoUpdatePage.h +++ b/retroshare-gui/src/gui/RsAutoUpdatePage.h @@ -18,7 +18,7 @@ class RsAutoUpdatePage: public MainPage Q_OBJECT public: - RsAutoUpdatePage(int ms_update_period = 1000,QWidget *parent=NULL) ; + RsAutoUpdatePage(int ms_update_period = 1000, QWidget *parent = NULL, Qt::WindowFlags flags = 0) ; virtual ~RsAutoUpdatePage() ; virtual void updateDisplay() {} diff --git a/retroshare-gui/src/gui/chat/ChatDialog.h b/retroshare-gui/src/gui/chat/ChatDialog.h index 625c80dbd..8c27786c2 100644 --- a/retroshare-gui/src/gui/chat/ChatDialog.h +++ b/retroshare-gui/src/gui/chat/ChatDialog.h @@ -41,7 +41,7 @@ public: static void closeChat(const std::string &peerId); static void chatChanged(int list, int type); - virtual void showDialog(uint chatflags) {} + virtual void showDialog(uint /*chatflags*/) {} virtual ChatWidget *getChatWidget() = 0; virtual bool hasPeerStatus() = 0; @@ -79,7 +79,7 @@ protected: virtual bool canClose() { return true; } virtual void init(const std::string &peerId, const QString &title); - virtual void onChatChanged(int list, int type) {} + virtual void onChatChanged(int /*list*/, int /*type*/) {} virtual void addIncomingChatMsg(const ChatInfo& info) = 0; diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp index 33897b9e8..2db434077 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp @@ -297,7 +297,7 @@ void PopupChatWindow::getAvatar() } } -void PopupChatWindow::tabClosed(ChatDialog *dialog) +void PopupChatWindow::tabClosed(ChatDialog */*dialog*/) { if (tabbedWindow) { if (ui.tabWidget->count() == 0) { diff --git a/retroshare-gui/src/gui/mainpage.h b/retroshare-gui/src/gui/mainpage.h index 7a966a5b5..0d5eef842 100644 --- a/retroshare-gui/src/gui/mainpage.h +++ b/retroshare-gui/src/gui/mainpage.h @@ -30,7 +30,7 @@ class MainPage : public QWidget { public: /** Default Constructor */ - MainPage(QWidget *parent = 0) : QWidget(parent) {} + MainPage(QWidget *parent = 0, Qt::WindowFlags flags = 0) : QWidget(parent, flags) {} virtual void retranslateUi() {} }; diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index adf1f191b..edcb4308a 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -446,13 +446,6 @@ void NotifyQt::notifyListPreChange(int list, int /*type*/) void NotifyQt::UpdateGUI() { #ifndef MINIMAL_RSGUI - /* hack to force updates until we've fixed that part */ - static time_t lastTs = 0; - -// std::cerr << "Got update signal t=" << lastTs << std::endl ; - - lastTs = time(NULL) ; - static bool already_updated = false ; // these only update once at start because they may already have been set before // the gui is running, then they get updated by callbacks. if(!already_updated) @@ -656,9 +649,6 @@ void NotifyQt::runningTick() { // QMutexLocker lock(&runningToasterMutex); - QDesktopWidget *desktop = QApplication::desktop(); - QRect desktopGeometry = desktop->availableGeometry(desktop->primaryScreen()); - int interval = runningToasterTimer->interval(); QPoint diff; diff --git a/retroshare-gui/src/gui/settings/RelayPage.cpp b/retroshare-gui/src/gui/settings/RelayPage.cpp index 6864b66db..51a58989e 100644 --- a/retroshare-gui/src/gui/settings/RelayPage.cpp +++ b/retroshare-gui/src/gui/settings/RelayPage.cpp @@ -61,7 +61,7 @@ RelayPage::RelayPage(QWidget * parent, Qt::WFlags flags) } /** Saves the changes on this page */ -bool RelayPage::save(QString &errmsg) +bool RelayPage::save(QString &/*errmsg*/) { int nFriends = ui.noFriendSpinBox->value();