Removed some more compiler warnings from Windows compile (GCC 4.4).

Added -Wextra to the Windows compile.
Added new define in libbitdht for snprintf and fprintf to proper handling of "%ll" under Windows.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4951 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-02-17 10:03:38 +00:00
parent 2d2b7230d1
commit 970d88200d
35 changed files with 170 additions and 125 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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<bdNodeId, DhtPeerDetails>::iterator it = mPeers.find(*id);
if (it == mPeers.end())

View file

@ -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),

View file

@ -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
}

View file

@ -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++ )

View file

@ -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);

View file

@ -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;
}

View file

@ -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;

View file

@ -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!";

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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)
{

View file

@ -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,

View file

@ -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)
{

View file

@ -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(