refactor(modules): drop redundant wl_resource type checks - #1451
Merged
wineee merged 1 commit intoSep 29, 2026
Merged
Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe handlers now rely on libwayland to reject null, unknown, destroyed, or incorrectly typed object arguments before invocation, eliminating duplicated resource checks while retaining checks for client ownership, resource state, wrapper availability, and protocol-specific validation. Sequence diagram for libwayland request object validationsequenceDiagram
participant Client
participant Wayland as libwayland
participant Handler as RequestHandler
participant Resource as ResourceAPI
Client->>Wayland: request with object id
Wayland->>Wayland: wl_connection_demarshal()
alt invalid object id or type
Wayland-->>Client: WL_DISPLAY_ERROR_INVALID_METHOD
else valid protocol object
Wayland->>Handler: invoke request handler
Handler->>Resource: perform ownership/state/wrapper checks
Resource-->>Handler: validation result
end
Flow diagram for simplified object request handlingflowchart TD
A[Wayland request received] --> B{libwayland object validation}
B -->|invalid, null, unknown, destroyed, or wrong type| C[Reject before handler]
B -->|valid protocol-declared object| D[Invoke module handler]
D --> E{Meaningful module checks}
E -->|ownership, resource state, wrapper, or protocol validation fails| F[Post protocol error]
E -->|valid| G[Perform requested operation]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin-wm
force-pushed
the
agent/developer/b72c7f2fcdc2
branch
from
September 29, 2026 09:08
8e7a52b to
f09db59
Compare
Contributor
Author
|
recheck |
deepin-wm
force-pushed
the
agent/developer/b72c7f2fcdc2
branch
2 times, most recently
from
September 29, 2026 09:52
e754fd7 to
9ec8e45
Compare
deepin-wm
marked this pull request as draft
September 29, 2026 09:52
deepin-wm
marked this pull request as ready for review
September 29, 2026 09:56
wineee
approved these changes
Sep 29, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-wm, wineee 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 |
1. Remove the unreachable strcmp(wl_resource_get_class()) checks in the decoration, active-notify, region-watch and xwindow-control request handlers. 2. libwayland already validates object arguments before a handler runs: non-nullable object args are never NULL, and unknown ids or type mismatches fail dispatch with WL_DISPLAY_ERROR_INVALID_METHOD. 3. Drop the now-unused <cstring>/<string.h> includes; keep the real checks (cross-client ownership, inert resources, missing wrappers). Log: Remove redundant wl_resource type checks already done by libwayland dispatch Influence: 1. Build treeland and confirm it compiles and links. 2. Start treeland, run a client that drives decoration, active-notify, region-watch and xwindow-control requests, and confirm normal behavior. 3. Send a request with an invalid object id from a client and verify the compositor reports a protocol error instead of crashing. refactor(modules): 清理冗余的 wl_resource 类型检查 1. 删除 decoration、active-notify、region-watch、xwindow-control 请求处理函数中不可达的 strcmp(wl_resource_get_class()) 类型检查。 2. libwayland 分发层在调用处理函数前已完成校验:不可空对象参数不会为 NULL,未知对象 id 或类型不匹配会以 WL_DISPLAY_ERROR_INVALID_METHOD 分发失败。 3. 顺带删除不再使用的 <cstring>/<string.h> 头文件;保留跨客户端归属、inert resource 判空与缺失包装对象等必要检查。 Log: 清理请求处理函数中冗余的 wl_resource 类型检查,libwayland 分发层已校验对象类型 Influence: 1. 编译 treeland 确认通过。 2. 启动 treeland,运行客户端遍历 decoration、active-notify、region-watch、xwindow-control 相关请求,确认功能正常。 3. 客户端传入非法对象 id 时,确认合成器返回协议错误而非崩溃。 PMS: TASK-390751 Multica Issue: WM-558
deepin-wm
force-pushed
the
agent/developer/b72c7f2fcdc2
branch
from
September 29, 2026 11:28
9ec8e45 to
96b5f05
Compare
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.
Summary
libwayland already validates object arguments before a request handler runs:
wl_connection_demarshal()rejects id 0 for non-nullable object arguments.wl_closure_lookup_objects()rejects unknown object ids and type mismatches withWL_DISPLAY_ERROR_INVALID_METHOD; the handler is never invoked on error. Server-side destroyed resources are removed from the client object map, so their ids fail lookup as well.Hence in the touched request handlers the object arguments are always non-NULL and of the protocol-declared type; the self-made
strcmp(wl_resource_get_class(...))checks were unreachable dead code. Remove them and the now-unused<cstring>/<string.h>includes.Real checks are kept: cross-client ownership (decoration), inert seat (
wlr_seat_client_from_resource), removed output (WOutput::fromHandleNULL), missingWSurfacewrapper, and the protocol size/anchor enum validations. The capture module / waylibQ_ASSERT(wl_resource_instance_of(...))debug asserts (mirroring wlroots' ownwlr_*_from_resourcestyle) are intentionally left untouched.变更说明
删除四个模块请求处理函数中自行做的 wl_resource 类型检查:libwayland 分发层已在校验对象参数的类型与有效性(
wl_closure_lookup_objects对未知 id / 类型不匹配报WL_DISPLAY_ERROR_INVALID_METHOD,不可空参数不会为 NULL,已销毁 resource 的 id 在服务端对象表中查不到),这些检查不可达。保留跨 client 归属检查、inert resource 判空与协议错误校验。Files changed (+2/−42)
Verification
Full build passes on the build machine:
cmake --preset=default && cmake --build build -j50(1915/1915 targets).Summary by Sourcery
Rely on libwayland’s request dispatch validation instead of duplicating unreachable resource checks in module handlers.
Enhancements:
Chores: