Handle cases when std::optional does not contain a value

This commit is contained in:
B3n30 2018-10-05 16:51:33 +02:00
parent d37a2270d6
commit 2306af3600
9 changed files with 15 additions and 7 deletions

View file

@ -317,7 +317,7 @@ void ConfigureInput::setPollingResult(const Common::ParamPackage& params, bool a
poller->Stop(); poller->Stop();
} }
if (!abort) { if (!abort && input_setter) {
(*input_setter)(params); (*input_setter)(params);
} }

View file

@ -116,6 +116,7 @@ System::ResultStatus System::Load(EmuWindow& emu_window, const std::string& file
} }
} }
ASSERT(system_mode.first);
ResultStatus init_result{Init(emu_window, *system_mode.first)}; ResultStatus init_result{Init(emu_window, *system_mode.first)};
if (init_result != ResultStatus::Success) { if (init_result != ResultStatus::Success) {
LOG_CRITICAL(Core, "Failed to initialize system (Error {})!", LOG_CRITICAL(Core, "Failed to initialize system (Error {})!",

View file

@ -147,7 +147,9 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
if (base_address == 0 && target_address == 0) { if (base_address == 0 && target_address == 0) {
// Calculate the address at which to map the memory block. // Calculate the address at which to map the memory block.
target_address = *Memory::PhysicalToVirtualAddress(linear_heap_phys_address); auto maybe_vaddr = Memory::PhysicalToVirtualAddress(linear_heap_phys_address);
ASSERT(maybe_vaddr);
target_address = *maybe_vaddr;
} }
// Map the memory block into the target process // Map the memory block into the target process

View file

@ -142,7 +142,6 @@ public:
private: private:
/// Parameter data to be returned in the next call to Glance/ReceiveParameter. /// Parameter data to be returned in the next call to Glance/ReceiveParameter.
/// TODO(Subv): Use std::optional once we migrate to C++17.
std::optional<MessageParameter> next_parameter; std::optional<MessageParameter> next_parameter;
static constexpr std::size_t NumAppletSlot = 4; static constexpr std::size_t NumAppletSlot = 4;

View file

@ -205,8 +205,10 @@ void Module::Interface::GetSharedFont(Kernel::HLERequestContext& ctx) {
// The shared font has to be relocated to the new address before being passed to the // The shared font has to be relocated to the new address before being passed to the
// application. // application.
VAddr target_address = auto maybe_vaddr =
*Memory::PhysicalToVirtualAddress(apt->shared_font_mem->linear_heap_phys_address); Memory::PhysicalToVirtualAddress(apt->shared_font_mem->linear_heap_phys_address);
ASSERT(maybe_vaddr);
VAddr target_address = *maybe_vaddr;
if (!apt->shared_font_relocated) { if (!apt->shared_font_relocated) {
BCFNT::RelocateSharedFont(apt->shared_font_mem, target_address); BCFNT::RelocateSharedFont(apt->shared_font_mem, target_address);
apt->shared_font_relocated = true; apt->shared_font_relocated = true;

View file

@ -433,7 +433,9 @@ void RasterizerFlushVirtualRegion(VAddr start, u32 size, FlushMode mode) {
VAddr overlap_start = std::max(start, region_start); VAddr overlap_start = std::max(start, region_start);
VAddr overlap_end = std::min(end, region_end); VAddr overlap_end = std::min(end, region_end);
PAddr physical_start = *TryVirtualToPhysicalAddress(overlap_start); auto maybe_paddr = TryVirtualToPhysicalAddress(overlap_start);
ASSERT(maybe_paddr);
PAddr physical_start = *maybe_paddr;
u32 overlap_size = overlap_end - overlap_start; u32 overlap_size = overlap_end - overlap_start;
auto* rasterizer = VideoCore::g_renderer->Rasterizer(); auto* rasterizer = VideoCore::g_renderer->Rasterizer();

View file

@ -42,7 +42,7 @@ public:
std::unique_ptr<Input::TouchDevice> Create(const Common::ParamPackage& params) override { std::unique_ptr<Input::TouchDevice> Create(const Common::ParamPackage& params) override {
{ {
std::lock_guard<std::mutex> guard(status->update_mutex); std::lock_guard<std::mutex> guard(status->update_mutex);
status->touch_calibration.reset(); status->touch_calibration.emplace();
// These default values work well for DS4 but probably not other touch inputs // These default values work well for DS4 but probably not other touch inputs
status->touch_calibration->min_x = params.Get("min_x", 100); status->touch_calibration->min_x = params.Get("min_x", 100);
status->touch_calibration->min_y = params.Get("min_y", 50); status->touch_calibration->min_y = params.Get("min_y", 50);

View file

@ -948,6 +948,7 @@ Surface FindMatch(const SurfaceCache& surface_cache, const SurfaceParams& params
return std::make_pair(surface->CanSubRect(params), surface->GetInterval()); return std::make_pair(surface->CanSubRect(params), surface->GetInterval());
}); });
IsMatch_Helper(std::integral_constant<MatchFlags, MatchFlags::Copy>{}, [&] { IsMatch_Helper(std::integral_constant<MatchFlags, MatchFlags::Copy>{}, [&] {
ASSERT(validate_interval);
auto copy_interval = auto copy_interval =
params.FromInterval(*validate_interval).GetCopyableInterval(surface); params.FromInterval(*validate_interval).GetCopyableInterval(surface);
bool matched = boost::icl::length(copy_interval & *validate_interval) != 0 && bool matched = boost::icl::length(copy_interval & *validate_interval) != 0 &&

View file

@ -600,6 +600,7 @@ void JitShader::Compile_BREAKC(Instruction instr) {
Compile_Assert(looping, "BREAKC must be inside a LOOP"); Compile_Assert(looping, "BREAKC must be inside a LOOP");
if (looping) { if (looping) {
Compile_EvaluateCondition(instr); Compile_EvaluateCondition(instr);
ASSERT(loop_break_label);
jnz(*loop_break_label); jnz(*loop_break_label);
} }
} }