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

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

View file

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

View file

@ -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 <stdlib.h>
@ -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;

View file

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

View file

@ -161,7 +161,6 @@ void bdStore::addStore(bdPeer *peer)
#endif
/* remove old entry */
bool removed = false;
std::list<bdPeer>::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));

View file

@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h> /* malloc() realloc() free() strtoll() */
#include <string.h> /* 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;

View file

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

View file

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