Commit 83da0042 authored by Gaurav Jain's avatar Gaurav Jain Committed by Jordan DeLong

Fix some clang compiler warnings/errors

Summary:
Fixes instances of the following problems:
error: offset of on non-POD type 'folly::fbstring_core<char>::RefCounted'
[-Werror,-Winvalid-offsetof]
Solution: Since the atomic is not a POD I used sizeof() instead to calculate
the offset

warning: C++11 requires lambda with omitted result type to consist of a single
return statement
Solution: Specify a return type

error: in-class initializer for static data member is not a constant expression
Solution: Move initializer

Test Plan: - Compiled folly and ran fbmake runtests

Reviewed By: andrei.alexandrescu@fb.com

FB internal diff: D656963
parent 06eaa4f3
......@@ -729,7 +729,7 @@ private:
return static_cast<RefCounted*>(
static_cast<void*>(
static_cast<unsigned char*>(static_cast<void*>(p))
- offsetof(RefCounted, data_)));
- sizeof(refCount_)));
}
static size_t refs(Char * p) {
......
......@@ -120,7 +120,7 @@ public:
typedef typename std::iterator_traits<Iter>::reference reference;
typedef std::char_traits<value_type> traits_type;
static const size_type npos = std::string::npos;
static const size_type npos;
// Works for all iterators
Range() : b_(), e_() {
......@@ -423,7 +423,7 @@ private:
};
template <class Iter>
const typename Range<Iter>::size_type Range<Iter>::npos;
const typename Range<Iter>::size_type Range<Iter>::npos = std::string::npos;
template <class T>
void swap(Range<T>& lhs, Range<T>& rhs) {
......
......@@ -225,7 +225,7 @@ template <class T> struct IsZeroInitializable
namespace std {
template <class T, class U>
class pair;
struct pair;
#ifndef _GLIBCXX_USE_FB
template <class T, class R, class A>
class basic_string;
......
......@@ -542,7 +542,7 @@ fbstring decodeUnicodeEscape(Input& in) {
(in.error("invalid hex digit"), 0);
};
auto readHex = [&] {
auto readHex = [&]() -> uint16_t {
if (in.size() < 4) {
in.error("expected 4 hex digits");
}
......
......@@ -100,7 +100,7 @@ struct OneBitMutex;
//////////////////////////////////////////////////////////////////////
template<class T, std::size_t M, class A, class B, class C>
struct small_vector;
class small_vector;
//////////////////////////////////////////////////////////////////////
......
......@@ -191,7 +191,7 @@ VT BucketedTimeSeries<VT, TT>::sum(TimeType start, TimeType end) const {
ValueType sum = ValueType();
forEachBucket(start, end, [&](const Bucket& bucket,
TimeType bucketStart,
TimeType nextBucketStart) {
TimeType nextBucketStart) -> bool {
sum += this->rangeAdjust(bucketStart, nextBucketStart, start, end,
bucket.sum);
return true;
......@@ -205,7 +205,7 @@ uint64_t BucketedTimeSeries<VT, TT>::count(TimeType start, TimeType end) const {
uint64_t count = 0;
forEachBucket(start, end, [&](const Bucket& bucket,
TimeType bucketStart,
TimeType nextBucketStart) {
TimeType nextBucketStart) -> bool {
count += this->rangeAdjust(bucketStart, nextBucketStart, start, end,
bucket.count);
return true;
......@@ -221,7 +221,7 @@ ReturnType BucketedTimeSeries<VT, TT>::avg(TimeType start, TimeType end) const {
uint64_t count = 0;
forEachBucket(start, end, [&](const Bucket& bucket,
TimeType bucketStart,
TimeType nextBucketStart) {
TimeType nextBucketStart) -> bool {
sum += this->rangeAdjust(bucketStart, nextBucketStart, start, end,
bucket.sum);
count += this->rangeAdjust(bucketStart, nextBucketStart, start, end,
......@@ -396,7 +396,7 @@ template <typename Function>
void BucketedTimeSeries<VT, TT>::forEachBucket(TimeType start, TimeType end,
Function fn) const {
forEachBucket([&start, &end, &fn] (const Bucket& bucket, TimeType bucketStart,
TimeType nextBucketStart) {
TimeType nextBucketStart) -> bool {
if (start >= nextBucketStart) {
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment