Skip to content

Commit

Permalink
Merge pull request #4411 from JosJuice/blob-nullptr
Browse files Browse the repository at this point in the history
Remove Blob nullptr checks from Volume code
  • Loading branch information
degasus committed Mar 13, 2017
2 parents f83a030 + acec02f commit 8035270
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
11 changes: 5 additions & 6 deletions Source/Core/DiscIO/VolumeGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <utility>
#include <vector>

#include "Common/Assert.h"
#include "Common/ColorUtil.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
Expand All @@ -25,6 +26,7 @@ namespace DiscIO
{
CVolumeGC::CVolumeGC(std::unique_ptr<IBlobReader> reader) : m_pReader(std::move(reader))
{
_assert_(m_pReader);
}

CVolumeGC::~CVolumeGC()
Expand All @@ -36,9 +38,6 @@ bool CVolumeGC::Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) const
if (decrypt)
PanicAlertT("Tried to decrypt data from a non-Wii volume");

if (m_pReader == nullptr)
return false;

FileMon::FindFilename(_Offset);

return m_pReader->Read(_Offset, _Length, _pBuffer);
Expand Down Expand Up @@ -162,17 +161,17 @@ std::string CVolumeGC::GetApploaderDate() const

BlobType CVolumeGC::GetBlobType() const
{
return m_pReader ? m_pReader->GetBlobType() : BlobType::PLAIN;
return m_pReader->GetBlobType();
}

u64 CVolumeGC::GetSize() const
{
return m_pReader ? m_pReader->GetDataSize() : 0;
return m_pReader->GetDataSize();
}

u64 CVolumeGC::GetRawSize() const
{
return m_pReader ? m_pReader->GetRawSize() : 0;
return m_pReader->GetRawSize();
}

u8 CVolumeGC::GetDiscNumber() const
Expand Down
12 changes: 6 additions & 6 deletions Source/Core/DiscIO/VolumeWad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <vector>

#include "Common/Align.h"
#include "Common/Assert.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
Expand All @@ -24,6 +25,8 @@ namespace DiscIO
{
CVolumeWAD::CVolumeWAD(std::unique_ptr<IBlobReader> reader) : m_reader(std::move(reader))
{
_assert_(m_reader);

// Source: http://wiibrew.org/wiki/WAD_files
ReadSwapped(0x00, &m_hdr_size, false);
ReadSwapped(0x08, &m_cert_size, false);
Expand Down Expand Up @@ -57,9 +60,6 @@ bool CVolumeWAD::Read(u64 offset, u64 length, u8* buffer, bool decrypt) const
if (decrypt)
PanicAlertT("Tried to decrypt data from a non-Wii volume");

if (m_reader == nullptr)
return false;

return m_reader->Read(offset, length, buffer);
}

Expand Down Expand Up @@ -150,17 +150,17 @@ std::vector<u32> CVolumeWAD::GetBanner(int* width, int* height) const

BlobType CVolumeWAD::GetBlobType() const
{
return m_reader ? m_reader->GetBlobType() : BlobType::PLAIN;
return m_reader->GetBlobType();
}

u64 CVolumeWAD::GetSize() const
{
return m_reader ? m_reader->GetDataSize() : 0;
return m_reader->GetDataSize();
}

u64 CVolumeWAD::GetRawSize() const
{
return m_reader ? m_reader->GetRawSize() : 0;
return m_reader->GetRawSize();
}

} // namespace
12 changes: 6 additions & 6 deletions Source/Core/DiscIO/VolumeWiiCrypted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <utility>
#include <vector>

#include "Common/Assert.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
Expand All @@ -33,6 +34,8 @@ CVolumeWiiCrypted::CVolumeWiiCrypted(std::unique_ptr<IBlobReader> reader, u64 _V
: m_pReader(std::move(reader)), m_AES_ctx(std::make_unique<mbedtls_aes_context>()),
m_VolumeOffset(_VolumeOffset), m_dataOffset(0x20000), m_LastDecryptedBlockOffset(-1)
{
_assert_(m_pReader);

mbedtls_aes_setkey_dec(m_AES_ctx.get(), _pVolumeKey, 128);
}

Expand All @@ -53,9 +56,6 @@ CVolumeWiiCrypted::~CVolumeWiiCrypted()

bool CVolumeWiiCrypted::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer, bool decrypt) const
{
if (m_pReader == nullptr)
return false;

if (!decrypt)
return m_pReader->Read(_ReadOffset, _Length, _pBuffer);

Expand Down Expand Up @@ -275,17 +275,17 @@ u8 CVolumeWiiCrypted::GetDiscNumber() const

BlobType CVolumeWiiCrypted::GetBlobType() const
{
return m_pReader ? m_pReader->GetBlobType() : BlobType::PLAIN;
return m_pReader->GetBlobType();
}

u64 CVolumeWiiCrypted::GetSize() const
{
return m_pReader ? m_pReader->GetDataSize() : 0;
return m_pReader->GetDataSize();
}

u64 CVolumeWiiCrypted::GetRawSize() const
{
return m_pReader ? m_pReader->GetRawSize() : 0;
return m_pReader->GetRawSize();
}

bool CVolumeWiiCrypted::CheckIntegrity() const
Expand Down

0 comments on commit 8035270

Please sign in to comment.