diff options
| author | 2020-10-15 14:49:45 -0400 | |
|---|---|---|
| committer | 2020-10-17 19:50:39 -0400 | |
| commit | be1954e04cb5a0c3a526f78ed5490a5e65310280 (patch) | |
| tree | 267db7ae4be88dbbc288fa605e35d4a2a13839f6 /src/audio_core/splitter_context.cpp | |
| parent | Merge pull request #4787 from lioncash/conversion (diff) | |
| download | yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.gz yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.xz yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.zip | |
core: Fix clang build
Recent changes to the build system that made more warnings be flagged as
errors caused building via clang to break.
Fixes #4795
Diffstat (limited to 'src/audio_core/splitter_context.cpp')
| -rw-r--r-- | src/audio_core/splitter_context.cpp | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/src/audio_core/splitter_context.cpp b/src/audio_core/splitter_context.cpp index f21b53147..f3e870648 100644 --- a/src/audio_core/splitter_context.cpp +++ b/src/audio_core/splitter_context.cpp | |||
| @@ -109,7 +109,7 @@ std::size_t ServerSplitterInfo::Update(SplitterInfo::InInfoPrams& header) { | |||
| 109 | new_connection = true; | 109 | new_connection = true; |
| 110 | // We need to update the size here due to the splitter bug being present and providing an | 110 | // We need to update the size here due to the splitter bug being present and providing an |
| 111 | // incorrect size. We're suppose to also update the header here but we just ignore and continue | 111 | // incorrect size. We're suppose to also update the header here but we just ignore and continue |
| 112 | return (sizeof(s32_le) * (header.length - 1)) + (sizeof(s32_le) * 3); | 112 | return (sizeof(s32_le) * static_cast<size_t>(header.length - 1)) + (sizeof(s32_le) * 3); |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | ServerSplitterDestinationData* ServerSplitterInfo::GetHead() { | 115 | ServerSplitterDestinationData* ServerSplitterInfo::GetHead() { |
| @@ -306,13 +306,14 @@ bool SplitterContext::UpdateInfo(const std::vector<u8>& input, std::size_t& inpu | |||
| 306 | break; | 306 | break; |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | if (header.send_id < 0 || static_cast<std::size_t>(header.send_id) > info_count) { | 309 | const auto send_id = static_cast<std::size_t>(header.send_id); |
| 310 | if (header.send_id < 0 || send_id > info_count) { | ||
| 310 | LOG_ERROR(Audio, "Bad splitter data id"); | 311 | LOG_ERROR(Audio, "Bad splitter data id"); |
| 311 | break; | 312 | break; |
| 312 | } | 313 | } |
| 313 | 314 | ||
| 314 | UpdateOffsets(sizeof(SplitterInfo::InInfoPrams)); | 315 | UpdateOffsets(sizeof(SplitterInfo::InInfoPrams)); |
| 315 | auto& info = GetInfo(header.send_id); | 316 | auto& info = GetInfo(send_id); |
| 316 | if (!RecomposeDestination(info, header, input, input_offset)) { | 317 | if (!RecomposeDestination(info, header, input, input_offset)) { |
| 317 | LOG_ERROR(Audio, "Failed to recompose destination for splitter!"); | 318 | LOG_ERROR(Audio, "Failed to recompose destination for splitter!"); |
| 318 | return false; | 319 | return false; |
| @@ -348,11 +349,12 @@ bool SplitterContext::UpdateData(const std::vector<u8>& input, std::size_t& inpu | |||
| 348 | break; | 349 | break; |
| 349 | } | 350 | } |
| 350 | 351 | ||
| 351 | if (header.splitter_id < 0 || static_cast<std::size_t>(header.splitter_id) > data_count) { | 352 | const auto splitter_id = static_cast<std::size_t>(header.splitter_id); |
| 353 | if (header.splitter_id < 0 || splitter_id > data_count) { | ||
| 352 | LOG_ERROR(Audio, "Bad splitter data id"); | 354 | LOG_ERROR(Audio, "Bad splitter data id"); |
| 353 | break; | 355 | break; |
| 354 | } | 356 | } |
| 355 | GetData(header.splitter_id).Update(header); | 357 | GetData(splitter_id).Update(header); |
| 356 | } | 358 | } |
| 357 | return true; | 359 | return true; |
| 358 | } | 360 | } |
| @@ -386,9 +388,9 @@ bool SplitterContext::RecomposeDestination(ServerSplitterInfo& info, | |||
| 386 | return true; | 388 | return true; |
| 387 | } | 389 | } |
| 388 | 390 | ||
| 389 | auto* start_head = &GetData(header.resource_id_base); | 391 | auto* start_head = &GetData(static_cast<u32>(header.resource_id_base)); |
| 390 | current_head = start_head; | 392 | current_head = start_head; |
| 391 | std::vector<s32_le> resource_ids(size - 1); | 393 | std::vector<s32_le> resource_ids(static_cast<size_t>(size - 1)); |
| 392 | if (!AudioCommon::CanConsumeBuffer(input.size(), input_offset, | 394 | if (!AudioCommon::CanConsumeBuffer(input.size(), input_offset, |
| 393 | resource_ids.size() * sizeof(s32_le))) { | 395 | resource_ids.size() * sizeof(s32_le))) { |
| 394 | LOG_ERROR(Audio, "Buffer is an invalid size!"); | 396 | LOG_ERROR(Audio, "Buffer is an invalid size!"); |
| @@ -397,8 +399,8 @@ bool SplitterContext::RecomposeDestination(ServerSplitterInfo& info, | |||
| 397 | std::memcpy(resource_ids.data(), input.data() + input_offset, | 399 | std::memcpy(resource_ids.data(), input.data() + input_offset, |
| 398 | resource_ids.size() * sizeof(s32_le)); | 400 | resource_ids.size() * sizeof(s32_le)); |
| 399 | 401 | ||
| 400 | for (auto resource_id : resource_ids) { | 402 | for (const auto resource_id : resource_ids) { |
| 401 | auto* head = &GetData(resource_id); | 403 | auto* head = &GetData(static_cast<u32>(resource_id)); |
| 402 | current_head->SetNextDestination(head); | 404 | current_head->SetNextDestination(head); |
| 403 | current_head = head; | 405 | current_head = head; |
| 404 | } | 406 | } |
| @@ -444,7 +446,7 @@ bool NodeStates::DepthFirstSearch(EdgeMatrix& edge_matrix) { | |||
| 444 | const auto node_id = static_cast<s32>(i); | 446 | const auto node_id = static_cast<s32>(i); |
| 445 | 447 | ||
| 446 | // If we don't have a state, send to our index stack for work | 448 | // If we don't have a state, send to our index stack for work |
| 447 | if (GetState(i) == NodeStates::State::NoState) { | 449 | if (GetState(i) == State::NoState) { |
| 448 | index_stack.push(node_id); | 450 | index_stack.push(node_id); |
| 449 | } | 451 | } |
| 450 | 452 | ||
| @@ -453,19 +455,19 @@ bool NodeStates::DepthFirstSearch(EdgeMatrix& edge_matrix) { | |||
| 453 | // Get the current node | 455 | // Get the current node |
| 454 | const auto current_stack_index = index_stack.top(); | 456 | const auto current_stack_index = index_stack.top(); |
| 455 | // Check if we've seen the node yet | 457 | // Check if we've seen the node yet |
| 456 | const auto index_state = GetState(current_stack_index); | 458 | const auto index_state = GetState(static_cast<u32>(current_stack_index)); |
| 457 | if (index_state == NodeStates::State::NoState) { | 459 | if (index_state == State::NoState) { |
| 458 | // Mark the node as seen | 460 | // Mark the node as seen |
| 459 | UpdateState(NodeStates::State::InFound, current_stack_index); | 461 | UpdateState(State::InFound, static_cast<u32>(current_stack_index)); |
| 460 | } else if (index_state == NodeStates::State::InFound) { | 462 | } else if (index_state == State::InFound) { |
| 461 | // We've seen this node before, mark it as completed | 463 | // We've seen this node before, mark it as completed |
| 462 | UpdateState(NodeStates::State::InCompleted, current_stack_index); | 464 | UpdateState(State::InCompleted, static_cast<u32>(current_stack_index)); |
| 463 | // Update our index list | 465 | // Update our index list |
| 464 | PushTsortResult(current_stack_index); | 466 | PushTsortResult(current_stack_index); |
| 465 | // Pop the stack | 467 | // Pop the stack |
| 466 | index_stack.pop(); | 468 | index_stack.pop(); |
| 467 | continue; | 469 | continue; |
| 468 | } else if (index_state == NodeStates::State::InCompleted) { | 470 | } else if (index_state == State::InCompleted) { |
| 469 | // If our node is already sorted, clear it | 471 | // If our node is already sorted, clear it |
| 470 | index_stack.pop(); | 472 | index_stack.pop(); |
| 471 | continue; | 473 | continue; |
| @@ -479,11 +481,11 @@ bool NodeStates::DepthFirstSearch(EdgeMatrix& edge_matrix) { | |||
| 479 | } | 481 | } |
| 480 | 482 | ||
| 481 | // Check if our node exists | 483 | // Check if our node exists |
| 482 | const auto node_state = GetState(j); | 484 | const auto node_state = GetState(static_cast<u32>(j)); |
| 483 | if (node_state == NodeStates::State::NoState) { | 485 | if (node_state == State::NoState) { |
| 484 | // Add more work | 486 | // Add more work |
| 485 | index_stack.push(j); | 487 | index_stack.push(j); |
| 486 | } else if (node_state == NodeStates::State::InFound) { | 488 | } else if (node_state == State::InFound) { |
| 487 | UNREACHABLE_MSG("Node start marked as found"); | 489 | UNREACHABLE_MSG("Node start marked as found"); |
| 488 | ResetState(); | 490 | ResetState(); |
| 489 | return false; | 491 | return false; |
| @@ -507,17 +509,17 @@ void NodeStates::ResetState() { | |||
| 507 | } | 509 | } |
| 508 | } | 510 | } |
| 509 | 511 | ||
| 510 | void NodeStates::UpdateState(NodeStates::State state, std::size_t i) { | 512 | void NodeStates::UpdateState(State state, std::size_t i) { |
| 511 | switch (state) { | 513 | switch (state) { |
| 512 | case NodeStates::State::NoState: | 514 | case State::NoState: |
| 513 | was_node_found[i] = false; | 515 | was_node_found[i] = false; |
| 514 | was_node_completed[i] = false; | 516 | was_node_completed[i] = false; |
| 515 | break; | 517 | break; |
| 516 | case NodeStates::State::InFound: | 518 | case State::InFound: |
| 517 | was_node_found[i] = true; | 519 | was_node_found[i] = true; |
| 518 | was_node_completed[i] = false; | 520 | was_node_completed[i] = false; |
| 519 | break; | 521 | break; |
| 520 | case NodeStates::State::InCompleted: | 522 | case State::InCompleted: |
| 521 | was_node_found[i] = false; | 523 | was_node_found[i] = false; |
| 522 | was_node_completed[i] = true; | 524 | was_node_completed[i] = true; |
| 523 | break; | 525 | break; |
| @@ -528,13 +530,13 @@ NodeStates::State NodeStates::GetState(std::size_t i) { | |||
| 528 | ASSERT(i < node_count); | 530 | ASSERT(i < node_count); |
| 529 | if (was_node_found[i]) { | 531 | if (was_node_found[i]) { |
| 530 | // If our node exists in our found list | 532 | // If our node exists in our found list |
| 531 | return NodeStates::State::InFound; | 533 | return State::InFound; |
| 532 | } else if (was_node_completed[i]) { | 534 | } else if (was_node_completed[i]) { |
| 533 | // If node is in the completed list | 535 | // If node is in the completed list |
| 534 | return NodeStates::State::InCompleted; | 536 | return State::InCompleted; |
| 535 | } else { | 537 | } else { |
| 536 | // If in neither | 538 | // If in neither |
| 537 | return NodeStates::State::NoState; | 539 | return State::NoState; |
| 538 | } | 540 | } |
| 539 | } | 541 | } |
| 540 | 542 | ||
| @@ -601,16 +603,16 @@ std::size_t EdgeMatrix::GetNodeCount() const { | |||
| 601 | 603 | ||
| 602 | void EdgeMatrix::SetState(s32 a, s32 b, bool state) { | 604 | void EdgeMatrix::SetState(s32 a, s32 b, bool state) { |
| 603 | ASSERT(InRange(a, b)); | 605 | ASSERT(InRange(a, b)); |
| 604 | edge_matrix.at(a * node_count + b) = state; | 606 | edge_matrix.at(static_cast<u32>(a) * node_count + static_cast<u32>(b)) = state; |
| 605 | } | 607 | } |
| 606 | 608 | ||
| 607 | bool EdgeMatrix::GetState(s32 a, s32 b) { | 609 | bool EdgeMatrix::GetState(s32 a, s32 b) { |
| 608 | ASSERT(InRange(a, b)); | 610 | ASSERT(InRange(a, b)); |
| 609 | return edge_matrix.at(a * node_count + b); | 611 | return edge_matrix.at(static_cast<u32>(a) * node_count + static_cast<u32>(b)); |
| 610 | } | 612 | } |
| 611 | 613 | ||
| 612 | bool EdgeMatrix::InRange(s32 a, s32 b) const { | 614 | bool EdgeMatrix::InRange(s32 a, s32 b) const { |
| 613 | const std::size_t pos = a * node_count + b; | 615 | const std::size_t pos = static_cast<u32>(a) * node_count + static_cast<u32>(b); |
| 614 | return pos < (node_count * node_count); | 616 | return pos < (node_count * node_count); |
| 615 | } | 617 | } |
| 616 | 618 | ||