Fix clang warnings

This commit is contained in:
Howard Hinnant
2014-02-25 15:49:27 -05:00
committed by Vinnie Falco
parent 8eddcfd3d5
commit bb02112752
10 changed files with 41 additions and 14 deletions

View File

@@ -300,8 +300,16 @@ template <typename Type>
inline Type Atomic<Type>::operator+= (const Type amountToAdd) noexcept
{
#if BEAST_ATOMICS_MAC
# ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wint-to-void-pointer-cast"
# pragma clang diagnostic ignored "-Wint-to-pointer-cast"
# endif
return sizeof (Type) == 4 ? (Type) OSAtomicAdd32Barrier ((int32_t) castTo32Bit (amountToAdd), (BEAST_MAC_ATOMICS_VOLATILE int32_t*) &value)
: (Type) OSAtomicAdd64Barrier ((int64_t) amountToAdd, (BEAST_MAC_ATOMICS_VOLATILE int64_t*) &value);
# ifdef __clang__
# pragma clang diagnostic pop
# endif
#elif BEAST_ATOMICS_WINDOWS
return sizeof (Type) == 4 ? (Type) (beast_InterlockedExchangeAdd ((volatile long*) &value, (long) amountToAdd) + (long) amountToAdd)
: (Type) (beast_InterlockedExchangeAdd64 ((volatile __int64*) &value, (__int64) amountToAdd) + (__int64) amountToAdd);
@@ -320,8 +328,16 @@ template <typename Type>
inline Type Atomic<Type>::operator++() noexcept
{
#if BEAST_ATOMICS_MAC
# ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wint-to-void-pointer-cast"
# pragma clang diagnostic ignored "-Wint-to-pointer-cast"
# endif
return sizeof (Type) == 4 ? (Type) OSAtomicIncrement32Barrier ((BEAST_MAC_ATOMICS_VOLATILE int32_t*) &value)
: (Type) OSAtomicIncrement64Barrier ((BEAST_MAC_ATOMICS_VOLATILE int64_t*) &value);
# ifdef __clang__
# pragma clang diagnostic pop
# endif
#elif BEAST_ATOMICS_WINDOWS
return sizeof (Type) == 4 ? (Type) beast_InterlockedIncrement ((volatile long*) &value)
: (Type) beast_InterlockedIncrement64 ((volatile __int64*) &value);
@@ -334,8 +350,16 @@ template <typename Type>
inline Type Atomic<Type>::operator--() noexcept
{
#if BEAST_ATOMICS_MAC
# ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wint-to-void-pointer-cast"
# pragma clang diagnostic ignored "-Wint-to-pointer-cast"
# endif
return sizeof (Type) == 4 ? (Type) OSAtomicDecrement32Barrier ((BEAST_MAC_ATOMICS_VOLATILE int32_t*) &value)
: (Type) OSAtomicDecrement64Barrier ((BEAST_MAC_ATOMICS_VOLATILE int64_t*) &value);
# ifdef __clang__
# pragma clang diagnostic pop
# endif
#elif BEAST_ATOMICS_WINDOWS
return sizeof (Type) == 4 ? (Type) beast_InterlockedDecrement ((volatile long*) &value)
: (Type) beast_InterlockedDecrement64 ((volatile __int64*) &value);

View File

@@ -1469,7 +1469,7 @@ operator[] (Key const& key)
std::piecewise_construct, std::forward_as_tuple (key),
std::forward_as_tuple ()));
chronological.list.push_back (*p);
auto const iter (m_cont.insert_commit (*p, d));
m_cont.insert_commit (*p, d);
return p->value.second;
}
return result.first->value.second;
@@ -1492,7 +1492,7 @@ operator[] (Key&& key)
std::forward_as_tuple (std::move (key)),
std::forward_as_tuple ()));
chronological.list.push_back (*p);
auto const iter (m_cont.insert_commit (*p, d));
m_cont.insert_commit (*p, d);
return p->value.second;
}
return result.first->value.second;

View File

@@ -2077,7 +2077,7 @@ operator[] (Key const& key)
std::forward_as_tuple (key),
std::forward_as_tuple ()));
chronological.list.push_back (*p);
auto const iter (m_cont.insert_commit (*p, d));
m_cont.insert_commit (*p, d);
return p->value.second;
}
return result.first->value.second;
@@ -2103,7 +2103,7 @@ operator[] (Key&& key)
std::forward_as_tuple (std::move (key)),
std::forward_as_tuple ()));
chronological.list.push_back (*p);
auto const iter (m_cont.insert_commit (*p, d));
m_cont.insert_commit (*p, d);
return p->value.second;
}
return result.first->value.second;

View File

@@ -335,7 +335,7 @@ public:
void log (std::vector <boost::asio::const_buffer> const& buffers)
{
buffers;
(void)buffers;
#if BEAST_STATSDCOLLECTOR_TRACING_ENABLED
std::stringstream ss;
for (auto const& buffer : buffers)

View File

@@ -343,9 +343,9 @@ public:
const beast_wchar c = src.getAndAdvance();
const size_t bytesNeeded = DestCharPointerType::getBytesRequiredFor (c);
maxBytes -= bytesNeeded;
if (c == 0 || maxBytes < 0)
if (c == 0 || maxBytes < bytesNeeded)
break;
maxBytes -= bytesNeeded;
dest.write (c);
}

View File

@@ -64,6 +64,9 @@ public:
#pragma warning (push)
#pragma warning (disable: 4127) // conditional expression is constant
#pragma warning (disable: 4146) // unary minus operator applied to unsigned type, result still unsigned
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-compare"
#endif
// pass in a pointer to the END of a buffer..
template <typename IntegerType>
@@ -86,6 +89,8 @@ public:
}
#ifdef _MSC_VER
#pragma warning (pop)
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif
struct StackArrayStream : public std::basic_streambuf <char, std::char_traits <char> >

View File

@@ -33,9 +33,8 @@ protected:
SharedHandler. A reference to the SharedHandler is maintained
for the lifetime of the composed operation.
*/
ComposedAsyncOperation (std::size_t size, SharedHandlerPtr const& ptr)
: m_size (size)
, m_ptr (ptr)
explicit ComposedAsyncOperation (SharedHandlerPtr const& ptr)
: m_ptr (ptr)
{
// Illegal to do anything with handler here, because
// usually it hasn't been assigned by the derived class yet.
@@ -93,7 +92,6 @@ protected:
}
private:
std::size_t const m_size;
SharedHandlerPtr const m_ptr;
};

View File

@@ -129,7 +129,7 @@ private:
AsyncOp (HandshakeDetectLogicType <Logic>& logic, Stream& stream,
BuffersType& buffer, SharedHandlerPtr const& handler)
: ComposedAsyncOperation (sizeof (*this), handler)
: ComposedAsyncOperation (handler)
, m_logic (logic)
, m_stream (stream)
, m_buffer (buffer)

View File

@@ -27,7 +27,7 @@ class TestPeerDetails
public:
virtual ~TestPeerDetails () { }
virtual String name () = 0;
virtual String name () const = 0;
virtual Socket& get_socket () = 0;

View File

@@ -54,7 +54,7 @@ public:
return ".tcp?";
}
String name ()
String name () const
{
return getArgName (m_protocol);
}