Merged
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnsures wheel speed settings are corrected to the valid range and applied when the configured value is out of bounds. Sequence diagram for corrected wheel speed setting in setWheelSpeedsequenceDiagram
participant Manager
participant WheelSpeed
participant Logger
Manager->>Manager: setWheelSpeed()
Manager->>Manager: read configuredSpeed
Manager->>Manager: determine min, max
alt speed < min
Manager->>Manager: speed = min
Manager-->>WheelSpeed: defer Set(speed)
else speed > max
Manager->>Manager: speed = max
Manager-->>WheelSpeed: defer Set(speed)
else within range
Note over Manager: no deferred Set
end
Manager-->>Logger: Debug("setWheelSpeed", speed)
Manager-->>WheelSpeed: (deferred) Set(speed) when out of range
Manager-->>Manager: return
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Using
defer m.WheelSpeed.Set(speed)inside each bounds branch means the debug log will print the unclamped value and the setter will run later, which is likely unintended; consider callingSetimmediately (or once after clamping) so the log and state reflect the corrected value synchronously. - If this method can be called frequently (e.g., in a loop or on high‑frequency events), deferring
WheelSpeed.Seton each invocation may cause unnecessary stacking of deferred calls; it would be leaner and clearer to callSetdirectly after computing the finalspeed.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Using `defer m.WheelSpeed.Set(speed)` inside each bounds branch means the debug log will print the unclamped value and the setter will run later, which is likely unintended; consider calling `Set` immediately (or once after clamping) so the log and state reflect the corrected value synchronously.
- If this method can be called frequently (e.g., in a loop or on high‑frequency events), deferring `WheelSpeed.Set` on each invocation may cause unnecessary stacking of deferred calls; it would be leaner and clearer to call `Set` directly after computing the final `speed`.
## Individual Comments
### Comment 1
<location path="inputdevices1/manager.go" line_range="117" />
<code_context>
// speed range is [1,100]
if speed < uint32(min) {
speed = uint32(min)
+ defer m.WheelSpeed.Set(speed)
} else if speed > uint32(max) {
speed = uint32(max)
</code_context>
<issue_to_address>
**suggestion:** Using `defer` inside these branches is likely unnecessary and may be misleading or inefficient.
Since the only work after clamping is a debug log before returning, deferring `WheelSpeed.Set(speed)` adds indirection without real benefit and hides when the final value is applied. It also causes defers to accumulate on each call (e.g., in a loop) until return. Prefer calling `m.WheelSpeed.Set(speed)` immediately after clamping, or once at the end of the function, instead of deferring it inside the branches.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
8939d25 to
afa7061
Compare
mhduiy
previously approved these changes
Feb 26, 2026
当设置滚轮配置超出范围时,矫正配置 Log: 当设置滚轮配置超出范围时,矫正配置 PMS: BUG-348133 Influence: 滚轮速度
deepin pr auto review这份代码变更主要包含两部分内容:版权年份更新和逻辑调整。以下是对这两部分的详细审查和改进意见: 1. 版权年份变更-// SPDX-FileCopyrightText: 2018 - 2022 UnionTech Software Technology Co., Ltd.
+// SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd.审查意见:
2.
|
mhduiy
approved these changes
Feb 27, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602, mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
当设置滚轮配置超出范围时,矫正配置
Log: 当设置滚轮配置超出范围时,矫正配置
PMS: BUG-348133
Influence: 滚轮速度
Summary by Sourcery
Bug Fixes: