diff --git a/src/beast/beast/container/tests/hash_metrics.h b/src/beast/beast/container/tests/hash_metrics.h index 1cb2ec420..c5df4ef86 100644 --- a/src/beast/beast/container/tests/hash_metrics.h +++ b/src/beast/beast/container/tests/hash_metrics.h @@ -157,7 +157,7 @@ window (T* blob, int start, int count ) /** Calculated a windowed metric using bins. TODO Need reference (SMHasher?) -*/ +*/ template double windowed_score (FwdIter first, FwdIter last) @@ -169,8 +169,6 @@ windowed_score (FwdIter first, FwdIter last) while (static_cast(size) / (1 << maxwidth) < 5.0) maxwidth--; double worst = 0; - int worstStart = -1; - int worstWidth = -1; std::vector bins (1 << maxwidth); int const hashbits = sizeof(std::size_t) * CHAR_BIT; for (int start = 0; start < hashbits; ++start) @@ -185,12 +183,7 @@ windowed_score (FwdIter first, FwdIter last) { double score (detail::score ( bins.data(), bins.size(), size)); - if (score > worst) - { - worst = score; - worstStart = start; - worstWidth = width; - } + worst = std::max(score, worst); if (--width < 8) break; for (std::size_t i = 0, j = bins.size() / 2; j < bins.size(); ++i, ++j) diff --git a/src/beast/modules/beast_core/native/linux_Threads.cpp b/src/beast/modules/beast_core/native/linux_Threads.cpp index 74c1e3fe3..6bb1b1bcf 100644 --- a/src/beast/modules/beast_core/native/linux_Threads.cpp +++ b/src/beast/modules/beast_core/native/linux_Threads.cpp @@ -73,10 +73,14 @@ bool Process::isRunningUnderDebugger() return beast_isRunningUnderDebugger(); } -static void swapUserAndEffectiveUser() +// TODO(tom): raisePrivilege and lowerPrivilege don't seem to be called. If we +// start using them, we should deal with the return codes of setreuid() and +// setregid(). +static bool swapUserAndEffectiveUser() { - (void) setreuid (geteuid(), getuid()); - (void) setregid (getegid(), getgid()); + auto r1 = setreuid (geteuid(), getuid()); + auto r2 = setregid (getegid(), getgid()); + return !(r1 || r2); } void Process::raisePrivilege() { if (geteuid() != 0 && getuid() == 0) swapUserAndEffectiveUser(); }