Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of four compilation warnings in beast. #376

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/beast/beast/container/tests/hash_metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ window (T* blob, int start, int count )

/** Calculated a windowed metric using bins.
TODO Need reference (SMHasher?)
*/
*/
template <class FwdIter>
double
windowed_score (FwdIter first, FwdIter last)
Expand All @@ -169,8 +169,6 @@ windowed_score (FwdIter first, FwdIter last)
while (static_cast<double>(size) / (1 << maxwidth) < 5.0)
maxwidth--;
double worst = 0;
int worstStart = -1;
int worstWidth = -1;
std::vector <int> bins (1 << maxwidth);
int const hashbits = sizeof(std::size_t) * CHAR_BIT;
for (int start = 0; start < hashbits; ++start)
Expand All @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions src/beast/modules/beast_core/native/linux_Threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down