Core: Fix a -Wshadow warning in gcc 11
This moves the only direct call to zlib’s crc32() into its own translation unit, but that operation is cold enough that this won’t matter in the slightest. crc32_z() would be more appropriate, but Android has an older zlib version…
This commit is contained in:
parent
ab252aedfa
commit
3d662e746b
|
@ -25,6 +25,8 @@ add_library(common
|
|||
Config/Layer.cpp
|
||||
Config/Layer.h
|
||||
CPUDetect.h
|
||||
CRC32.cpp
|
||||
CRC32.h
|
||||
Crypto/AES.cpp
|
||||
Crypto/AES.h
|
||||
Crypto/bn.cpp
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2021 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#include "Common/CRC32.h"
|
||||
|
||||
namespace Common
|
||||
{
|
||||
u32 ComputeCRC32(std::string_view data)
|
||||
{
|
||||
const Bytef* buf = reinterpret_cast<const Bytef*>(data.data());
|
||||
uInt len = static_cast<uInt>(data.size());
|
||||
// Use zlibs crc32 implementation to compute the hash
|
||||
u32 hash = crc32(0L, Z_NULL, 0);
|
||||
hash = crc32(hash, buf, len);
|
||||
return hash;
|
||||
}
|
||||
} // namespace Common
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright 2021 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
namespace Common
|
||||
{
|
||||
u32 ComputeCRC32(std::string_view data);
|
||||
} // namespace Common
|
|
@ -20,10 +20,9 @@ namespace fs = std::filesystem;
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/CDUtils.h"
|
||||
#include "Common/CRC32.h"
|
||||
#include "Common/CommonPaths.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Config/Config.h"
|
||||
|
@ -355,9 +354,7 @@ bool CBoot::Load_BS2(const std::string& boot_rom_filename)
|
|||
if (!File::ReadFileToString(boot_rom_filename, data))
|
||||
return false;
|
||||
|
||||
// Use zlibs crc32 implementation to compute the hash
|
||||
u32 ipl_hash = crc32(0L, Z_NULL, 0);
|
||||
ipl_hash = crc32(ipl_hash, (const Bytef*)data.data(), (u32)data.size());
|
||||
const u32 ipl_hash = Common::ComputeCRC32(data);
|
||||
bool known_ipl = false;
|
||||
bool pal_ipl = false;
|
||||
switch (ipl_hash)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<ClInclude Include="Common\BitUtils.h" />
|
||||
<ClInclude Include="Common\BlockingLoop.h" />
|
||||
<ClInclude Include="Common\CDUtils.h" />
|
||||
<ClInclude Include="Common\CRC32.h" />
|
||||
<ClInclude Include="Common\ChunkFile.h" />
|
||||
<ClInclude Include="Common\CodeBlock.h" />
|
||||
<ClInclude Include="Common\ColorUtil.h" />
|
||||
|
@ -689,6 +690,7 @@
|
|||
<ClCompile Include="AudioCommon\WaveFile.cpp" />
|
||||
<ClCompile Include="Common\Analytics.cpp" />
|
||||
<ClCompile Include="Common\CDUtils.cpp" />
|
||||
<ClCompile Include="Common\CRC32.cpp" />
|
||||
<ClCompile Include="Common\ColorUtil.cpp" />
|
||||
<ClCompile Include="Common\CommonFuncs.cpp" />
|
||||
<ClCompile Include="Common\CompatPatches.cpp" />
|
||||
|
|
Loading…
Reference in New Issue