From 0975d66d2f06603f5e4016440b333aac88e2958a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 24 Sep 2008 03:22:58 +0000 Subject: Ok, now all the warnings are gone (except for those coming from nids, but that's ok, nids is still in flux, they'll be gone soon). --- src/fifo.cpp | 6 +++--- src/fstring.h | 4 ++-- src/hash.h | 14 +++++++++++--- src/list.h | 2 +- src/membuf.cpp | 2 +- src/minimacro.cpp | 8 ++++---- src/minimacro.h | 4 ++-- src/paramproc.cpp | 6 +++--- src/process.cpp | 8 ++++---- src/programchain.cpp | 2 +- src/protocol.cpp | 2 +- src/protocoltelnet.cpp | 2 +- src/protocoltelnet.h | 9 +++++---- src/socket.cpp | 14 +++++++++++--- src/stdstream.cpp | 8 ++++---- src/tafnode.cpp | 4 ++-- src/tafnode.h | 2 +- src/tests/bzip2.cpp | 8 +++++++- src/tests/formula.cpp | 7 +++++++ src/tests/fstring.cpp | 4 +++- src/tests/itoserver.cpp | 4 ++-- src/tests/logger.cpp | 4 ++-- src/tests/mmparse.cpp | 2 +- src/tests/procs.cpp | 2 +- src/tests/telnetsrv.cpp | 4 ++-- src/unitsuite.cpp | 3 ++- 26 files changed, 84 insertions(+), 51 deletions(-) diff --git a/src/fifo.cpp b/src/fifo.cpp index 2321cb6..f909e61 100644 --- a/src/fifo.cpp +++ b/src/fifo.cpp @@ -80,15 +80,15 @@ long Bu::Fifo::tell() return -1; } -void Bu::Fifo::seek( long offset ) +void Bu::Fifo::seek( long ) { } -void Bu::Fifo::setPos( long pos ) +void Bu::Fifo::setPos( long ) { } -void Bu::Fifo::setPosEnd( long pos ) +void Bu::Fifo::setPosEnd( long ) { } diff --git a/src/fstring.h b/src/fstring.h index a9b4c95..b4cae3a 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -138,7 +138,7 @@ namespace Bu { if( !pData ) return; long nLen; - for( nLen = 0; pData[nLen] != (chr)0; nLen++ ); + for( nLen = 0; pData[nLen] != (chr)0; nLen++ ) { } if( nLen == 0 ) return; @@ -220,7 +220,7 @@ namespace Bu if( pData == NULL ) return; long nLen; - for( nLen = 0; pData[nLen] != (chr)0; nLen++ ); + for( nLen = 0; pData[nLen] != (chr)0; nLen++ ) { } Chunk *pNew = newChunk( nLen ); cpy( pNew->pData, pData, nLen ); diff --git a/src/hash.h b/src/hash.h index 25dc509..2810e35 100644 --- a/src/hash.h +++ b/src/hash.h @@ -39,7 +39,7 @@ namespace Bu struct __calcNextTSize_fast { - uint32_t operator()( uint32_t nCapacity, uint32_t nFill, uint32_t nDeleted ) const + uint32_t operator()( uint32_t nCapacity, uint32_t, uint32_t nDeleted ) const { if( nDeleted >= nCapacity/2 ) return nCapacity; @@ -506,7 +506,7 @@ namespace Bu { uint32_t hash = __calcHashCode( k ); bool bFill; - uint32_t nPos = probe( hash, k, bFill, false ); + uint32_t nPos = probe( hash, k, bFill ); if( bFill ) { @@ -533,6 +533,14 @@ namespace Bu return bFill; } + + virtual bool has( key k ) const + { + bool bFill; + probe( __calcHashCode( k ), k, bFill ); + + return bFill; + } /** * Iteration structure for iterating through the hash. @@ -979,7 +987,7 @@ namespace Bu return nCur; } - uint32_t probe( uint32_t hash, key k, bool &bFill, bool rehash=true ) const + uint32_t probe( uint32_t hash, key k, bool &bFill ) const { uint32_t nCur = hash%nCapacity; diff --git a/src/list.h b/src/list.h index 2a40013..e5d7ceb 100644 --- a/src/list.h +++ b/src/list.h @@ -576,7 +576,7 @@ namespace Bu return *pLast->pValue; } - const bool isEmpty() const + bool isEmpty() const { return (nSize == 0); } diff --git a/src/membuf.cpp b/src/membuf.cpp index 459282e..6d850bf 100644 --- a/src/membuf.cpp +++ b/src/membuf.cpp @@ -116,7 +116,7 @@ bool Bu::MemBuf::isBlocking() return true; } -void Bu::MemBuf::setBlocking( bool bBlocking ) +void Bu::MemBuf::setBlocking( bool ) { } diff --git a/src/minimacro.cpp b/src/minimacro.cpp index ecacd79..6fc5382 100644 --- a/src/minimacro.cpp +++ b/src/minimacro.cpp @@ -73,7 +73,7 @@ Bu::FString Bu::MiniMacro::parseRepl() bool bIsFirst = true; for( const char *sNext = sCur;;) { - for(; *sNext != ':' && *sNext != '}' && *sNext != '\0'; sNext++ ); + for(; *sNext != ':' && *sNext != '}' && *sNext != '\0'; sNext++ ) { } if( *sNext == '\0' ) break; Bu::FString sName( sCur, (ptrdiff_t)sNext-(ptrdiff_t)sCur ); @@ -113,7 +113,7 @@ Bu::FString Bu::MiniMacro::parseCmd() { Bu::FString sOut; const char *sNext = sCur; - for(; *sNext != ':' && *sNext != '}' && *sNext != '\0'; sNext++ ); + for(; *sNext != ':' && *sNext != '}' && *sNext != '\0'; sNext++ ) { } if( *sNext != '\0' ) { Bu::FString sName( sCur, (ptrdiff_t)sNext-(ptrdiff_t)sCur ); @@ -149,9 +149,9 @@ Bu::FString Bu::MiniMacro::callFunc( StrList lsParams; for( const char *s = sFunc.getStr()+i+1; *s && *s != ')'; s++ ) { - for(; *s == ' ' || *s == '\t' || *s == '\r' || *s == '\n'; s++ ); + for(; *s == ' ' || *s == '\t' || *s == '\r' || *s == '\n'; s++ ) { } const char *sNext; - for( sNext = s; *sNext && *sNext != ')' && *sNext != ','; sNext++ ); + for( sNext = s; *sNext && *sNext != ')' && *sNext != ','; sNext++ ) { } Bu::FString p( s, (ptrdiff_t)sNext-(ptrdiff_t)s ); lsParams.append( p ); sNext++; diff --git a/src/minimacro.h b/src/minimacro.h index 45a8555..e0765d3 100644 --- a/src/minimacro.h +++ b/src/minimacro.h @@ -103,7 +103,7 @@ namespace Bu FuncToUpper(){} virtual ~FuncToUpper(){} virtual Bu::FString call( - const Bu::FString &sIn, StrList &lsParam ) + const Bu::FString &sIn, StrList & ) { Bu::FString sOut( sIn ); sOut.toUpper(); @@ -117,7 +117,7 @@ namespace Bu FuncToLower(){} virtual ~FuncToLower(){} virtual Bu::FString call( - const Bu::FString &sIn, StrList &lsParam ) + const Bu::FString &sIn, StrList & ) { Bu::FString sOut( sIn ); sOut.toLower(); diff --git a/src/paramproc.cpp b/src/paramproc.cpp index c8e6afd..7aeb819 100644 --- a/src/paramproc.cpp +++ b/src/paramproc.cpp @@ -435,19 +435,19 @@ Bu::ParamProc::ArgSpec *Bu::ParamProc::checkLetr( const char arg ) return NULL; } -int Bu::ParamProc::cmdParam( int argc, char *argv[] ) +int Bu::ParamProc::cmdParam( int /*argc*/, char *argv[] ) { printf("Unhandled command parameter \"%s\" found!\n", argv[0] ); return 0; } -int Bu::ParamProc::unknownParam( int argc, char *argv[] ) +int Bu::ParamProc::unknownParam( int /*argc*/, char *argv[] ) { printf("Unknown parameter \"%s\" found!\n", argv[0] ); return 0; } -int Bu::ParamProc::help( int argc, char *argv[] ) +int Bu::ParamProc::help( int /*argc*/, char * /*argv*/ [] ) { std::list::const_iterator b = lBan.begin(); std::list::const_iterator i; diff --git a/src/process.cpp b/src/process.cpp index 5781600..f04d9fb 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -24,7 +24,7 @@ Bu::Process::Process( const char *sName, const char *argv, ...) int iCnt = 0; va_list ap; va_start( ap, argv ); - for(; va_arg( ap, const char *); iCnt++ ); + for(; va_arg( ap, const char *); iCnt++ ) { } va_end( ap ); char const **list = new char const *[iCnt+2]; @@ -137,15 +137,15 @@ long Bu::Process::tell() return 0; } -void Bu::Process::seek( long offset ) +void Bu::Process::seek( long ) { } -void Bu::Process::setPos( long pos ) +void Bu::Process::setPos( long ) { } -void Bu::Process::setPosEnd( long pos ) +void Bu::Process::setPosEnd( long ) { } diff --git a/src/programchain.cpp b/src/programchain.cpp index d592969..1d005e2 100644 --- a/src/programchain.cpp +++ b/src/programchain.cpp @@ -85,7 +85,7 @@ void Bu::ProgramChain::emergencyShutdown() lLink.clear(); } -LinkMessage *Bu::ProgramChain::broadcastIRM( LinkMessage *pMsgOut, ProgramLink *pSender ) +LinkMessage *Bu::ProgramChain::broadcastIRM( LinkMessage *pMsgOut, ProgramLink * /*pSender*/ ) { for( Bu::List::iterator i = lLink.begin(); i != lLink.end(); i++ ) diff --git a/src/protocol.cpp b/src/protocol.cpp index 83ab4ba..51ff105 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -17,7 +17,7 @@ Bu::Protocol::~Protocol() { } -void Bu::Protocol::onMessage( Bu::Client *pClient, const Bu::FString &sMsg ) +void Bu::Protocol::onMessage( Bu::Client *, const Bu::FString & ) { } diff --git a/src/protocoltelnet.cpp b/src/protocoltelnet.cpp index 504493b..8f8c435 100644 --- a/src/protocoltelnet.cpp +++ b/src/protocoltelnet.cpp @@ -571,7 +571,7 @@ bool Bu::ProtocolTelnet::Option::isLocalSet() return (bool)(fOpts&fLocalIs); } -void Bu::ProtocolTelnet::Option::remoteEnable( bool bSet ) +void Bu::ProtocolTelnet::Option::remoteEnable( bool /*bSet*/ ) { return; } diff --git a/src/protocoltelnet.h b/src/protocoltelnet.h index 59004a0..532db4b 100644 --- a/src/protocoltelnet.h +++ b/src/protocoltelnet.h @@ -88,7 +88,7 @@ namespace Bu * the line or not, the data will be cleared from the buffer when this * function returns, any changes made to the buffer will be destroyed. */ - virtual void gotLine( Bu::FString &sLine ){}; + virtual void gotLine( Bu::FString & /*sLine*/ ){}; /** * Override this function to be notified of any new data that comes in @@ -98,7 +98,7 @@ namespace Bu * child class in this function, the buffer will never be cleared unless * it happens in this function's override. */ - virtual void gotData( Bu::FString &sData ){}; + virtual void gotData( Bu::FString & /*sData*/ ){}; /** * Using this function to enable or disable canonical mode only affects @@ -126,7 +126,7 @@ namespace Bu * If you wish to know the current dimensions of the client window, * override this function, it will be called whenever the size changes. */ - virtual void onSubNAWS( uint16_t iWidth, uint16_t iHeight ){}; + virtual void onSubNAWS( uint16_t /*iWidth*/, uint16_t /*iHeight*/ ){}; /** * This function is called whenever an unknown sub negotiation option is @@ -135,7 +135,8 @@ namespace Bu * can handle it yourself if you'd like. Feel free to change the * sSubBuf, it will be cleared as soon as this function returns anyway. */ - virtual void onSubUnknown( char cSubOpt, Bu::FString &sSubBuf ){}; + virtual void onSubUnknown( char /*cSubOpt*/, + Bu::FString & /*sSubBuf*/ ){}; private: /** diff --git a/src/socket.cpp b/src/socket.cpp index f68fc37..651a2e1 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -260,17 +260,17 @@ long Bu::Socket::tell() throw UnsupportedException(); } -void Bu::Socket::seek( long offset ) +void Bu::Socket::seek( long ) { throw UnsupportedException(); } -void Bu::Socket::setPos( long pos ) +void Bu::Socket::setPos( long ) { throw UnsupportedException(); } -void Bu::Socket::setPosEnd( long pos ) +void Bu::Socket::setPosEnd( long ) { throw UnsupportedException(); } @@ -336,6 +336,14 @@ bool Bu::Socket::isBlocking() void Bu::Socket::setBlocking( bool bBlocking ) { + if( bBlocking ) + { + fcntl( nSocket, F_SETFL, fcntl( nSocket, F_GETFL, 0 ) & ~O_NONBLOCK ); + } + else + { + fcntl( nSocket, F_SETFL, fcntl( nSocket, F_GETFL, 0 ) | O_NONBLOCK ); + } } void Bu::Socket::flush() diff --git a/src/stdstream.cpp b/src/stdstream.cpp index 4bb7b17..844f495 100644 --- a/src/stdstream.cpp +++ b/src/stdstream.cpp @@ -34,15 +34,15 @@ long Bu::StdStream::tell() return 0; } -void Bu::StdStream::seek( long offset ) +void Bu::StdStream::seek( long ) { } -void Bu::StdStream::setPos( long pos ) +void Bu::StdStream::setPos( long ) { } -void Bu::StdStream::setPosEnd( long pos ) +void Bu::StdStream::setPosEnd( long ) { } @@ -91,7 +91,7 @@ bool Bu::StdStream::isBlocking() return true; } -void Bu::StdStream::setBlocking( bool bBlocking ) +void Bu::StdStream::setBlocking( bool ) { } diff --git a/src/tafnode.cpp b/src/tafnode.cpp index bdd96d7..35be4ff 100644 --- a/src/tafnode.cpp +++ b/src/tafnode.cpp @@ -5,7 +5,7 @@ * terms of the license contained in the file LICENSE. */ -#include "tafnode.h" +#include "bu/tafnode.h" Bu::TafNode::TafNode( NodeType eType ) : eType( eType ) @@ -16,7 +16,7 @@ Bu::TafNode::~TafNode() { } -const Bu::TafNode::NodeType Bu::TafNode::getType() const +Bu::TafNode::NodeType Bu::TafNode::getType() const { return eType; } diff --git a/src/tafnode.h b/src/tafnode.h index 9f80781..fcdfdf5 100644 --- a/src/tafnode.h +++ b/src/tafnode.h @@ -33,7 +33,7 @@ namespace Bu TafNode( NodeType eType ); virtual ~TafNode(); - const NodeType getType() const; + NodeType getType() const; private: NodeType eType; diff --git a/src/tests/bzip2.cpp b/src/tests/bzip2.cpp index 88c5a5d..de7c034 100644 --- a/src/tests/bzip2.cpp +++ b/src/tests/bzip2.cpp @@ -10,10 +10,16 @@ int main( int argc, char *argv[] ) { + if( argc < 3 ) + { + printf("usage: %s \n", argv[0] ); + return -1; + } + char buf[1024]; size_t nRead; - Bu::File f( "test.bz2", "wb" ); + Bu::File f( argv[0], "wb" ); Bu::BZip2 bz2( f ); Bu::File fin( argv[1], "rb"); diff --git a/src/tests/formula.cpp b/src/tests/formula.cpp index 635d73f..429c306 100644 --- a/src/tests/formula.cpp +++ b/src/tests/formula.cpp @@ -9,10 +9,17 @@ int main( int argc, char *argv[] ) { + if( argc < 2 ) + { + printf("usage: %s \n", argv[0] ); + return -1; + } Bu::Formula uForm; Bu::Formula dForm; printf("u: %s = %u\n", argv[1], uForm.run( argv[1] ) ); printf("d: %s = %f\n", argv[1], dForm.run( argv[1] ) ); + + return 0; } diff --git a/src/tests/fstring.cpp b/src/tests/fstring.cpp index 6288ccb..b392eb7 100644 --- a/src/tests/fstring.cpp +++ b/src/tests/fstring.cpp @@ -116,7 +116,7 @@ void doTimings() } #define pem printf("---------\n%08tX: %s\n%08tX: %s\n", (ptrdiff_t)str.getStr(), str.getStr(), (ptrdiff_t)str2.getStr(), str2.getStr() ); -int main( int argc, char *argv[] ) +int main( ) { Bu::FString fs1; for( int j = 0; j < 500000; j++ ) fs1 += (char)('a'+(j%26)); @@ -148,5 +148,7 @@ int main( int argc, char *argv[] ) printf("%d == %d\n", Bu::__calcHashCode( str ), Bu::__calcHashCode( str.getStr() ) ); doTimings(); + + return 0; } diff --git a/src/tests/itoserver.cpp b/src/tests/itoserver.cpp index f4ab726..319b11b 100644 --- a/src/tests/itoserver.cpp +++ b/src/tests/itoserver.cpp @@ -24,7 +24,7 @@ public: TRACE(); } - virtual void onNewConnection( Bu::Client *pClient ) + virtual void onNewConnection( Bu::Client * ) { TRACE(); // Huh... @@ -50,7 +50,7 @@ public: TRACE(); } - virtual void onNewConnection( Bu::Client *pClient, int iPort ) + virtual void onNewConnection( Bu::Client *pClient, int ) { TRACE(); pClient->setProtocol( new ProtocolEcho() ); diff --git a/src/tests/logger.cpp b/src/tests/logger.cpp index 71a1ca2..04cefe8 100644 --- a/src/tests/logger.cpp +++ b/src/tests/logger.cpp @@ -17,7 +17,7 @@ class Thing lineLog( 2, "Want a thing?"); } - void go( int i ) + void go( int ) { lineLog( 1, "GO!!!!"); } @@ -32,6 +32,6 @@ int main() logHexDump( 5, "This is a test of the hex-dump facility", 16, "Random stuff"); Thing gh; - gh.go( 6); + gh.go( 6 ); } diff --git a/src/tests/mmparse.cpp b/src/tests/mmparse.cpp index c60aa1c..9b79e4d 100644 --- a/src/tests/mmparse.cpp +++ b/src/tests/mmparse.cpp @@ -8,7 +8,7 @@ #include "bu/minimacro.h" #include "bu/fstring.h" -int main( int argc, char *argv[] ) +int main() { Bu::MiniMacro mm; diff --git a/src/tests/procs.cpp b/src/tests/procs.cpp index c233040..c4b3ebc 100644 --- a/src/tests/procs.cpp +++ b/src/tests/procs.cpp @@ -2,7 +2,7 @@ #include -int main( int agrc, char *argv[] ) +int main() { //Bu::Process p( argv[1], argv+1 ); Bu::Process p("mplayer", "mplayer", "dvd://", "-framedrop", diff --git a/src/tests/telnetsrv.cpp b/src/tests/telnetsrv.cpp index 9fe2881..f9457e2 100644 --- a/src/tests/telnetsrv.cpp +++ b/src/tests/telnetsrv.cpp @@ -57,7 +57,7 @@ public: { } - virtual void onNewConnection( Bu::Client *pClient, int iPort ) + virtual void onNewConnection( Bu::Client *pClient, int ) { printf("New connection.\n"); @@ -75,7 +75,7 @@ private: }; -int main( int argc, char *argv[] ) +int main() { TelServer ts; diff --git a/src/unitsuite.cpp b/src/unitsuite.cpp index 5e59026..0008721 100644 --- a/src/unitsuite.cpp +++ b/src/unitsuite.cpp @@ -21,7 +21,8 @@ Bu::UnitSuite::~UnitSuite() { } -int Bu::UnitSuite::run( int argc, char *argv[] ) +// Argument handling is coming soon, I promise. +int Bu::UnitSuite::run( int /*argc*/, char * /*argv */ [] ) { for( TestList::iterator i = lTests.begin(); i != lTests.end(); i++ ) { -- cgit v1.2.3