Fix a few warnings

This commit is contained in:
Tom Ritchford
2014-05-27 12:55:44 -04:00
committed by Vinnie Falco
parent bfa8dec6f6
commit 48d4fccc22
2 changed files with 9 additions and 12 deletions

View File

@@ -157,7 +157,7 @@ window (T* blob, int start, int count )
/** Calculated a windowed metric using bins. /** Calculated a windowed metric using bins.
TODO Need reference (SMHasher?) TODO Need reference (SMHasher?)
*/ */
template <class FwdIter> template <class FwdIter>
double double
windowed_score (FwdIter first, FwdIter last) windowed_score (FwdIter first, FwdIter last)
@@ -169,8 +169,6 @@ windowed_score (FwdIter first, FwdIter last)
while (static_cast<double>(size) / (1 << maxwidth) < 5.0) while (static_cast<double>(size) / (1 << maxwidth) < 5.0)
maxwidth--; maxwidth--;
double worst = 0; double worst = 0;
int worstStart = -1;
int worstWidth = -1;
std::vector <int> bins (1 << maxwidth); std::vector <int> bins (1 << maxwidth);
int const hashbits = sizeof(std::size_t) * CHAR_BIT; int const hashbits = sizeof(std::size_t) * CHAR_BIT;
for (int start = 0; start < hashbits; ++start) for (int start = 0; start < hashbits; ++start)
@@ -185,12 +183,7 @@ windowed_score (FwdIter first, FwdIter last)
{ {
double score (detail::score ( double score (detail::score (
bins.data(), bins.size(), size)); bins.data(), bins.size(), size));
if (score > worst) worst = std::max(score, worst);
{
worst = score;
worstStart = start;
worstWidth = width;
}
if (--width < 8) if (--width < 8)
break; break;
for (std::size_t i = 0, j = bins.size() / 2; j < bins.size(); ++i, ++j) for (std::size_t i = 0, j = bins.size() / 2; j < bins.size(); ++i, ++j)

View File

@@ -73,10 +73,14 @@ bool Process::isRunningUnderDebugger()
return beast_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()); auto r1 = setreuid (geteuid(), getuid());
(void) setregid (getegid(), getgid()); auto r2 = setregid (getegid(), getgid());
return !(r1 || r2);
} }
void Process::raisePrivilege() { if (geteuid() != 0 && getuid() == 0) swapUserAndEffectiveUser(); } void Process::raisePrivilege() { if (geteuid() != 0 && getuid() == 0) swapUserAndEffectiveUser(); }