diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -218,6 +218,7 @@ -Wall -Wextra -Wformat + -Wgnu -Wvla -Wcast-align -Wunused-parameter diff --git a/src/logging/timer.h b/src/logging/timer.h --- a/src/logging/timer.h +++ b/src/logging/timer.h @@ -79,14 +79,11 @@ } // namespace BCLog -#define LOG_TIME_MICROS(end_msg, ...) \ - BCLog::Timer PASTE2( \ - logging_timer, __COUNTER__)(__func__, end_msg, ##__VA_ARGS__) -#define LOG_TIME_MILLIS(end_msg, ...) \ +#define LOG_TIME_MILLIS_WITH_CATEGORY(end_msg, log_category) \ BCLog::Timer PASTE2( \ - logging_timer, __COUNTER__)(__func__, end_msg, ##__VA_ARGS__) -#define LOG_TIME_SECONDS(end_msg, ...) \ - BCLog::Timer PASTE2(logging_timer, __COUNTER__)( \ - __func__, end_msg, ##__VA_ARGS__) + logging_timer, __COUNTER__)(__func__, end_msg, log_category) +#define LOG_TIME_SECONDS(end_msg) \ + BCLog::Timer PASTE2(logging_timer, \ + __COUNTER__)(__func__, end_msg) #endif // BITCOIN_LOGGING_TIMER_H diff --git a/src/prevector.h b/src/prevector.h --- a/src/prevector.h +++ b/src/prevector.h @@ -237,7 +237,7 @@ struct { char *indirect; size_type capacity; - }; + } indirect_contents; }; #pragma pack(pop) alignas(char *) direct_or_indirect _union = {}; @@ -258,10 +258,11 @@ return reinterpret_cast(_union.direct) + pos; } T *indirect_ptr(difference_type pos) { - return reinterpret_cast(_union.indirect) + pos; + return reinterpret_cast(_union.indirect_contents.indirect) + pos; } const T *indirect_ptr(difference_type pos) const { - return reinterpret_cast(_union.indirect) + pos; + return reinterpret_cast(_union.indirect_contents.indirect) + + pos; } bool is_direct() const { return _size <= N; } @@ -282,10 +283,11 @@ // allocator or new/delete so that handlers are called as // necessary, but performance would be slightly degraded by // doing so. - _union.indirect = static_cast(realloc( - _union.indirect, ((size_t)sizeof(T)) * new_capacity)); - assert(_union.indirect); - _union.capacity = new_capacity; + _union.indirect_contents.indirect = static_cast( + realloc(_union.indirect_contents.indirect, + ((size_t)sizeof(T)) * new_capacity)); + assert(_union.indirect_contents.indirect); + _union.indirect_contents.capacity = new_capacity; } else { char *new_indirect = static_cast( malloc(((size_t)sizeof(T)) * new_capacity)); @@ -293,8 +295,8 @@ T *src = direct_ptr(0); T *dst = reinterpret_cast(new_indirect); memcpy(dst, src, size() * sizeof(T)); - _union.indirect = new_indirect; - _union.capacity = new_capacity; + _union.indirect_contents.indirect = new_indirect; + _union.indirect_contents.capacity = new_capacity; _size += N + 1; } } @@ -403,7 +405,7 @@ if (is_direct()) { return N; } else { - return _union.capacity; + return _union.indirect_contents.capacity; } } @@ -548,8 +550,8 @@ clear(); } if (!is_direct()) { - free(_union.indirect); - _union.indirect = nullptr; + free(_union.indirect_contents.indirect); + _union.indirect_contents.indirect = nullptr; } } @@ -601,7 +603,7 @@ if (is_direct()) { return 0; } else { - return ((size_t)(sizeof(T))) * _union.capacity; + return ((size_t)(sizeof(T))) * _union.indirect_contents.capacity; } } diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2111,12 +2111,13 @@ if (fPruneMode && (fCheckForPruning || nManualPruneHeight > 0) && !fReindex) { if (nManualPruneHeight > 0) { - LOG_TIME_MILLIS("find files to prune (manual)", - BCLog::BENCH); + LOG_TIME_MILLIS_WITH_CATEGORY( + "find files to prune (manual)", BCLog::BENCH); FindFilesToPruneManual(g_chainman, setFilesToPrune, nManualPruneHeight); } else { - LOG_TIME_MILLIS("find files to prune", BCLog::BENCH); + LOG_TIME_MILLIS_WITH_CATEGORY("find files to prune", + BCLog::BENCH); FindFilesToPrune(g_chainman, setFilesToPrune, chainparams.PruneAfterHeight()); fCheckForPruning = false; @@ -2166,8 +2167,8 @@ } { - LOG_TIME_MILLIS("write block and undo data to disk", - BCLog::BENCH); + LOG_TIME_MILLIS_WITH_CATEGORY( + "write block and undo data to disk", BCLog::BENCH); // First make sure all block and undo data is flushed to // disk. @@ -2176,7 +2177,8 @@ // Then update all block file information (which may refer to // block and undo files). { - LOG_TIME_MILLIS("write block index to disk", BCLog::BENCH); + LOG_TIME_MILLIS_WITH_CATEGORY("write block index to disk", + BCLog::BENCH); std::vector> vFiles; vFiles.reserve(setDirtyFileInfo.size()); @@ -2203,7 +2205,8 @@ // Finally remove any pruned files if (fFlushForPrune) { - LOG_TIME_MILLIS("unlink pruned files", BCLog::BENCH); + LOG_TIME_MILLIS_WITH_CATEGORY("unlink pruned files", + BCLog::BENCH); UnlinkPrunedFiles(setFilesToPrune); }