diff --git a/bson/bson-inl.h b/bson/bson-inl.h index 5b4c490ea74..b14441a527e 100644 --- a/bson/bson-inl.h +++ b/bson/bson-inl.h @@ -398,7 +398,7 @@ namespace mongo { break; case RegEx: { const char *p = value(); - size_t len1 = ( maxLen == -1 ) ? strlen( p ) : mongo::strnlen( p, remain ); + size_t len1 = ( maxLen == -1 ) ? strlen( p ) : (size_t)mongo::strnlen( p, remain ); //massert( 10318 , "Invalid regex string", len1 != -1 ); // ERH - 4/28/10 - don't think this does anything p = p + len1 + 1; size_t len2; diff --git a/client/distlock_test.cpp b/client/distlock_test.cpp index 3f4164e81ec..0c00bb46e56 100644 --- a/client/distlock_test.cpp +++ b/client/distlock_test.cpp @@ -213,11 +213,11 @@ namespace mongo { log() << "Initializing lock with skew of " << skew << " for thread " << threadId << endl; - lock.reset(new DistributedLock(hostConn, lockName, legacy ? takeoverMins : takeoverMS, true, legacy)); + lock.reset(new DistributedLock(hostConn, lockName, legacy ? (unsigned long long)takeoverMins : takeoverMS, true, legacy)); log() << "Skewed time " << jsTime() << " for thread " << threadId << endl << " max wait (with lock: " << threadWait << ", after lock: " << threadSleep << ")" << endl - << " takeover in " << (legacy ? takeoverMins : takeoverMS) << (legacy ? " (mins local)" : "(ms remote)") << endl; + << " takeover in " << (legacy ? (unsigned long long)takeoverMins : takeoverMS) << (legacy ? " (mins local)" : "(ms remote)") << endl; } @@ -267,7 +267,7 @@ namespace mongo { result << "errors" << errors << "skew" << skew - << "takeover" << (long long) (legacy ? takeoverMS : takeoverMins) + << "takeover" << (long long) (legacy ? takeoverMS : (unsigned long long)takeoverMins) << "localTimeout" << (takeoverMS > 0); } diff --git a/db/query.cpp b/db/query.cpp index df09fcec51c..003ac6f3976 100644 --- a/db/query.cpp +++ b/db/query.cpp @@ -1108,7 +1108,7 @@ namespace mongo { qr->startingFrom = 0; qr->nReturned = n; result.setData( qr.release(), true ); - return false; + return NULL; } } diff --git a/db/repl/rs.h b/db/repl/rs.h index fc1a49a169a..4d87cc63af0 100644 --- a/db/repl/rs.h +++ b/db/repl/rs.h @@ -134,6 +134,7 @@ namespace mongo { log() << "replSet ~RSBase called" << rsLog; } + public: class lock { RSBase& rsbase; auto_ptr sl; @@ -157,7 +158,6 @@ namespace mongo { } }; - public: /* for asserts */ bool locked() const { return _locked != 0; } diff --git a/db/repl/rs_config.cpp b/db/repl/rs_config.cpp index 02b3e6b9506..5603bfc5e08 100644 --- a/db/repl/rs_config.cpp +++ b/db/repl/rs_config.cpp @@ -135,7 +135,7 @@ namespace mongo { void ReplSetConfig::MemberCfg::check() const { mchk(_id >= 0 && _id <= 255); mchk(priority >= 0 && priority <= 1000); - mchk(votes >= 0 && votes <= 100); + mchk(votes <= 100); // votes >= 0 because it is unsigned uassert(13419, "this version of mongod only supports priorities 0 and 1", priority == 0 || priority == 1); uassert(13437, "slaveDelay requires priority be zero", slaveDelay == 0 || priority == 0); uassert(13438, "bad slaveDelay value", slaveDelay >= 0 && slaveDelay <= 3600 * 24 * 366); diff --git a/tools/top.cpp b/tools/top.cpp index 59554e517f1..88c479b45b7 100644 --- a/tools/top.cpp +++ b/tools/top.cpp @@ -97,7 +97,7 @@ namespace mongo { << "\t write" << "\t\t" << terseCurrentTime() << endl; - for ( unsigned i=data.size()-1; i>=0 && data.size() - i < 10 ; i-- ) { + for ( int i=data.size()-1; i>=0 && data.size() - i < 10 ; i-- ) { cout << setw(longest) << data[i].ns << "\t" << setprecision(3) << ( data[i].timeDiff / ( 1000 * _sleep ) ) << "%" << "\t" << setprecision(3) << data[i].percentTime( "readLock" , _sleep) << "%" diff --git a/util/assert_util.h b/util/assert_util.h index 79781c0ba30..38f2f71a57e 100644 --- a/util/assert_util.h +++ b/util/assert_util.h @@ -20,6 +20,13 @@ #include "../db/lasterror.h" +// MONGO_NORETURN undefed at end of file +#ifdef __GNUC__ +# define MONGO_NORETURN __attribute__((__noreturn__)) +#else +# define MONGO_NORETURN +#endif + namespace mongo { enum CommonErrorCodes { @@ -117,14 +124,13 @@ namespace mongo { virtual void appendPrefix( stringstream& ss ) const { ss << "massert:"; } }; - - void asserted(const char *msg, const char *file, unsigned line); + void asserted(const char *msg, const char *file, unsigned line) MONGO_NORETURN; void wasserted(const char *msg, const char *file, unsigned line); /** a "user assertion". throws UserAssertion. logs. typically used for errors that a user could cause, such as dupliate key, disk full, etc. */ - void uasserted(int msgid, const char *msg); + void uasserted(int msgid, const char *msg) MONGO_NORETURN; inline void uasserted(int msgid , string msg) { uasserted(msgid, msg.c_str()); } /** reported via lasterror, but don't throw exception */ @@ -133,9 +139,9 @@ namespace mongo { /** msgassert and massert are for errors that are internal but have a well defined error text string. a stack trace is logged. */ - void msgassertedNoTrace(int msgid, const char *msg); + void msgassertedNoTrace(int msgid, const char *msg) MONGO_NORETURN; inline void msgassertedNoTrace(int msgid, const string& msg) { msgassertedNoTrace( msgid , msg.c_str() ); } - void msgasserted(int msgid, const char *msg); + void msgasserted(int msgid, const char *msg) MONGO_NORETURN; inline void msgasserted(int msgid, string msg) { msgasserted(msgid, msg.c_str()); } #ifdef assert @@ -183,7 +189,7 @@ namespace mongo { enum { ASSERT_ID_DUPKEY = 11000 }; /* throws a uassertion with an appropriate msg */ - void streamNotGood( int code , string msg , std::ios& myios ); + void streamNotGood( int code , string msg , std::ios& myios ) MONGO_NORETURN; inline void assertStreamGood(unsigned msgid, string msg, std::ios& myios) { if( !myios.good() ) streamNotGood(msgid, msg, myios); @@ -227,3 +233,5 @@ namespace mongo { #define MONGO_chain_exception(code, e, type, msg) { stringstream ss; ss << msg; ss << MONGO_caused_by(e); throw type(ss.str().c_str(), code); } #define m_chain_exception MONGO_chain_exception + +#undef MONGO_NORETURN