Skip to content

Commit

Permalink
Revert "OrcLib: Utils: EnumFlags: fix operator&"
Browse files Browse the repository at this point in the history
This reverts commit 78c1529771815f2b8e7fa610f1c56d30e22b8b9c.
  • Loading branch information
fabienfl-orc committed Dec 1, 2020
1 parent 8ccc6b7 commit ab33fc3
Show file tree
Hide file tree
Showing 19 changed files with 141 additions and 158 deletions.
2 changes: 1 addition & 1 deletion src/OrcCommand/FastFind_Run.cpp
Expand Up @@ -463,7 +463,7 @@ HRESULT Main::Run()
if (config.outObject.Type != OutputSpec::Kind::None)
pObjectTableOutput = TableOutput::GetWriter(config.outObject);

if ((config.outStructured.Type & OutputSpec::Kind::StructuredFile) == OutputSpec::Kind::StructuredFile)
if (config.outStructured.Type & OutputSpec::Kind::StructuredFile)
{
pStructuredOutput = StructuredOutputWriter::GetWriter(config.outStructured, nullptr);
}
Expand Down
4 changes: 2 additions & 2 deletions src/OrcCommand/GetSamples_Run.cpp
Expand Up @@ -473,7 +473,7 @@ HRESULT Main::Run()
Log::Info(L"Verifying code signatures... Done");
}

if ((config.sampleinfoOutput.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile)
if (config.sampleinfoOutput.Type & OutputSpec::Kind::TableFile)
{
hr = WriteSampleInformation(results);
if (FAILED(hr))
Expand All @@ -483,7 +483,7 @@ HRESULT Main::Run()
}
}

if ((config.timelineOutput.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile)
if (config.timelineOutput.Type & OutputSpec::Kind::TableFile)
{
// Collect time line related information
const TaskTracker::TimeLine& timeline = tk.GetTimeLine();
Expand Down
2 changes: 1 addition & 1 deletion src/OrcCommand/RegInfo_Config.cpp
Expand Up @@ -246,7 +246,7 @@ HRESULT Main::CheckConfiguration()
Log::Error("No valid output specified (only directory or csv|tsv are allowed");
return E_INVALIDARG;
}
if ((config.Output.Type & OutputSpec::Kind::Archive) == OutputSpec::Kind::Archive)
if (config.Output.Type & OutputSpec::Kind::Archive)
{
Log::Error("Archive output is not supported (only directory or csv|tsv are allowed");
return E_INVALIDARG;
Expand Down
4 changes: 2 additions & 2 deletions src/OrcCommand/RegInfo_Run.cpp
Expand Up @@ -467,7 +467,7 @@ HRESULT Main::Run()

std::shared_ptr<TableOutput::IWriter> pRegInfoWriter;

if ((config.Output.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile)
if (config.Output.Type & OutputSpec::Kind::TableFile)
{
pRegInfoWriter = GetRegInfoWriter(config.Output);
if (nullptr == pRegInfoWriter)
Expand All @@ -482,7 +482,7 @@ HRESULT Main::Run()
{
auto node = root.AddNode("Parsing hive '{}'", hive.FileName);

if ((config.Output.Type & OutputSpec::Kind::Directory) == OutputSpec::Kind::Directory)
if (config.Output.Type & OutputSpec::Kind::Directory)
{
std::wstring fileName(hive.FileName);
std::replace(fileName.begin(), fileName.end(), L'\\', L'_');
Expand Down
2 changes: 1 addition & 1 deletion src/OrcCommand/Usage.h
Expand Up @@ -255,7 +255,7 @@ auto PrintColumnSelectionParameter(
const ColumnNameDef* pCurCol = pColumnNames;
while (pCurCol->dwIntention != Intentions::FILEINFO_NONE)
{
if ((pCurAlias->dwIntention & pCurCol->dwIntention) == pCurCol->dwIntention)
if (pCurAlias->dwIntention & pCurCol->dwIntention)
{
PrintValue(aliasNode, pCurCol->szColumnName, pCurCol->szColumnDesc);
dwNumCol++;
Expand Down
4 changes: 2 additions & 2 deletions src/OrcCommand/WolfExecution.h
Expand Up @@ -175,12 +175,12 @@ class WolfExecution
m_Temporary = temporary;

m_JobStatisticsOutput = jobstats;
if ((m_JobStatisticsOutput.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile)
if (m_JobStatisticsOutput.Type & OutputSpec::Kind::TableFile)
{
m_JobStatisticsOutput.Path = m_Temporary.Path + L"\\" + m_JobStatisticsOutput.Path;
}
m_ProcessStatisticsOutput = processstats;
if ((m_ProcessStatisticsOutput.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile)
if (m_ProcessStatisticsOutput.Type & OutputSpec::Kind::TableFile)
{
m_ProcessStatisticsOutput.Path = m_Temporary.Path + L"\\" + m_ProcessStatisticsOutput.Path;
}
Expand Down
4 changes: 2 additions & 2 deletions src/OrcCommand/WolfExecution_Execute.cpp
Expand Up @@ -504,7 +504,7 @@ HRESULT WolfExecution::CreateCommandAgent(
m_pTermination = std::make_shared<WOLFExecutionTerminate>(m_commandSet, this);
Robustness::AddTerminationHandler(m_pTermination);

if ((m_ProcessStatisticsOutput.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile)
if (m_ProcessStatisticsOutput.Type & OutputSpec::Kind::TableFile)
{
m_ProcessStatisticsWriter = TableOutput::GetWriter(m_ProcessStatisticsOutput);

Expand All @@ -514,7 +514,7 @@ HRESULT WolfExecution::CreateCommandAgent(
}
}

if ((m_JobStatisticsOutput.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile)
if (m_JobStatisticsOutput.Type & OutputSpec::Kind::TableFile)
{
m_JobStatisticsWriter = TableOutput::GetWriter(m_JobStatisticsOutput);
if (m_JobStatisticsWriter == nullptr)
Expand Down
8 changes: 4 additions & 4 deletions src/OrcCommand/WolfLauncher_Output.cpp
Expand Up @@ -50,22 +50,22 @@ std::wstring Main::ToString(Main::WolfPowerState value)
return L"<SystemDefault>";
}

if ((value & Main::WolfPowerState::SystemRequired) == Main::WolfPowerState::SystemRequired)
if (value & Main::WolfPowerState::SystemRequired)
{
properties.push_back(L"SystemRequired");
}

if ((value & Main::WolfPowerState::DisplayRequired) == Main::WolfPowerState::DisplayRequired)
if (value & Main::WolfPowerState::DisplayRequired)
{
properties.push_back(L"DisplayRequired");
}

if ((value & Main::WolfPowerState::UserPresent) == Main::WolfPowerState::UserPresent)
if (value & Main::WolfPowerState::UserPresent)
{
properties.push_back(L"UserPresent");
}

if ((value & Main::WolfPowerState::AwayMode) == Main::WolfPowerState::AwayMode)
if (value & Main::WolfPowerState::AwayMode)
{
properties.push_back(L"AwayMode");
}
Expand Down
13 changes: 6 additions & 7 deletions src/OrcLib/CryptoHashStream.cpp
Expand Up @@ -102,19 +102,18 @@ HRESULT CryptoHashStream::ResetHash(bool bContinue)
}
m_bHashIsValid = true;

if ((m_Algorithms & Algorithm::MD5) == Algorithm::MD5 && !CryptCreateHash(g_hProv, CALG_MD5, 0, 0, &m_MD5))
if ((m_Algorithms & Algorithm::MD5) && !CryptCreateHash(g_hProv, CALG_MD5, 0, 0, &m_MD5))
{
hr = HRESULT_FROM_WIN32(GetLastError());
Log::Debug(L"Failed to initialise MD5 hash [{}]", SystemError(hr));
}

if ((m_Algorithms & Algorithm::SHA1) == Algorithm::SHA1 && !CryptCreateHash(g_hProv, CALG_SHA1, 0, 0, &m_Sha1))
if ((m_Algorithms & Algorithm::SHA1) && !CryptCreateHash(g_hProv, CALG_SHA1, 0, 0, &m_Sha1))
{
hr = HRESULT_FROM_WIN32(GetLastError());
Log::Debug(L"Failed to initialise SHA1 hash [{}]", SystemError(hr));
}
if ((m_Algorithms & Algorithm::SHA256) == Algorithm::SHA256
&& !CryptCreateHash(g_hProv, CALG_SHA_256, 0, 0, &m_Sha256))
if ((m_Algorithms & Algorithm::SHA256) && !CryptCreateHash(g_hProv, CALG_SHA_256, 0, 0, &m_Sha256))
{
hr = HRESULT_FROM_WIN32(GetLastError());
Log::Debug(L"Failed to initialise SHA256 hash [{}]", SystemError(hr));
Expand Down Expand Up @@ -228,18 +227,18 @@ std::wstring CryptoHashStream::GetSupportedAlgorithm(Algorithm algs)

retval.reserve(16);

if ((algs & Algorithm::MD5) == Algorithm::MD5)
if (algs & Algorithm::MD5)
{
retval.append(L"MD5"sv);
}
if ((algs & Algorithm::SHA1) == Algorithm::SHA1)
if (algs & Algorithm::SHA1)
{
if (retval.empty())
retval.append(L"SHA1"sv);
else
retval.append(L",SHA1"sv);
}
if ((algs & Algorithm::SHA256) == Algorithm::SHA256)
if (algs & Algorithm::SHA256)
{
if (retval.empty())
retval.append(L"SHA256"sv);
Expand Down
19 changes: 9 additions & 10 deletions src/OrcLib/FileFind.cpp
Expand Up @@ -781,7 +781,9 @@ std::shared_ptr<FileFind::SearchTerm> FileFind::GetSearchTermFromConfig(const Co
else
{
Log::Warn(
L"Invalid hex string passed as header: {} [{}]", item[CONFIG_FILEFIND_HEADER_HEX], SystemError(hr));
L"Invalid hex string passed as header: {} [{}]",
item[CONFIG_FILEFIND_HEADER_HEX],
SystemError(hr));
}
}
if (item[CONFIG_FILEFIND_HEADER_REGEX])
Expand Down Expand Up @@ -3494,14 +3496,11 @@ HRESULT FileFind::ComputeMatchHashes(const std::shared_ptr<Match>& aMatch)
for (auto& attr_match : aMatch->MatchingAttributes)
{
CryptoHashStream::Algorithm needed = CryptoHashStream::Algorithm::Undefined;
if ((m_MatchHash & CryptoHashStream::Algorithm::MD5) == CryptoHashStream::Algorithm::MD5
&& attr_match.MD5.empty())
if (m_MatchHash & CryptoHashStream::Algorithm::MD5 && attr_match.MD5.empty())
needed |= CryptoHashStream::Algorithm::MD5;
if ((m_MatchHash & CryptoHashStream::Algorithm::SHA1) == CryptoHashStream::Algorithm::SHA1
&& attr_match.SHA1.empty())
if (m_MatchHash & CryptoHashStream::Algorithm::SHA1 && attr_match.SHA1.empty())
needed |= CryptoHashStream::Algorithm::SHA1;
if ((m_MatchHash & CryptoHashStream::Algorithm::SHA256) == CryptoHashStream::Algorithm::SHA256
&& attr_match.SHA256.empty())
if (m_MatchHash & CryptoHashStream::Algorithm::SHA256 && attr_match.SHA256.empty())
needed |= CryptoHashStream::Algorithm::SHA256;

if (needed != CryptoHashStream::Algorithm::Undefined)
Expand All @@ -3526,19 +3525,19 @@ HRESULT FileFind::ComputeMatchHashes(const std::shared_ptr<Match>& aMatch)

if (ullWritten > 0)
{
if ((needed & CryptoHashStream::Algorithm::MD5) == CryptoHashStream::Algorithm::MD5
if (needed & CryptoHashStream::Algorithm::MD5
&& FAILED(hr = hashstream->GetHash(CryptoHashStream::Algorithm::MD5, attr_match.MD5)))
{
if (hr != MK_E_UNAVAILABLE)
return hr;
}
if ((needed & CryptoHashStream::Algorithm::SHA1) == CryptoHashStream::Algorithm::SHA1
if (needed & CryptoHashStream::Algorithm::SHA1
&& FAILED(hr = hashstream->GetHash(CryptoHashStream::Algorithm::SHA1, attr_match.SHA1)))
{
if (hr != MK_E_UNAVAILABLE)
return hr;
}
if ((needed & CryptoHashStream::Algorithm::SHA256) == CryptoHashStream::Algorithm::SHA256
if (needed & CryptoHashStream::Algorithm::SHA256
&& FAILED(hr = hashstream->GetHash(CryptoHashStream::Algorithm::SHA256, attr_match.SHA256)))
{
if (hr != MK_E_UNAVAILABLE)
Expand Down

0 comments on commit ab33fc3

Please sign in to comment.