diff options
author | Juan Gu <juan.gu@mongodb.com> | 2022-11-11 21:57:33 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-11-11 23:04:37 +0000 |
commit | fffe2cb03d8f3a826f7039614ee1c12d88917440 (patch) | |
tree | 9fb13778af611afcab969cca9629a9d7a07921cb /src | |
parent | 4fe82a58bcb58f653da8052885a13c683fcea9cc (diff) | |
download | mongo-fffe2cb03d8f3a826f7039614ee1c12d88917440.tar.gz |
SERVER-29601 Add -Wshadow to compilation - part1
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/bson/json.cpp | 26 | ||||
-rw-r--r-- | src/mongo/bson/util/bsoncolumn.cpp | 4 | ||||
-rw-r--r-- | src/mongo/logv2/json_formatter.cpp | 8 | ||||
-rw-r--r-- | src/mongo/util/future_impl.h | 15 | ||||
-rw-r--r-- | src/mongo/util/stacktrace_somap.cpp | 2 |
5 files changed, 29 insertions, 26 deletions
diff --git a/src/mongo/bson/json.cpp b/src/mongo/bson/json.cpp index 5e6e502f8db..0a7e69a1177 100644 --- a/src/mongo/bson/json.cpp +++ b/src/mongo/bson/json.cpp @@ -220,9 +220,9 @@ Status JParse::object(StringData fieldName, BSONObjBuilder& builder, bool subObj // Special object std::string firstField; firstField.reserve(FIELD_RESERVE_SIZE); - Status ret = field(&firstField); - if (ret != Status::OK()) { - return ret; + Status fieldParseResult = field(&firstField); + if (fieldParseResult != Status::OK()) { + return fieldParseResult; } if (firstField == "$oid") { @@ -365,18 +365,18 @@ Status JParse::object(StringData fieldName, BSONObjBuilder& builder, bool subObj return valueRet; } while (readToken(COMMA)) { - std::string fieldName; - fieldName.reserve(FIELD_RESERVE_SIZE); - Status fieldRet = field(&fieldName); + std::string nextFieldName; + nextFieldName.reserve(FIELD_RESERVE_SIZE); + Status fieldRet = field(&nextFieldName); if (fieldRet != Status::OK()) { return fieldRet; } if (!readToken(COLON)) { return parseError("Expecting ':'"); } - Status valueRet = value(fieldName, *objBuilder); - if (valueRet != Status::OK()) { - return valueRet; + Status nextFieldValueRet = value(nextFieldName, *objBuilder); + if (nextFieldValueRet != Status::OK()) { + return nextFieldValueRet; } } } @@ -529,13 +529,13 @@ Status JParse::dateObject(StringData fieldName, BSONObjBuilder& builder) { } date = dateRet.getValue(); } else if (readToken(LBRACE)) { - std::string fieldName; - fieldName.reserve(FIELD_RESERVE_SIZE); - Status ret = field(&fieldName); + std::string nextFieldName; + nextFieldName.reserve(FIELD_RESERVE_SIZE); + Status ret = field(&nextFieldName); if (ret != Status::OK()) { return ret; } - if (fieldName != "$numberLong") { + if (nextFieldName != "$numberLong") { return parseError("Expected field name: $numberLong for $date value object"); } if (!readToken(COLON)) { diff --git a/src/mongo/bson/util/bsoncolumn.cpp b/src/mongo/bson/util/bsoncolumn.cpp index 3308dac7b3b..63ae732840c 100644 --- a/src/mongo/bson/util/bsoncolumn.cpp +++ b/src/mongo/bson/util/bsoncolumn.cpp @@ -766,7 +766,7 @@ BSONElement BSONColumn::Iterator::DecodingState::_loadDelta(BSONColumn& column, } // Write value depending on type - auto elem = [&]() -> ElementStorage::Element { + auto elemFn = [&]() -> ElementStorage::Element { switch (_lastType) { case String: case Code: { @@ -809,7 +809,7 @@ BSONElement BSONColumn::Iterator::DecodingState::_loadDelta(BSONColumn& column, } }(); - _lastValue = elem.element(); + _lastValue = elemFn.element(); return _lastValue; } diff --git a/src/mongo/logv2/json_formatter.cpp b/src/mongo/logv2/json_formatter.cpp index 58111121423..8b6b0eda101 100644 --- a/src/mongo/logv2/json_formatter.cpp +++ b/src/mongo/logv2/json_formatter.cpp @@ -306,10 +306,10 @@ void JSONFormatter::format(fmt::memory_buffer& buffer, }; }; - auto dateFn = [&](Date_t date) { - return jsobj([&, date](CommaTracker& tracker) { - field(tracker, "$date", quote([&, date] { - write(StringData{DateStringBuffer{}.iso8601(date, local)}); + auto dateFn = [&](Date_t dateToPrint) { + return jsobj([&, dateToPrint](CommaTracker& tracker) { + field(tracker, "$date", quote([&, dateToPrint] { + write(StringData{DateStringBuffer{}.iso8601(dateToPrint, local)}); })); }); }; diff --git a/src/mongo/util/future_impl.h b/src/mongo/util/future_impl.h index cdc8e787cfd..ba0b096cf3d 100644 --- a/src/mongo/util/future_impl.h +++ b/src/mongo/util/future_impl.h @@ -1200,8 +1200,8 @@ public: "func passed to tap must return void"); return tapImpl(std::forward<Func>(func), - [](Func && func, const T& val) noexcept { call(func, val); }, - [](Func && func, const Status& status) noexcept {}); + [](Func && successFunc, const T& val) noexcept { call(successFunc, val); }, + [](Func && failFunc, const Status& status) noexcept {}); } TEMPLATE(typename Policy, typename Func) @@ -1210,8 +1210,9 @@ public: static_assert(std::is_void<decltype(call(func, std::declval<const Status&>()))>::value, "func passed to tapError must return void"); - return tapImpl(std::forward<Func>(func), [](Func && func, const T& val) noexcept {}, [ - ](Func && func, const Status& status) noexcept { call(func, status); }); + return tapImpl( + std::forward<Func>(func), [](Func && successFunc, const T& val) noexcept {}, [ + ](Func && failFunc, const Status& status) noexcept { call(failFunc, status); }); } TEMPLATE(typename Policy, typename Func) @@ -1224,8 +1225,10 @@ public: using Wrapper = StatusOrStatusWith<T>; return tapImpl( std::forward<Func>(func), - [](Func && func, const T& val) noexcept { call(func, Wrapper(val)); }, - [](Func && func, const Status& status) noexcept { call(func, Wrapper(status)); }); + [](Func && successFunc, const T& val) noexcept { call(successFunc, Wrapper(val)); }, + [](Func && failFunc, const Status& status) noexcept { + call(failFunc, Wrapper(status)); + }); } FutureImpl<void> ignoreValue() && noexcept; diff --git a/src/mongo/util/stacktrace_somap.cpp b/src/mongo/util/stacktrace_somap.cpp index c2ed5ac84f8..a9045da0376 100644 --- a/src/mongo/util/stacktrace_somap.cpp +++ b/src/mongo/util/stacktrace_somap.cpp @@ -102,7 +102,6 @@ void processNoteSegment(const dl_phdr_info& info, const ElfW(Phdr) & phdr, BSONO #ifdef NT_GNU_BUILD_ID const char* const notesBegin = reinterpret_cast<const char*>(info.dlpi_addr) + phdr.p_vaddr; const char* const notesEnd = notesBegin + phdr.p_memsz; - ElfW(Nhdr) noteHeader; // Returns the size in bytes of an ELF note entry with the given header. auto roundUpToElfWordAlignment = [](size_t offset) -> size_t { static const size_t elfWordSizeBytes = sizeof(ElfW(Word)); @@ -112,6 +111,7 @@ void processNoteSegment(const dl_phdr_info& info, const ElfW(Phdr) & phdr, BSONO return sizeof(noteHeader) + roundUpToElfWordAlignment(noteHeader.n_namesz) + roundUpToElfWordAlignment(noteHeader.n_descsz); }; + ElfW(Nhdr) noteHeader; for (const char* notesCurr = notesBegin; (notesCurr + sizeof(noteHeader)) < notesEnd; notesCurr += getNoteSizeBytes(noteHeader)) { memcpy(¬eHeader, notesCurr, sizeof(noteHeader)); |