summaryrefslogtreecommitdiff
path: root/src/core/hle/service/hid
diff options
context:
space:
mode:
authorGravatar liamwhite2023-11-03 09:14:17 -0400
committerGravatar GitHub2023-11-03 09:14:17 -0400
commiteda403388af14b55d56753b4f887fadec129522c (patch)
tree6bd78480d54fa0a8198fca583ed18e0962f0cbad /src/core/hle/service/hid
parentMerge pull request #11947 from german77/battery (diff)
parentservice: hid: Ensure GetNextEntryIndex can't fail (diff)
downloadyuzu-eda403388af14b55d56753b4f887fadec129522c.tar.gz
yuzu-eda403388af14b55d56753b4f887fadec129522c.tar.xz
yuzu-eda403388af14b55d56753b4f887fadec129522c.zip
Merge pull request #11948 from german77/hard_ring
service: hid: Ensure GetNextEntryIndex can't fail
Diffstat (limited to 'src/core/hle/service/hid')
-rw-r--r--src/core/hle/service/hid/ring_lifo.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/core/hle/service/hid/ring_lifo.h b/src/core/hle/service/hid/ring_lifo.h
index 65eb7ea02..0816784e0 100644
--- a/src/core/hle/service/hid/ring_lifo.h
+++ b/src/core/hle/service/hid/ring_lifo.h
@@ -32,15 +32,15 @@ struct Lifo {
32 } 32 }
33 33
34 std::size_t GetPreviousEntryIndex() const { 34 std::size_t GetPreviousEntryIndex() const {
35 return static_cast<size_t>((buffer_tail + total_buffer_count - 1) % total_buffer_count); 35 return static_cast<size_t>((buffer_tail + max_buffer_size - 1) % max_buffer_size);
36 } 36 }
37 37
38 std::size_t GetNextEntryIndex() const { 38 std::size_t GetNextEntryIndex() const {
39 return static_cast<size_t>((buffer_tail + 1) % total_buffer_count); 39 return static_cast<size_t>((buffer_tail + 1) % max_buffer_size);
40 } 40 }
41 41
42 void WriteNextEntry(const State& new_state) { 42 void WriteNextEntry(const State& new_state) {
43 if (buffer_count < total_buffer_count - 1) { 43 if (buffer_count < static_cast<s64>(max_buffer_size) - 1) {
44 buffer_count++; 44 buffer_count++;
45 } 45 }
46 buffer_tail = GetNextEntryIndex(); 46 buffer_tail = GetNextEntryIndex();