Skip to content

fix(input): correct batch overflow handling - #853

Closed
qiin2333 wants to merge 1 commit into
masterfrom
codex/fix-input-batch-overflow
Closed

fix(input): correct batch overflow handling#853
qiin2333 wants to merge 1 commit into
masterfrom
codex/fix-input-batch-overflow

Conversation

@qiin2333

Copy link
Copy Markdown
Collaborator

改了啥呀

  • 同步上游修复:LizardByte/Sunshine#5456
  • 修正相对鼠标移动、垂直滚轮和水平滚轮合批中的 4 处溢出判断
  • 仅在 16 位有符号加法真正溢出时终止合批

为啥要改

__builtin_add_overflow() 在发生溢出时返回 true,原代码却对结果取反了。这个小小的 ! 把逻辑整个颠倒:正常输入无法合批,极端溢出反而可能写入回绕结果。杂鱼 bug 这次乖乖退场啦。

修复后,高频鼠标和滚轮输入可以按设计合并;发生溢出时则保留两个独立事件,避免位移或滚动量回绕。

验证

  • git diff --check:通过
  • 源码检查:4 处正确溢出判断,0 处残留反向判断
  • 独立边界测试:正常相加、SHRT_MAX + 1SHRT_MIN - 1 均通过
  • 完整 GCC 构建未完成:本机 MSYS2 cc1plus.exe 启动即返回 0xC0000139;备用 Clang 检查被工程现有工具链/依赖兼容问题阻断,未出现由本补丁导致的诊断

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a64ddfc-94b0-40d7-9da8-e2b6ef279722

📥 Commits

Reviewing files that changed from the base of the PR and between c172c62 and 57c1dcf.

📒 Files selected for processing (1)
  • src/input.cpp
📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Windows
🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.{cpp,c,h}

⚙️ CodeRabbit configuration file

src/**/*.{cpp,c,h}: Sunshine 核心 C++ 源码,自托管游戏串流服务器。审查要点:内存安全、 线程安全、RAII 资源管理、安全漏洞。注意预处理宏控制的平台相关代码。

Files:

  • src/input.cpp
🔇 Additional comments (1)
src/input.cpp (1)

1423-1426: LGTM!

Also applies to: 1465-1465, 1486-1486


Summary by CodeRabbit

  • Bug 修复
    • 修复输入消息批处理中的溢出判断问题。
    • 改善相对鼠标移动、垂直滚轮和水平滚轮事件的批处理行为,避免在未溢出时提前终止处理。

Walkthrough

修正输入消息批处理中相对鼠标移动、垂直滚轮和水平滚轮的 16-bit 加法溢出判断,使批处理仅在发生溢出时终止。

Changes

输入批处理溢出判断

Layer / File(s) Summary
修正三类输入批处理的溢出条件
src/input.cpp
相对鼠标移动、垂直滚轮和水平滚轮批处理均改为直接使用 __builtin_add_overflow 的结果,仅在加法溢出时终止批处理。

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: yundi339

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题简洁且准确概括了输入批处理溢出判断修复。
Description check ✅ Passed 描述与本次修改一致,说明了修复内容、原因和验证情况。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-input-batch-overflow

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qiin2333
qiin2333 marked this pull request as ready for review July 27, 2026 15:07
@qiin2333 qiin2333 closed this Jul 27, 2026
@qiin2333
qiin2333 deleted the codex/fix-input-batch-overflow branch July 27, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant