Skip to content

Commit

Permalink
Fix several warnings
Browse files Browse the repository at this point in the history
A small, nonexhaustive set of warning fixes. The DiscIO Volume change
is a workaround for a GCC bug [1] that causes returning an unengaged
std::optional to emit annoying -Wmaybe-uninitialized warnings.
This last change alone fixes pages upon pages of warnings since
Volume.h is included from several files.

-Wstringop-truncation is another irrelevant warning for us, but
unfortunately there seems to be no way to disable it without
adding ugly pragmas wherever the warning appears.
  • Loading branch information
leoetlino committed Jan 4, 2020
1 parent 94c5460 commit ad75215
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Common/Config/Config.cpp
Expand Up @@ -35,7 +35,7 @@ using ReadLock = std::shared_lock<std::shared_mutex>;
using WriteLock = std::unique_lock<std::shared_mutex>;
#endif

void AddLayerInternal(std::shared_ptr<Layer> layer)
static void AddLayerInternal(std::shared_ptr<Layer> layer)
{
{
WriteLock lock(s_layers_rw_lock);
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/BootManager.cpp
Expand Up @@ -425,6 +425,8 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
case DiscIO::Region::NTSC_K:
Config::SetCurrent(Config::SYSCONF_COUNTRY, 0x88); // South Korea
break;
case DiscIO::Region::Unknown:
break;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/AddressSpace.cpp
Expand Up @@ -303,7 +303,7 @@ struct CompositeAddressSpaceAccessors : Accessors

struct SmallBlockAccessors : Accessors
{
SmallBlockAccessors(u8** alloc_base, u32 size) : alloc_base(alloc_base), size(size) {}
SmallBlockAccessors(u8** alloc_base_, u32 size_) : alloc_base{alloc_base_}, size{size_} {}

bool IsValidAddress(u32 address) const override
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/GCMemcard/GCMemcard.cpp
Expand Up @@ -321,7 +321,7 @@ bool GCMemcard::Save()
return mcdFile.Close();
}

std::pair<u16, u16> CalculateMemcardChecksums(const u8* data, size_t size)
static std::pair<u16, u16> CalculateMemcardChecksums(const u8* data, size_t size)
{
assert(size % 2 == 0);
u16 csum = 0;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.cpp
Expand Up @@ -211,7 +211,7 @@ void WiimoteDevice::Activate(bool ready)

void WiimoteDevice::EventConnectionAccepted()
{
DEBUG_LOG(IOS_WIIMOTE, "ConnectionState %x -> CONN_LINKING", m_connection_state);
DEBUG_LOG(IOS_WIIMOTE, "ConnectionState %x -> CONN_LINKING", int(m_connection_state));
m_connection_state = ConnectionState::Linking;
}

Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/IOS/USB/USB_KBD.cpp
Expand Up @@ -176,9 +176,9 @@ constexpr std::array<u8, 256> s_key_codes_azerty{};
#endif
} // Anonymous namespace

USB_KBD::MessageData::MessageData(MessageType type, u8 modifiers, PressedKeyData pressed_keys)
: msg_type{Common::swap32(static_cast<u32>(type))}, modifiers{modifiers}, pressed_keys{
pressed_keys}
USB_KBD::MessageData::MessageData(MessageType type, u8 modifiers_, PressedKeyData pressed_keys_)
: msg_type{Common::swap32(static_cast<u32>(type))}, modifiers{modifiers_}, pressed_keys{
pressed_keys_}
{
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DiscIO/Blob.h
Expand Up @@ -53,7 +53,7 @@ class BlobReader
{
T temp;
if (!Read(offset, sizeof(T), reinterpret_cast<u8*>(&temp)))
return {};
return std::nullopt;
return Common::FromBigEndian(temp);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DiscIO/DirectoryBlob.cpp
Expand Up @@ -451,7 +451,7 @@ void DirectoryBlobReader::SetWiiRegionData(const std::string& game_partition_roo
ERROR_LOG(DISCIO, "Couldn't read age ratings from %s", region_bin_path.c_str());

constexpr u64 WII_REGION_DATA_ADDRESS = 0x4E000;
constexpr u64 WII_REGION_DATA_SIZE = 0x20;
[[maybe_unused]] constexpr u64 WII_REGION_DATA_SIZE = 0x20;
m_nonpartition_contents.Add(WII_REGION_DATA_ADDRESS, m_wii_region_data);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DiscIO/Volume.h
Expand Up @@ -50,7 +50,7 @@ class Volume
{
T temp;
if (!Read(offset, sizeof(T), reinterpret_cast<u8*>(&temp), partition))
return {};
return std::nullopt;
return Common::FromBigEndian(temp);
}
std::optional<u64> ReadSwappedAndShifted(u64 offset, const Partition& partition) const
Expand Down
2 changes: 0 additions & 2 deletions Source/Core/DiscIO/VolumeVerifier.cpp
Expand Up @@ -88,11 +88,9 @@ void RedumpVerifier::Start(const Volume& volume)
return {};
}

DownloadStatus status;
{
std::lock_guard lk(download_state->mutex);
download_state->status = DownloadDatfile(system, download_state->status);
status = download_state->status;
}

switch (download_state->status)
Expand Down

0 comments on commit ad75215

Please sign in to comment.