Fix a few warnings

This commit is contained in:
Tom Ritchford
2014-05-27 12:55:44 -04:00
committed by Vinnie Falco
parent 9bbaa9a2ae
commit 353f32e6af
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.
TODO Need reference (SMHasher?)
*/
*/
template <class FwdIter>
double
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)
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)
@@ -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)

View File

@@ -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(); }