detached a13db1f

#134 chore(lint): fix all golangci-lint findings and enforce lint in checks

state
merged · e2f6a0c · squash
branch
chore/lint-triage → main
opened
bnema ·
updated

Resolves #132.

  • Fixes all golangci-lint findings (the issue's 71 was a capped count; the real total was 707 errcheck plus 21 staticcheck).
  • Consequential Close/fence/lease/lock/write errors are returned or logged with a component field. Cleanup-only calls ignore the error explicitly with _ =. Close is never retried, and a fence close failure never fails a KMS commit.
  • Adds .golangci.yml, make lint (golangci-lint v2.15.0 required), a dependency of make check on lint, and a CI lint step.

Checks: golangci-lint 0 issues, make check, make race, make mocks-check, staticcheck. Known: TestTrimCaptureResources/cursor (vulkan) is flaky on main too (~1/6), unrelated.

CommitSubjectAuthorDateSignatureStatus
a13db1ffix(drm,xcursor): bound index and pnp reads and join close errorsbrice GPG Verified
5fc7a12fix(cli): report session rm connection close error after cleanupbrice GPG Verified
74ee8c4fix(vulkan): log dup fd close failure instead of failing importbrice GPG Verified
be13e6afix(ports): return lease fd close errors to callersbrice GPG Verified
55ed8adfix(seat,xwayland,screencast): log device, lock and bus close failuresbrice GPG Verified
a194c15fix(headless,capture): log fence, index and temp file failuresbrice GPG Verified
2b1dc8erefactor(drm,wayland): pass loggers explicitly to overlay close and socket listenbrice GPG Verified
e2643d6refactor(logging): host close helpers in the allowed shared adapter packagebrice GPG Verified
fc96b18fix(ports): report lease fd close failures through a callbackbrice GPG Verified
5fac7ddfix(cli): keep session start kill exit status explicitbrice GPG Verified
1c26955fix(adapters): log protocol object creation and connection close failuresbrice GPG Verified
b1190d4fix(vulkan): join or log descriptor and mapping close failuresbrice GPG Verified
16dfa05fix(adapters): join or log close failures of pollers, files and temp filesbrice GPG Verified
42177edfix(capture): log fence close failures without changing verdictsbrice GPG Verified
57e0d89fix(xwayland): log descriptor close failuresbrice GPG Verified
35121a7fix(wayland): log or join descriptor close failuresbrice GPG Verified
89d9c8ffix(wayland): log dropped lease fd close failuresbrice GPG Verified
061d7d5fix(cli): join connection and pipe close errors into command errorsbrice GPG Verified
26fdf46fix(control): report cleanup failures instead of discarding thembrice GPG Verified
1eef41dfix(drm): log descriptor close failures on error pathsbrice GPG Verified
5cf39aafix(fdwait,watchdog): join close errors into returned errorsbrice GPG Verified
b156fc9fix(vulkan,cli): wait for clear frame after fence close error and print log shutdown errorsbrice GPG Verified
1bd7f1achore(lint): enforce golangci-lint in local and CI checksbrice GPG Verified
037bcb5test(core): make runner shutdown and descriptor cleanup explicitbrice GPG Verified
99a5d24test(adapters): check operation results and mark cleanup ignoresbrice GPG Verified
1c881e7test(wayland): explicitly discard teardown errorsbrice GPG Verified
857f1abtest(render): make descriptor cleanup errors explicitbrice GPG Verified
bf5663efix(cli): return output and log shutdown errorsbrice GPG Verified
fdfd8fachore(examples): make descriptor cleanup ignores explicitbrice GPG Verified
9b7e468fix(app): report session registry close failuresbrice GPG Verified
d399ae7chore(xwayland): explicitly discard shutdown and socket cleanup errorsbrice GPG Verified
4021ae0fix(xwayland): check X11 lock close and mark control cleanupbrice GPG Verified
40e6c0dfix(wayland): report lease fd close failures and mark owned cleanupbrice GPG Verified
9a4cf5dfix(vulkan): check clear fence close and mark descriptor cleanupbrice GPG Verified
639896efix(adapters): check diagnostic writes and resource release errorsbrice GPG Verified
447b1f6fix(sessiondir): propagate registry and lifetime lock release errorsbrice GPG Verified
91f683efix(fdwait): return errors from both poller descriptor closesbrice GPG Verified
68e724ffix(logging): return session lock close failuresbrice GPG Verified
6882484fix(outputkit): report lease fd close failures and mark capture cleanupbrice GPG Verified
7c79997fix(drm): report fence and lease descriptor close failuresbrice GPG Verified
65dad23chore(lint): apply staticcheck quick fixesbrice GPG Verified

Checks 1

295 files · +1434 -1090
1/1
M .github/workflows/ci.yml +6 -0
@@ -34,6 +34,12 @@ jobs:
3434 - run: |
3535 go install github.com/bnema/hexcheck/cmd/hexcheck@v0.3.1
3636 cd tools && GOBIN=$HOME/go/bin go install tool
37+ - name: Lint
38+ uses: golangci/golangci-lint-action@v9
39+ env:
40+ CGO_ENABLED: "0"
41+ with:
42+ version: v2.15.0
3743 - run: make check
3844 - run: make race
3945 - run: make mocks-check
@@ -34,6 +34,12 @@ jobs:
34 - run: |34 - run: |
35 go install github.com/bnema/hexcheck/cmd/hexcheck@v0.3.135 go install github.com/bnema/hexcheck/cmd/hexcheck@v0.3.1
36 cd tools && GOBIN=$HOME/go/bin go install tool36 cd tools && GOBIN=$HOME/go/bin go install tool
37+ - name: Lint
38+ uses: golangci/golangci-lint-action@v9
39+ env:
40+ CGO_ENABLED: "0"
41+ with:
42+ version: v2.15.0
37 - run: make check43 - run: make check
38 - run: make race44 - run: make race
39 - run: make mocks-check45 - run: make mocks-check
A .golangci.yml +12 -0
@@ -0,0 +1,12 @@
1+version: "2"
2+linters:
3+ default: none
4+ enable:
5+ - errcheck
6+ - govet
7+ - ineffassign
8+ - staticcheck
9+ - unused
10+issues:
11+ max-issues-per-linter: 0
12+ max-same-issues: 0
@@ -0,0 +1,12 @@
1+version: "2"
2+linters:
3+ default: none
4+ enable:
5+ - errcheck
6+ - govet
7+ - ineffassign
8+ - staticcheck
9+ - unused
10+issues:
11+ max-issues-per-linter: 0
12+ max-same-issues: 0
M Makefile +11 -2
@@ -1,4 +1,4 @@
1-.PHONY: build test vet race e2e-xwayland e2e-wayvnc mocks mocks-check spv-check fakes-check log-check arch adapter-imports check perf-check color-check bin tty logs pkg install
1+.PHONY: build test vet lint race e2e-xwayland e2e-wayvnc mocks mocks-check spv-check fakes-check log-check arch adapter-imports check perf-check color-check bin tty logs pkg install
22
33 # 0 runs until quit; set e.g. TTY_TIMEOUT=60s for a safety net.
44 TTY_TIMEOUT ?= 0
@@ -24,6 +24,15 @@ build:
2424 CGO_ENABLED=0 go build ./...
2525 test:
2626 CGO_ENABLED=0 go test ./...
27+GOLANGCI_LINT_VERSION := v2.15.0
28+GOLANGCI_LINT ?= golangci-lint
29+lint:
30+ @command -v "$(GOLANGCI_LINT)" >/dev/null 2>&1 || { echo 'error: golangci-lint is required; install $(GOLANGCI_LINT_VERSION) from https://golangci-lint.run/docs/welcome/install/' >&2; exit 1; }
31+ @version="$$("$(GOLANGCI_LINT)" version)"; case "$$version" in \
32+ *"version $(patsubst v%,%,$(GOLANGCI_LINT_VERSION)) "*) ;; \
33+ *) echo "warning: expected golangci-lint $(GOLANGCI_LINT_VERSION); got $$version" >&2 ;; \
34+ esac
35+ CGO_ENABLED=0 $(GOLANGCI_LINT) run ./...
2736 vet:
2837 CGO_ENABLED=0 go vet ./...
2938 CGO_ENABLED=0 go vet -tags xwayland ./internal/app
@@ -70,7 +79,7 @@ adapter-imports:
7079 perf-check:
7180 CGO_ENABLED=0 go test ./internal/adapters/outputkit/presented ./internal/core ./internal/app ./internal/adapters/drm ./internal/adapters/headless ./internal/adapters/vulkan ./internal/adapters/wayland ./internal/adapters/outputkit/capture ./internal/adapters/outputkit/routing ./internal/adapters/screencast ./internal/adapters/wayland/xwm -run '^(TestLineageObserverDormantAndAllocations|TestWaitNilFencesAllocations|TestAnimateAllocations|TestPublishAllocations|TestPublishExpansionAllocations|TestPublishSubscribersAllocations|TestPublishStashSlideAllocations|TestPublishOverviewAllocations|TestPublishLeavingAllocations|TestOutputRoutingAllocations|TestReportSeenAllocations|TestFrameLifecycleTransitionsAllocations|TestFullscreenShownAllocations|TestFrameDecisionAllocations|TestFrameDecisionExpansionAllocations|TestOverlayExpansionAllocations|TestCommitFrameAllocations|TestColorPipelineAllocations|TestShownBySnapshotAllocations|TestFlipShowsAllocations|TestMRUNoteFocusDoesNotAllocateWhenSettled|TestDueFramesAllocations|TestRenderSteadyStateAllocations|TestRenderExpansionAllocations|TestRenderSteadyStateDMABufAllocations|TestSceneOpaqueRegionAllocations|TestSceneDeltaAllocations|TestAccountFlipAllocations|TestFlipDoneAllocations|TestSceneWalkUnchangedTiledSHM|TestTiledCommitPublishAllocations|TestCapturedCommitApplyAllocations|TestCapturedViewportApplyAllocations|TestEffectiveInputEmptyTreeAllocations|TestHeadlessTiledSHMCallbackAndCopyBudget|TestReleaseHeldAllocations|TestCommitDamageAllocations|TestEmitContentAllocations|TestPresentationPushAllocations|TestPresentationSnapshotAllocations|TestAnimatingFrameSendAllocations|TestContentBatchCycleAllocations|TestWriteMappedAllocations|TestCapturedForwardAllocations|TestCommandForwardAllocations|TestOutboxQueuedDeliveryAllocations|TestCastFrameAllocations|TestCastProducerAllocations|TestCaptureCycleAllocations|TestCaptureCursorCycleAllocations|TestCaptureCursorIdleAllocations|TestCaptureDMABufCopyAllocations|TestLogScenesAllocations|TestOverviewNamedRowsAllocations|TestOverviewWorkspaceSwitchAllocations|TestBufferContentAllocations|TestDueFramesFireScratch|TestRetireSemaphoreAllocatesNothing|TestTableLookupAllocations|TestTableInsertRemoveAllocations|TestPropertyUnchangedAllocations|TestDispatchAllocations|TestConfigureFlushAllocations|TestFocusAllocations|TestSpaceAllocations|TestUnmanagedGeometryAllocations|TestFocusInUnmanagedAllocations|TestUnmanagedPublishAllocations|TestUnmanagedHitAllocations|TestOverrideMovedUnchangedAllocations|TestFullscreenConfigureAllocations|TestKeyboardGrabSyncAllocations|TestSelectionCopyAllocations|TestSelectionINCRChunkAllocations|TestSelectionCopyAllocationsWaylandToX|TestXSettingsNoChangeAllocations|TestSettleLeftAllocs)$$' -count=1
7281 CGO_ENABLED=0 go test -tags xturbo_poison ./internal/adapters/wayland/xwm -count=1
73-check: vet test arch fakes-check log-check perf-check
82+check: lint vet test arch fakes-check log-check perf-check
7483
7584 # On-demand SDR/HDR colour check with examples/testpattern on a headless
7685 # NeferWL. Needs a GPU and /dev/udmabuf; not part of check.
@@ -1,4 +1,4 @@
1-.PHONY: build test vet race e2e-xwayland e2e-wayvnc mocks mocks-check spv-check fakes-check log-check arch adapter-imports check perf-check color-check bin tty logs pkg install1+.PHONY: build test vet lint race e2e-xwayland e2e-wayvnc mocks mocks-check spv-check fakes-check log-check arch adapter-imports check perf-check color-check bin tty logs pkg install
2 2
3 # 0 runs until quit; set e.g. TTY_TIMEOUT=60s for a safety net.3 # 0 runs until quit; set e.g. TTY_TIMEOUT=60s for a safety net.
4 TTY_TIMEOUT ?= 04 TTY_TIMEOUT ?= 0
@@ -24,6 +24,15 @@ build:
24 CGO_ENABLED=0 go build ./...24 CGO_ENABLED=0 go build ./...
25 test:25 test:
26 CGO_ENABLED=0 go test ./...26 CGO_ENABLED=0 go test ./...
27+GOLANGCI_LINT_VERSION := v2.15.0
28+GOLANGCI_LINT ?= golangci-lint
29+lint:
30+ @command -v "$(GOLANGCI_LINT)" >/dev/null 2>&1 || { echo 'error: golangci-lint is required; install $(GOLANGCI_LINT_VERSION) from https://golangci-lint.run/docs/welcome/install/' >&2; exit 1; }
31+ @version="$$("$(GOLANGCI_LINT)" version)"; case "$$version" in \
32+ *"version $(patsubst v%,%,$(GOLANGCI_LINT_VERSION)) "*) ;; \
33+ *) echo "warning: expected golangci-lint $(GOLANGCI_LINT_VERSION); got $$version" >&2 ;; \
34+ esac
35+ CGO_ENABLED=0 $(GOLANGCI_LINT) run ./...
27 vet:36 vet:
28 CGO_ENABLED=0 go vet ./...37 CGO_ENABLED=0 go vet ./...
29 CGO_ENABLED=0 go vet -tags xwayland ./internal/app38 CGO_ENABLED=0 go vet -tags xwayland ./internal/app
@@ -70,7 +79,7 @@ adapter-imports:
70 perf-check:79 perf-check:
71 CGO_ENABLED=0 go test ./internal/adapters/outputkit/presented ./internal/core ./internal/app ./internal/adapters/drm ./internal/adapters/headless ./internal/adapters/vulkan ./internal/adapters/wayland ./internal/adapters/outputkit/capture ./internal/adapters/outputkit/routing ./internal/adapters/screencast ./internal/adapters/wayland/xwm -run '^(TestLineageObserverDormantAndAllocations|TestWaitNilFencesAllocations|TestAnimateAllocations|TestPublishAllocations|TestPublishExpansionAllocations|TestPublishSubscribersAllocations|TestPublishStashSlideAllocations|TestPublishOverviewAllocations|TestPublishLeavingAllocations|TestOutputRoutingAllocations|TestReportSeenAllocations|TestFrameLifecycleTransitionsAllocations|TestFullscreenShownAllocations|TestFrameDecisionAllocations|TestFrameDecisionExpansionAllocations|TestOverlayExpansionAllocations|TestCommitFrameAllocations|TestColorPipelineAllocations|TestShownBySnapshotAllocations|TestFlipShowsAllocations|TestMRUNoteFocusDoesNotAllocateWhenSettled|TestDueFramesAllocations|TestRenderSteadyStateAllocations|TestRenderExpansionAllocations|TestRenderSteadyStateDMABufAllocations|TestSceneOpaqueRegionAllocations|TestSceneDeltaAllocations|TestAccountFlipAllocations|TestFlipDoneAllocations|TestSceneWalkUnchangedTiledSHM|TestTiledCommitPublishAllocations|TestCapturedCommitApplyAllocations|TestCapturedViewportApplyAllocations|TestEffectiveInputEmptyTreeAllocations|TestHeadlessTiledSHMCallbackAndCopyBudget|TestReleaseHeldAllocations|TestCommitDamageAllocations|TestEmitContentAllocations|TestPresentationPushAllocations|TestPresentationSnapshotAllocations|TestAnimatingFrameSendAllocations|TestContentBatchCycleAllocations|TestWriteMappedAllocations|TestCapturedForwardAllocations|TestCommandForwardAllocations|TestOutboxQueuedDeliveryAllocations|TestCastFrameAllocations|TestCastProducerAllocations|TestCaptureCycleAllocations|TestCaptureCursorCycleAllocations|TestCaptureCursorIdleAllocations|TestCaptureDMABufCopyAllocations|TestLogScenesAllocations|TestOverviewNamedRowsAllocations|TestOverviewWorkspaceSwitchAllocations|TestBufferContentAllocations|TestDueFramesFireScratch|TestRetireSemaphoreAllocatesNothing|TestTableLookupAllocations|TestTableInsertRemoveAllocations|TestPropertyUnchangedAllocations|TestDispatchAllocations|TestConfigureFlushAllocations|TestFocusAllocations|TestSpaceAllocations|TestUnmanagedGeometryAllocations|TestFocusInUnmanagedAllocations|TestUnmanagedPublishAllocations|TestUnmanagedHitAllocations|TestOverrideMovedUnchangedAllocations|TestFullscreenConfigureAllocations|TestKeyboardGrabSyncAllocations|TestSelectionCopyAllocations|TestSelectionINCRChunkAllocations|TestSelectionCopyAllocationsWaylandToX|TestXSettingsNoChangeAllocations|TestSettleLeftAllocs)$$' -count=180 CGO_ENABLED=0 go test ./internal/adapters/outputkit/presented ./internal/core ./internal/app ./internal/adapters/drm ./internal/adapters/headless ./internal/adapters/vulkan ./internal/adapters/wayland ./internal/adapters/outputkit/capture ./internal/adapters/outputkit/routing ./internal/adapters/screencast ./internal/adapters/wayland/xwm -run '^(TestLineageObserverDormantAndAllocations|TestWaitNilFencesAllocations|TestAnimateAllocations|TestPublishAllocations|TestPublishExpansionAllocations|TestPublishSubscribersAllocations|TestPublishStashSlideAllocations|TestPublishOverviewAllocations|TestPublishLeavingAllocations|TestOutputRoutingAllocations|TestReportSeenAllocations|TestFrameLifecycleTransitionsAllocations|TestFullscreenShownAllocations|TestFrameDecisionAllocations|TestFrameDecisionExpansionAllocations|TestOverlayExpansionAllocations|TestCommitFrameAllocations|TestColorPipelineAllocations|TestShownBySnapshotAllocations|TestFlipShowsAllocations|TestMRUNoteFocusDoesNotAllocateWhenSettled|TestDueFramesAllocations|TestRenderSteadyStateAllocations|TestRenderExpansionAllocations|TestRenderSteadyStateDMABufAllocations|TestSceneOpaqueRegionAllocations|TestSceneDeltaAllocations|TestAccountFlipAllocations|TestFlipDoneAllocations|TestSceneWalkUnchangedTiledSHM|TestTiledCommitPublishAllocations|TestCapturedCommitApplyAllocations|TestCapturedViewportApplyAllocations|TestEffectiveInputEmptyTreeAllocations|TestHeadlessTiledSHMCallbackAndCopyBudget|TestReleaseHeldAllocations|TestCommitDamageAllocations|TestEmitContentAllocations|TestPresentationPushAllocations|TestPresentationSnapshotAllocations|TestAnimatingFrameSendAllocations|TestContentBatchCycleAllocations|TestWriteMappedAllocations|TestCapturedForwardAllocations|TestCommandForwardAllocations|TestOutboxQueuedDeliveryAllocations|TestCastFrameAllocations|TestCastProducerAllocations|TestCaptureCycleAllocations|TestCaptureCursorCycleAllocations|TestCaptureCursorIdleAllocations|TestCaptureDMABufCopyAllocations|TestLogScenesAllocations|TestOverviewNamedRowsAllocations|TestOverviewWorkspaceSwitchAllocations|TestBufferContentAllocations|TestDueFramesFireScratch|TestRetireSemaphoreAllocatesNothing|TestTableLookupAllocations|TestTableInsertRemoveAllocations|TestPropertyUnchangedAllocations|TestDispatchAllocations|TestConfigureFlushAllocations|TestFocusAllocations|TestSpaceAllocations|TestUnmanagedGeometryAllocations|TestFocusInUnmanagedAllocations|TestUnmanagedPublishAllocations|TestUnmanagedHitAllocations|TestOverrideMovedUnchangedAllocations|TestFullscreenConfigureAllocations|TestKeyboardGrabSyncAllocations|TestSelectionCopyAllocations|TestSelectionINCRChunkAllocations|TestSelectionCopyAllocationsWaylandToX|TestXSettingsNoChangeAllocations|TestSettleLeftAllocs)$$' -count=1
72 CGO_ENABLED=0 go test -tags xturbo_poison ./internal/adapters/wayland/xwm -count=181 CGO_ENABLED=0 go test -tags xturbo_poison ./internal/adapters/wayland/xwm -count=1
73-check: vet test arch fakes-check log-check perf-check82+check: lint vet test arch fakes-check log-check perf-check
74 83
75 # On-demand SDR/HDR colour check with examples/testpattern on a headless84 # On-demand SDR/HDR colour check with examples/testpattern on a headless
76 # NeferWL. Needs a GPU and /dev/udmabuf; not part of check.85 # NeferWL. Needs a GPU and /dev/udmabuf; not part of check.
M examples/testime/main.go +2 -2
@@ -12,10 +12,10 @@ import (
1212 "os"
1313 "time"
1414
15+ "bnema.dev/wlturbo"
1516 clientime "github.com/bnema/go-wayland-bindings/client/inputmethod"
1617 clientcore "github.com/bnema/go-wayland-bindings/client/wayland"
1718 "github.com/bnema/go-wayland-bindings/server/inputmethod"
18- "bnema.dev/wlturbo"
1919 )
2020
2121 func main() {
@@ -86,7 +86,7 @@ func run(preedit, commit string, delay time.Duration, count int) error {
8686 if err != nil {
8787 return err
8888 }
89- defer c.Close()
89+ defer func() { _ = c.Close() }()
9090 if err := c.Roundtrip(); err != nil {
9191 return err
9292 }
@@ -12,10 +12,10 @@ import (
12 "os"12 "os"
13 "time"13 "time"
14 14
15+ "bnema.dev/wlturbo"
15 clientime "github.com/bnema/go-wayland-bindings/client/inputmethod"16 clientime "github.com/bnema/go-wayland-bindings/client/inputmethod"
16 clientcore "github.com/bnema/go-wayland-bindings/client/wayland"17 clientcore "github.com/bnema/go-wayland-bindings/client/wayland"
17 "github.com/bnema/go-wayland-bindings/server/inputmethod"18 "github.com/bnema/go-wayland-bindings/server/inputmethod"
18- "bnema.dev/wlturbo"
19 )19 )
20 20
21 func main() {21 func main() {
@@ -86,7 +86,7 @@ func run(preedit, commit string, delay time.Duration, count int) error {
86 if err != nil {86 if err != nil {
87 return err87 return err
88 }88 }
89- defer c.Close()89+ defer func() { _ = c.Close() }()
90 if err := c.Roundtrip(); err != nil {90 if err := c.Roundtrip(); err != nil {
91 return err91 return err
92 }92 }
M examples/testpattern/main.go +2 -2
@@ -93,7 +93,7 @@ func run(mode string, fullscreen bool) error {
9393 if err != nil {
9494 return err
9595 }
96- defer d.Close()
96+ defer func() { _ = d.Close() }()
9797 if err := d.Roundtrip(); err != nil {
9898 return err
9999 }
@@ -389,7 +389,7 @@ func (c *client) dmabufBuffer(w, h int, patches []pattern.Patch) (*clientcore.Bu
389389 if err != nil {
390390 return nil, err
391391 }
392- defer f.Close()
392+ defer func() { _ = f.Close() }()
393393 params, err := c.dmabuf.CreateParams()
394394 if err != nil {
395395 return nil, err
@@ -93,7 +93,7 @@ func run(mode string, fullscreen bool) error {
93 if err != nil {93 if err != nil {
94 return err94 return err
95 }95 }
96- defer d.Close()96+ defer func() { _ = d.Close() }()
97 if err := d.Roundtrip(); err != nil {97 if err := d.Roundtrip(); err != nil {
98 return err98 return err
99 }99 }
@@ -389,7 +389,7 @@ func (c *client) dmabufBuffer(w, h int, patches []pattern.Patch) (*clientcore.Bu
389 if err != nil {389 if err != nil {
390 return nil, err390 return nil, err
391 }391 }
392- defer f.Close()392+ defer func() { _ = f.Close() }()
393 params, err := c.dmabuf.CreateParams()393 params, err := c.dmabuf.CreateParams()
394 if err != nil {394 if err != nil {
395 return nil, err395 return nil, err
M examples/testpattern/udmabuf.go +2 -2
@@ -15,13 +15,13 @@ func udmabuf(size int, fill func(data []byte)) (*os.File, error) {
1515 if err != nil {
1616 return nil, fmt.Errorf("udmabuf unavailable: %w", err)
1717 }
18- defer dev.Close()
18+ defer func() { _ = dev.Close() }()
1919 size = (size + os.Getpagesize() - 1) / os.Getpagesize() * os.Getpagesize()
2020 mem, err := unix.MemfdCreate("testpattern-dmabuf", unix.MFD_ALLOW_SEALING|unix.MFD_CLOEXEC)
2121 if err != nil {
2222 return nil, err
2323 }
24- defer unix.Close(mem)
24+ defer func() { _ = unix.Close(mem) }()
2525 if err := unix.Ftruncate(mem, int64(size)); err != nil {
2626 return nil, err
2727 }
@@ -15,13 +15,13 @@ func udmabuf(size int, fill func(data []byte)) (*os.File, error) {
15 if err != nil {15 if err != nil {
16 return nil, fmt.Errorf("udmabuf unavailable: %w", err)16 return nil, fmt.Errorf("udmabuf unavailable: %w", err)
17 }17 }
18- defer dev.Close()18+ defer func() { _ = dev.Close() }()
19 size = (size + os.Getpagesize() - 1) / os.Getpagesize() * os.Getpagesize()19 size = (size + os.Getpagesize() - 1) / os.Getpagesize() * os.Getpagesize()
20 mem, err := unix.MemfdCreate("testpattern-dmabuf", unix.MFD_ALLOW_SEALING|unix.MFD_CLOEXEC)20 mem, err := unix.MemfdCreate("testpattern-dmabuf", unix.MFD_ALLOW_SEALING|unix.MFD_CLOEXEC)
21 if err != nil {21 if err != nil {
22 return nil, err22 return nil, err
23 }23 }
24- defer unix.Close(mem)24+ defer func() { _ = unix.Close(mem) }()
25 if err := unix.Ftruncate(mem, int64(size)); err != nil {25 if err := unix.Ftruncate(mem, int64(size)); err != nil {
26 return nil, err26 return nil, err
27 }27 }
M internal/adapters/atspi/bus_test.go +4 -3
@@ -1,10 +1,10 @@
11 package atspi
22
33 import (
4+ "bnema.dev/zerowrap"
45 "bufio"
56 "bytes"
67 "context"
7- "bnema.dev/zerowrap"
88 "os"
99 "os/exec"
1010 "strings"
@@ -238,13 +238,14 @@ func TestConnectCancelledWhileEnabling(t *testing.T) {
238238 if m.Type != zerobus.TypeMethodCall {
239239 continue
240240 }
241- if m.Member == "GetAddress" {
241+ switch m.Member {
242+ case "GetAddress":
242243 app.NewReply(m, "s").Str(address)
243244 if _, err := app.Send(); err != nil {
244245 peerDone <- err
245246 return
246247 }
247- } else if m.Member == "Set" {
248+ case "Set":
248249 cancel()
249250 peerDone <- nil
250251 return
@@ -1,10 +1,10 @@
1 package atspi1 package atspi
2 2
3 import (3 import (
4+ "bnema.dev/zerowrap"
4 "bufio"5 "bufio"
5 "bytes"6 "bytes"
6 "context"7 "context"
7- "bnema.dev/zerowrap"
8 "os"8 "os"
9 "os/exec"9 "os/exec"
10 "strings"10 "strings"
@@ -238,13 +238,14 @@ func TestConnectCancelledWhileEnabling(t *testing.T) {
238 if m.Type != zerobus.TypeMethodCall {238 if m.Type != zerobus.TypeMethodCall {
239 continue239 continue
240 }240 }
241- if m.Member == "GetAddress" {241+ switch m.Member {
242+ case "GetAddress":
242 app.NewReply(m, "s").Str(address)243 app.NewReply(m, "s").Str(address)
243 if _, err := app.Send(); err != nil {244 if _, err := app.Send(); err != nil {
244 peerDone <- err245 peerDone <- err
245 return246 return
246 }247 }
247- } else if m.Member == "Set" {248+ case "Set":
248 cancel()249 cancel()
249 peerDone <- nil250 peerDone <- nil
250 return251 return
M internal/adapters/atspi/source.go +2 -2
@@ -7,9 +7,9 @@ import (
77 "strings"
88 "time"
99
10+ "bnema.dev/zerobus"
1011 "github.com/bnema/neferwl/internal/adapters/logging"
1112 "github.com/bnema/neferwl/internal/domain"
12- "bnema.dev/zerobus"
1313 )
1414
1515 const (
@@ -392,7 +392,7 @@ func (s *Source) Targets(ctx context.Context, windows []domain.HintWindow, links
392392 for i, r := range replies {
393393 var be *busError
394394 // Collection may be absent; elements falls back to walking the frame.
395- if r.err != nil && !(calls[i].op == opMatches && errors.As(r.err, &be)) {
395+ if r.err != nil && (calls[i].op != opMatches || !errors.As(r.err, &be)) {
396396 windowErr = errors.Join(windowErr, r.err)
397397 }
398398 }
@@ -7,9 +7,9 @@ import (
7 "strings"7 "strings"
8 "time"8 "time"
9 9
10+ "bnema.dev/zerobus"
10 "github.com/bnema/neferwl/internal/adapters/logging"11 "github.com/bnema/neferwl/internal/adapters/logging"
11 "github.com/bnema/neferwl/internal/domain"12 "github.com/bnema/neferwl/internal/domain"
12- "bnema.dev/zerobus"
13 )13 )
14 14
15 const (15 const (
@@ -392,7 +392,7 @@ func (s *Source) Targets(ctx context.Context, windows []domain.HintWindow, links
392 for i, r := range replies {392 for i, r := range replies {
393 var be *busError393 var be *busError
394 // Collection may be absent; elements falls back to walking the frame.394 // Collection may be absent; elements falls back to walking the frame.
395- if r.err != nil && !(calls[i].op == opMatches && errors.As(r.err, &be)) {395+ if r.err != nil && (calls[i].op != opMatches || !errors.As(r.err, &be)) {
396 windowErr = errors.Join(windowErr, r.err)396 windowErr = errors.Join(windowErr, r.err)
397 }397 }
398 }398 }
M internal/adapters/captureallow/store.go +12 -7
@@ -13,8 +13,8 @@ import (
1313 "time"
1414 "unsafe"
1515
16- "github.com/bnema/neferwl/internal/adapters/fdwait"
1716 "bnema.dev/zerowrap"
17+ "github.com/bnema/neferwl/internal/adapters/fdwait"
1818 "golang.org/x/sys/unix"
1919 )
2020
@@ -32,7 +32,7 @@ import (
3232 // owner, and not group- or other-writable unless sticky. Anything else fails
3333 // closed. Only a missing file, or a missing directory that holds the file
3434 // (/etc/neferwl) under checked ancestors, gives the built-in list.
35-func load(path string, owner uint32) (*Policy, error) {
35+func load(path string, owner uint32) (p *Policy, err error) {
3636 path = filepath.Clean(path)
3737 if !filepath.IsAbs(path) {
3838 return Closed(), fmt.Errorf("%s: path is not absolute", path)
@@ -61,7 +61,12 @@ func load(path string, owner uint32) (*Policy, error) {
6161 return Closed(), &fs.PathError{Op: "open", Path: path, Err: err}
6262 }
6363 f := os.NewFile(uintptr(fd), path)
64- defer f.Close()
64+ defer func() {
65+ // A failed close of the policy file fails closed.
66+ if cerr := f.Close(); cerr != nil {
67+ p, err = Closed(), errors.Join(err, &fs.PathError{Op: "close", Path: path, Err: cerr})
68+ }
69+ }()
6570 var st unix.Stat_t
6671 if err := unix.Fstat(fd, &st); err != nil {
6772 return Closed(), &fs.PathError{Op: "stat", Path: path, Err: err}
@@ -77,7 +82,7 @@ func load(path string, owner uint32) (*Policy, error) {
7782 // Reads of a regular file do not block; leave non-blocking mode off so the
7883 // os.File does not go through the poller.
7984 _ = unix.SetNonblock(fd, false)
80- p, err := Parse(f)
85+ p, err = Parse(f)
8186 if err != nil {
8287 return Closed(), err
8388 }
@@ -207,17 +212,17 @@ func (inotifyWatchInstaller) AddWatch(fd int, path string, mask uint32) (int, er
207212 return unix.InotifyAddWatch(fd, path, mask)
208213 }
209214
210-func (s *Store) run(ctx context.Context, watches watchInstaller) error {
215+func (s *Store) run(ctx context.Context, watches watchInstaller) (err error) {
211216 fd, err := unix.InotifyInit1(unix.IN_CLOEXEC | unix.IN_NONBLOCK)
212217 if err != nil {
213218 return err
214219 }
215- defer unix.Close(fd)
220+ defer func() { err = errors.Join(err, unix.Close(fd)) }()
216221 waiter, err := fdwait.New()
217222 if err != nil {
218223 return err
219224 }
220- defer waiter.Close()
225+ defer func() { err = errors.Join(err, waiter.Close()) }()
221226 waiter.StopOn(ctx)
222227 if err := waiter.Pin(int32(fd)); err != nil {
223228 return err
@@ -13,8 +13,8 @@ import (
13 "time"13 "time"
14 "unsafe"14 "unsafe"
15 15
16- "github.com/bnema/neferwl/internal/adapters/fdwait"
17 "bnema.dev/zerowrap"16 "bnema.dev/zerowrap"
17+ "github.com/bnema/neferwl/internal/adapters/fdwait"
18 "golang.org/x/sys/unix"18 "golang.org/x/sys/unix"
19 )19 )
20 20
@@ -32,7 +32,7 @@ import (
32 // owner, and not group- or other-writable unless sticky. Anything else fails32 // owner, and not group- or other-writable unless sticky. Anything else fails
33 // closed. Only a missing file, or a missing directory that holds the file33 // closed. Only a missing file, or a missing directory that holds the file
34 // (/etc/neferwl) under checked ancestors, gives the built-in list.34 // (/etc/neferwl) under checked ancestors, gives the built-in list.
35-func load(path string, owner uint32) (*Policy, error) {35+func load(path string, owner uint32) (p *Policy, err error) {
36 path = filepath.Clean(path)36 path = filepath.Clean(path)
37 if !filepath.IsAbs(path) {37 if !filepath.IsAbs(path) {
38 return Closed(), fmt.Errorf("%s: path is not absolute", path)38 return Closed(), fmt.Errorf("%s: path is not absolute", path)
@@ -61,7 +61,12 @@ func load(path string, owner uint32) (*Policy, error) {
61 return Closed(), &fs.PathError{Op: "open", Path: path, Err: err}61 return Closed(), &fs.PathError{Op: "open", Path: path, Err: err}
62 }62 }
63 f := os.NewFile(uintptr(fd), path)63 f := os.NewFile(uintptr(fd), path)
64- defer f.Close()64+ defer func() {
65+ // A failed close of the policy file fails closed.
66+ if cerr := f.Close(); cerr != nil {
67+ p, err = Closed(), errors.Join(err, &fs.PathError{Op: "close", Path: path, Err: cerr})
68+ }
69+ }()
65 var st unix.Stat_t70 var st unix.Stat_t
66 if err := unix.Fstat(fd, &st); err != nil {71 if err := unix.Fstat(fd, &st); err != nil {
67 return Closed(), &fs.PathError{Op: "stat", Path: path, Err: err}72 return Closed(), &fs.PathError{Op: "stat", Path: path, Err: err}
@@ -77,7 +82,7 @@ func load(path string, owner uint32) (*Policy, error) {
77 // Reads of a regular file do not block; leave non-blocking mode off so the82 // Reads of a regular file do not block; leave non-blocking mode off so the
78 // os.File does not go through the poller.83 // os.File does not go through the poller.
79 _ = unix.SetNonblock(fd, false)84 _ = unix.SetNonblock(fd, false)
80- p, err := Parse(f)85+ p, err = Parse(f)
81 if err != nil {86 if err != nil {
82 return Closed(), err87 return Closed(), err
83 }88 }
@@ -207,17 +212,17 @@ func (inotifyWatchInstaller) AddWatch(fd int, path string, mask uint32) (int, er
207 return unix.InotifyAddWatch(fd, path, mask)212 return unix.InotifyAddWatch(fd, path, mask)
208 }213 }
209 214
210-func (s *Store) run(ctx context.Context, watches watchInstaller) error {215+func (s *Store) run(ctx context.Context, watches watchInstaller) (err error) {
211 fd, err := unix.InotifyInit1(unix.IN_CLOEXEC | unix.IN_NONBLOCK)216 fd, err := unix.InotifyInit1(unix.IN_CLOEXEC | unix.IN_NONBLOCK)
212 if err != nil {217 if err != nil {
213 return err218 return err
214 }219 }
215- defer unix.Close(fd)220+ defer func() { err = errors.Join(err, unix.Close(fd)) }()
216 waiter, err := fdwait.New()221 waiter, err := fdwait.New()
217 if err != nil {222 if err != nil {
218 return err223 return err
219 }224 }
220- defer waiter.Close()225+ defer func() { err = errors.Join(err, waiter.Close()) }()
221 waiter.StopOn(ctx)226 waiter.StopOn(ctx)
222 if err := waiter.Pin(int32(fd)); err != nil {227 if err := waiter.Pin(int32(fd)); err != nil {
223 return err228 return err
M internal/adapters/captureallow/store_test.go +1 -1
@@ -179,7 +179,7 @@ func TestStoreWaitsForMissingDirectory(t *testing.T) {
179179 }).Once()
180180 watches.EXPECT().AddWatch(mock.Anything, filepath.Dir(path), uint32(watchMask)).RunAndReturn(unix.InotifyAddWatch)
181181 go func() { done <- s.run(ctx, watches) }()
182- defer func() { cancel(); <-done }()
182+ defer func() { cancel(); discardedErr := <-done; _ = discardedErr }()
183183 select {
184184 case err := <-attempted:
185185 if !errors.Is(err, unix.ENOENT) {
@@ -179,7 +179,7 @@ func TestStoreWaitsForMissingDirectory(t *testing.T) {
179 }).Once()179 }).Once()
180 watches.EXPECT().AddWatch(mock.Anything, filepath.Dir(path), uint32(watchMask)).RunAndReturn(unix.InotifyAddWatch)180 watches.EXPECT().AddWatch(mock.Anything, filepath.Dir(path), uint32(watchMask)).RunAndReturn(unix.InotifyAddWatch)
181 go func() { done <- s.run(ctx, watches) }()181 go func() { done <- s.run(ctx, watches) }()
182- defer func() { cancel(); <-done }()182+ defer func() { cancel(); discardedErr := <-done; _ = discardedErr }()
183 select {183 select {
184 case err := <-attempted:184 case err := <-attempted:
185 if !errors.Is(err, unix.ENOENT) {185 if !errors.Is(err, unix.ENOENT) {
M internal/adapters/config/cascade_test.go +2 -2
@@ -10,8 +10,8 @@ func TestCascadeOverflowInherited(t *testing.T) {
1010 if len(w) != 0 {
1111 t.Fatalf("warnings=%v", w)
1212 }
13- out := c.Layout.Outputs[0].LayoutRules.Over(c.Layout.LayoutRules)
14- ws := c.Workspaces[0].LayoutRules.Over(out)
13+ out := c.Layout.Outputs[0].Over(c.Layout.LayoutRules)
14+ ws := c.Workspaces[0].Over(out)
1515 if out.Overflow != "cascade" || ws.Overflow != "cascade" {
1616 t.Fatalf("output=%q workspace=%q, want cascade", out.Overflow, ws.Overflow)
1717 }
@@ -10,8 +10,8 @@ func TestCascadeOverflowInherited(t *testing.T) {
10 if len(w) != 0 {10 if len(w) != 0 {
11 t.Fatalf("warnings=%v", w)11 t.Fatalf("warnings=%v", w)
12 }12 }
13- out := c.Layout.Outputs[0].LayoutRules.Over(c.Layout.LayoutRules)13+ out := c.Layout.Outputs[0].Over(c.Layout.LayoutRules)
14- ws := c.Workspaces[0].LayoutRules.Over(out)14+ ws := c.Workspaces[0].Over(out)
15 if out.Overflow != "cascade" || ws.Overflow != "cascade" {15 if out.Overflow != "cascade" || ws.Overflow != "cascade" {
16 t.Fatalf("output=%q workspace=%q, want cascade", out.Overflow, ws.Overflow)16 t.Fatalf("output=%q workspace=%q, want cascade", out.Overflow, ws.Overflow)
17 }17 }
M internal/adapters/control/control.go +8 -5
@@ -67,8 +67,7 @@ func Listen(path string, ids *workspaceid.IDs, opts Options) (*Server, error) {
6767 }
6868 conn, err := net.DialTimeout("unix", path, time.Second)
6969 if err == nil {
70- conn.Close()
71- return nil, fmt.Errorf("control socket already listening: %s", path)
70+ return nil, errors.Join(fmt.Errorf("control socket already listening: %s", path), conn.Close())
7271 }
7372 if !errors.Is(err, syscall.ECONNREFUSED) {
7473 return nil, err
@@ -84,8 +83,7 @@ func Listen(path string, ids *workspaceid.IDs, opts Options) (*Server, error) {
8483 return nil, err
8584 }
8685 if err := os.Chmod(path, 0o600); err != nil {
87- listener.Close()
88- return nil, err
86+ return nil, errors.Join(err, listener.Close())
8987 }
9088 s := &Server{listener: listener, ids: ids, done: make(chan struct{})}
9189 s.framesDir = opts.FramesDir
@@ -167,7 +165,12 @@ func (s *Server) Run(ctx context.Context, out chan<- ports.ControlRequest) error
167165 workers.Add(1)
168166 go func() {
169167 defer workers.Done()
170- defer conn.Close()
168+ defer func() {
169+ // The context hook below may have closed it already.
170+ if err := conn.Close(); err != nil && !errors.Is(err, net.ErrClosed) {
171+ log.Warn().Err(err).Msg("close control connection")
172+ }
173+ }()
171174 connCtx, cancel := context.WithCancel(ctx)
172175 defer cancel()
173176 go func() {
@@ -67,8 +67,7 @@ func Listen(path string, ids *workspaceid.IDs, opts Options) (*Server, error) {
67 }67 }
68 conn, err := net.DialTimeout("unix", path, time.Second)68 conn, err := net.DialTimeout("unix", path, time.Second)
69 if err == nil {69 if err == nil {
70- conn.Close()70+ return nil, errors.Join(fmt.Errorf("control socket already listening: %s", path), conn.Close())
71- return nil, fmt.Errorf("control socket already listening: %s", path)
72 }71 }
73 if !errors.Is(err, syscall.ECONNREFUSED) {72 if !errors.Is(err, syscall.ECONNREFUSED) {
74 return nil, err73 return nil, err
@@ -84,8 +83,7 @@ func Listen(path string, ids *workspaceid.IDs, opts Options) (*Server, error) {
84 return nil, err83 return nil, err
85 }84 }
86 if err := os.Chmod(path, 0o600); err != nil {85 if err := os.Chmod(path, 0o600); err != nil {
87- listener.Close()86+ return nil, errors.Join(err, listener.Close())
88- return nil, err
89 }87 }
90 s := &Server{listener: listener, ids: ids, done: make(chan struct{})}88 s := &Server{listener: listener, ids: ids, done: make(chan struct{})}
91 s.framesDir = opts.FramesDir89 s.framesDir = opts.FramesDir
@@ -167,7 +165,12 @@ func (s *Server) Run(ctx context.Context, out chan<- ports.ControlRequest) error
167 workers.Add(1)165 workers.Add(1)
168 go func() {166 go func() {
169 defer workers.Done()167 defer workers.Done()
170- defer conn.Close()168+ defer func() {
169+ // The context hook below may have closed it already.
170+ if err := conn.Close(); err != nil && !errors.Is(err, net.ErrClosed) {
171+ log.Warn().Err(err).Msg("close control connection")
172+ }
173+ }()
171 connCtx, cancel := context.WithCancel(ctx)174 connCtx, cancel := context.WithCancel(ctx)
172 defer cancel()175 defer cancel()
173 go func() {176 go func() {
M internal/adapters/control/control_test.go +10 -10
@@ -23,7 +23,7 @@ func TestProtocol(t *testing.T) {
2323 if err != nil {
2424 t.Fatal(err)
2525 }
26- defer s.Close()
26+ defer func() { _ = s.Close() }()
2727 for path, want := range map[string]os.FileMode{filepath.Dir(path): 0o700, path: 0o600} {
2828 info, err := os.Stat(path)
2929 if err != nil || info.Mode().Perm() != want {
@@ -39,7 +39,7 @@ func TestProtocol(t *testing.T) {
3939 if err != nil {
4040 t.Fatal(err)
4141 }
42- defer conn.Close()
42+ defer func() { _ = conn.Close() }()
4343 if err := conn.SetDeadline(time.Now().Add(10 * time.Second)); err != nil {
4444 t.Fatal(err)
4545 }
@@ -194,9 +194,9 @@ func TestListenPreservesLiveSocketAndFiles(t *testing.T) {
194194 if err != nil {
195195 t.Fatal(err)
196196 }
197- defer s.Close()
197+ defer func() { _ = s.Close() }()
198198 if other, err := Listen(path, ids, Options{}); err == nil {
199- other.Close()
199+ _ = other.Close()
200200 t.Fatal("replaced live listener")
201201 }
202202 if err := s.Close(); err != nil {
@@ -206,7 +206,7 @@ func TestListenPreservesLiveSocketAndFiles(t *testing.T) {
206206 t.Fatal(err)
207207 }
208208 if other, err := Listen(path, ids, Options{}); err == nil {
209- other.Close()
209+ _ = other.Close()
210210 t.Fatal("replaced regular file")
211211 }
212212 data, err := os.ReadFile(path)
@@ -240,7 +240,7 @@ func TestConnectionOrderingAndClose(t *testing.T) {
240240 if err != nil {
241241 t.Fatal(err)
242242 }
243- defer s.Close()
243+ defer func() { _ = s.Close() }()
244244 ctx, cancel := context.WithCancel(context.Background())
245245 defer cancel()
246246 out := make(chan ports.ControlRequest, 2)
@@ -250,7 +250,7 @@ func TestConnectionOrderingAndClose(t *testing.T) {
250250 if err != nil {
251251 t.Fatal(err)
252252 }
253- defer conn.Close()
253+ defer func() { _ = conn.Close() }()
254254 if err := conn.SetDeadline(time.Now().Add(10 * time.Second)); err != nil {
255255 t.Fatal(err)
256256 }
@@ -269,7 +269,7 @@ func TestConnectionOrderingAndClose(t *testing.T) {
269269 if err != nil {
270270 t.Fatal(err)
271271 }
272- defer barrier.Close()
272+ defer func() { _ = barrier.Close() }()
273273 if err := barrier.SetDeadline(time.Now().Add(10 * time.Second)); err != nil {
274274 t.Fatal(err)
275275 }
@@ -318,7 +318,7 @@ func TestQuitReplyBeforeShutdown(t *testing.T) {
318318 if err != nil {
319319 t.Fatal(err)
320320 }
321- defer s.Close()
321+ defer func() { _ = s.Close() }()
322322 ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
323323 defer cancel()
324324 out := make(chan ports.ControlRequest)
@@ -328,7 +328,7 @@ func TestQuitReplyBeforeShutdown(t *testing.T) {
328328 if err != nil {
329329 t.Fatal(err)
330330 }
331- defer conn.Close()
331+ defer func() { _ = conn.Close() }()
332332 if err := conn.SetDeadline(time.Now().Add(10 * time.Second)); err != nil {
333333 t.Fatal(err)
334334 }
@@ -23,7 +23,7 @@ func TestProtocol(t *testing.T) {
23 if err != nil {23 if err != nil {
24 t.Fatal(err)24 t.Fatal(err)
25 }25 }
26- defer s.Close()26+ defer func() { _ = s.Close() }()
27 for path, want := range map[string]os.FileMode{filepath.Dir(path): 0o700, path: 0o600} {27 for path, want := range map[string]os.FileMode{filepath.Dir(path): 0o700, path: 0o600} {
28 info, err := os.Stat(path)28 info, err := os.Stat(path)
29 if err != nil || info.Mode().Perm() != want {29 if err != nil || info.Mode().Perm() != want {
@@ -39,7 +39,7 @@ func TestProtocol(t *testing.T) {
39 if err != nil {39 if err != nil {
40 t.Fatal(err)40 t.Fatal(err)
41 }41 }
42- defer conn.Close()42+ defer func() { _ = conn.Close() }()
43 if err := conn.SetDeadline(time.Now().Add(10 * time.Second)); err != nil {43 if err := conn.SetDeadline(time.Now().Add(10 * time.Second)); err != nil {
44 t.Fatal(err)44 t.Fatal(err)
45 }45 }
@@ -194,9 +194,9 @@ func TestListenPreservesLiveSocketAndFiles(t *testing.T) {
194 if err != nil {194 if err != nil {
195 t.Fatal(err)195 t.Fatal(err)
196 }196 }
197- defer s.Close()197+ defer func() { _ = s.Close() }()
198 if other, err := Listen(path, ids, Options{}); err == nil {198 if other, err := Listen(path, ids, Options{}); err == nil {
199- other.Close()199+ _ = other.Close()
200 t.Fatal("replaced live listener")200 t.Fatal("replaced live listener")
201 }201 }
202 if err := s.Close(); err != nil {202 if err := s.Close(); err != nil {
@@ -206,7 +206,7 @@ func TestListenPreservesLiveSocketAndFiles(t *testing.T) {
206 t.Fatal(err)206 t.Fatal(err)
207 }207 }
208 if other, err := Listen(path, ids, Options{}); err == nil {208 if other, err := Listen(path, ids, Options{}); err == nil {
209- other.Close()209+ _ = other.Close()
210 t.Fatal("replaced regular file")210 t.Fatal("replaced regular file")
211 }211 }
212 data, err := os.ReadFile(path)212 data, err := os.ReadFile(path)
@@ -240,7 +240,7 @@ func TestConnectionOrderingAndClose(t *testing.T) {
240 if err != nil {240 if err != nil {
241 t.Fatal(err)241 t.Fatal(err)
242 }242 }
243- defer s.Close()243+ defer func() { _ = s.Close() }()
244 ctx, cancel := context.WithCancel(context.Background())244 ctx, cancel := context.WithCancel(context.Background())
245 defer cancel()245 defer cancel()
246 out := make(chan ports.ControlRequest, 2)246 out := make(chan ports.ControlRequest, 2)
@@ -250,7 +250,7 @@ func TestConnectionOrderingAndClose(t *testing.T) {
250 if err != nil {250 if err != nil {
251 t.Fatal(err)251 t.Fatal(err)
252 }252 }
253- defer conn.Close()253+ defer func() { _ = conn.Close() }()
254 if err := conn.SetDeadline(time.Now().Add(10 * time.Second)); err != nil {254 if err := conn.SetDeadline(time.Now().Add(10 * time.Second)); err != nil {
255 t.Fatal(err)255 t.Fatal(err)
256 }256 }
@@ -269,7 +269,7 @@ func TestConnectionOrderingAndClose(t *testing.T) {
269 if err != nil {269 if err != nil {
270 t.Fatal(err)270 t.Fatal(err)
271 }271 }
272- defer barrier.Close()272+ defer func() { _ = barrier.Close() }()
273 if err := barrier.SetDeadline(time.Now().Add(10 * time.Second)); err != nil {273 if err := barrier.SetDeadline(time.Now().Add(10 * time.Second)); err != nil {
274 t.Fatal(err)274 t.Fatal(err)
275 }275 }
@@ -318,7 +318,7 @@ func TestQuitReplyBeforeShutdown(t *testing.T) {
318 if err != nil {318 if err != nil {
319 t.Fatal(err)319 t.Fatal(err)
320 }320 }
321- defer s.Close()321+ defer func() { _ = s.Close() }()
322 ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)322 ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
323 defer cancel()323 defer cancel()
324 out := make(chan ports.ControlRequest)324 out := make(chan ports.ControlRequest)
@@ -328,7 +328,7 @@ func TestQuitReplyBeforeShutdown(t *testing.T) {
328 if err != nil {328 if err != nil {
329 t.Fatal(err)329 t.Fatal(err)
330 }330 }
331- defer conn.Close()331+ defer func() { _ = conn.Close() }()
332 if err := conn.SetDeadline(time.Now().Add(10 * time.Second)); err != nil {332 if err := conn.SetDeadline(time.Now().Add(10 * time.Second)); err != nil {
333 t.Fatal(err)333 t.Fatal(err)
334 }334 }
M internal/adapters/control/inject_wire_test.go +4 -4
@@ -28,7 +28,7 @@ func TestInjectProtocol(t *testing.T) {
2828 if err != nil {
2929 t.Fatal(err)
3030 }
31- defer s.Close()
31+ defer func() { _ = s.Close() }()
3232 ctx, cancel := context.WithCancel(context.Background())
3333 defer cancel()
3434 out := make(chan ports.ControlRequest, 1)
@@ -40,7 +40,7 @@ func TestInjectProtocol(t *testing.T) {
4040 if err != nil {
4141 t.Fatal(err)
4242 }
43- t.Cleanup(func() { c.Close() })
43+ t.Cleanup(func() { _ = c.Close() })
4444 if err := c.SetDeadline(time.Now().Add(5 * time.Second)); err != nil {
4545 t.Fatal(err)
4646 }
@@ -283,7 +283,7 @@ func TestTwoConnectionsShareAdmittedModifiers(t *testing.T) {
283283 if err != nil {
284284 t.Fatal(err)
285285 }
286- defer s.Close()
286+ defer func() { _ = s.Close() }()
287287 ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second)
288288 defer cancel()
289289 out := make(chan ports.ControlRequest)
@@ -295,7 +295,7 @@ func TestTwoConnectionsShareAdmittedModifiers(t *testing.T) {
295295 if err != nil {
296296 t.Fatal(err)
297297 }
298- t.Cleanup(func() { conn.Close() })
298+ t.Cleanup(func() { _ = conn.Close() })
299299 if err := conn.SetDeadline(time.Now().Add(5 * time.Second)); err != nil {
300300 t.Fatal(err)
301301 }
@@ -28,7 +28,7 @@ func TestInjectProtocol(t *testing.T) {
28 if err != nil {28 if err != nil {
29 t.Fatal(err)29 t.Fatal(err)
30 }30 }
31- defer s.Close()31+ defer func() { _ = s.Close() }()
32 ctx, cancel := context.WithCancel(context.Background())32 ctx, cancel := context.WithCancel(context.Background())
33 defer cancel()33 defer cancel()
34 out := make(chan ports.ControlRequest, 1)34 out := make(chan ports.ControlRequest, 1)
@@ -40,7 +40,7 @@ func TestInjectProtocol(t *testing.T) {
40 if err != nil {40 if err != nil {
41 t.Fatal(err)41 t.Fatal(err)
42 }42 }
43- t.Cleanup(func() { c.Close() })43+ t.Cleanup(func() { _ = c.Close() })
44 if err := c.SetDeadline(time.Now().Add(5 * time.Second)); err != nil {44 if err := c.SetDeadline(time.Now().Add(5 * time.Second)); err != nil {
45 t.Fatal(err)45 t.Fatal(err)
46 }46 }
@@ -283,7 +283,7 @@ func TestTwoConnectionsShareAdmittedModifiers(t *testing.T) {
283 if err != nil {283 if err != nil {
284 t.Fatal(err)284 t.Fatal(err)
285 }285 }
286- defer s.Close()286+ defer func() { _ = s.Close() }()
287 ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second)287 ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second)
288 defer cancel()288 defer cancel()
289 out := make(chan ports.ControlRequest)289 out := make(chan ports.ControlRequest)
@@ -295,7 +295,7 @@ func TestTwoConnectionsShareAdmittedModifiers(t *testing.T) {
295 if err != nil {295 if err != nil {
296 t.Fatal(err)296 t.Fatal(err)
297 }297 }
298- t.Cleanup(func() { conn.Close() })298+ t.Cleanup(func() { _ = conn.Close() })
299 if err := conn.SetDeadline(time.Now().Add(5 * time.Second)); err != nil {299 if err := conn.SetDeadline(time.Now().Add(5 * time.Second)); err != nil {
300 t.Fatal(err)300 t.Fatal(err)
301 }301 }
M internal/adapters/control/output_test.go +3 -1
@@ -16,7 +16,9 @@ func TestOutputDispatch(t *testing.T) {
1616 out := make(chan ports.ControlRequest)
1717 for _, wire := range []string{`{"op":"output-add","mode":"1920x1080@60","name":"X"}`, `{"op":"output-rm","name":"X"}`} {
1818 var req request
19- json.Unmarshal([]byte(wire), &req)
19+ if err := json.Unmarshal([]byte(wire), &req); err != nil {
20+ t.Fatal(err)
21+ }
2022 go func() {
2123 r := (<-out).(ports.ControlOutput)
2224 if r.Name != "X" || r.Caps != domain.CapsAll || r.Remove != (req.Op == "output-rm") {
@@ -16,7 +16,9 @@ func TestOutputDispatch(t *testing.T) {
16 out := make(chan ports.ControlRequest)16 out := make(chan ports.ControlRequest)
17 for _, wire := range []string{`{"op":"output-add","mode":"1920x1080@60","name":"X"}`, `{"op":"output-rm","name":"X"}`} {17 for _, wire := range []string{`{"op":"output-add","mode":"1920x1080@60","name":"X"}`, `{"op":"output-rm","name":"X"}`} {
18 var req request18 var req request
19- json.Unmarshal([]byte(wire), &req)19+ if err := json.Unmarshal([]byte(wire), &req); err != nil {
20+ t.Fatal(err)
21+ }
20 go func() {22 go func() {
21 r := (<-out).(ports.ControlOutput)23 r := (<-out).(ports.ControlOutput)
22 if r.Name != "X" || r.Caps != domain.CapsAll || r.Remove != (req.Op == "output-rm") {24 if r.Name != "X" || r.Caps != domain.CapsAll || r.Remove != (req.Op == "output-rm") {
M internal/adapters/control/shot.go +11 -13
@@ -12,6 +12,7 @@ import (
1212 "strings"
1313 "sync"
1414
15+ "github.com/bnema/neferwl/internal/adapters/logging"
1516 "github.com/bnema/neferwl/internal/domain"
1617 "github.com/bnema/neferwl/internal/ports"
1718 "golang.org/x/sys/unix"
@@ -82,8 +83,7 @@ func (s *Shooter) Shoot(ctx context.Context, shots []domain.ShotRequest, inline
8283 select {
8384 case s.requests <- request:
8485 case <-ctx.Done():
85- unix.Munmap(pixels)
86- return results, ctx.Err()
86+ return results, errors.Join(ctx.Err(), unix.Munmap(pixels))
8787 }
8888 completed := false
8989 for !completed {
@@ -94,7 +94,10 @@ func (s *Shooter) Shoot(ctx context.Context, shots []domain.ShotRequest, inline
9494 return results, errors.New("control capture sink closed before completion")
9595 }
9696 if old, ok := s.orphans[done.ID]; ok {
97- unix.Munmap(old)
97+ if err := unix.Munmap(old); err != nil {
98+ log := logging.For(ctx, "control")
99+ log.Warn().Err(err).Uint64("capture", done.ID).Msg("unmap orphaned capture")
100+ }
98101 delete(s.orphans, done.ID)
99102 }
100103 if done.ID != id {
@@ -102,8 +105,7 @@ func (s *Shooter) Shoot(ctx context.Context, shots []domain.ShotRequest, inline
102105 }
103106 completed = true
104107 if done.Err != nil {
105- unix.Munmap(pixels)
106- return results, fmt.Errorf("capture %s: %w", q.Output, done.Err)
108+ return results, fmt.Errorf("capture %s: %w", q.Output, errors.Join(done.Err, unix.Munmap(pixels)))
107109 }
108110 case <-ctx.Done():
109111 s.orphans[id] = pixels
@@ -111,8 +113,7 @@ func (s *Shooter) Shoot(ctx context.Context, shots []domain.ShotRequest, inline
111113 }
112114 }
113115 if err := ctx.Err(); err != nil {
114- unix.Munmap(pixels)
115- return results, err
116+ return results, errors.Join(err, unix.Munmap(pixels))
116117 }
117118 // CaptureFrame.Read writes opaque little-endian XRGB (BGRA bytes):
118119 // swap to RGBA in the private mapping and encode it in place.
@@ -121,8 +122,7 @@ func (s *Shooter) Shoot(ctx context.Context, shots []domain.ShotRequest, inline
121122 }
122123 img := &image.NRGBA{Pix: pixels, Stride: w * 4, Rect: image.Rect(0, 0, w, h)}
123124 var encoded bytes.Buffer
124- err = shotPNG.Encode(&encoded, img)
125- unix.Munmap(pixels)
125+ err = errors.Join(shotPNG.Encode(&encoded, img), unix.Munmap(pixels))
126126 if err != nil {
127127 return results, err
128128 }
@@ -134,12 +134,10 @@ func (s *Shooter) Shoot(ctx context.Context, shots []domain.ShotRequest, inline
134134 _, writeErr := f.Write(encoded.Bytes())
135135 closeErr := f.Close()
136136 if err := errors.Join(writeErr, closeErr); err != nil {
137- os.Remove(f.Name())
138- return results, err
137+ return results, errors.Join(err, os.Remove(f.Name()))
139138 }
140139 if err := os.Rename(f.Name(), path); err != nil {
141- os.Remove(f.Name())
142- return results, err
140+ return results, errors.Join(err, os.Remove(f.Name()))
143141 }
144142 shot := Shot{Output: q.Output, Path: path, Seq: q.MinSeq}
145143 if inline {
@@ -12,6 +12,7 @@ import (
12 "strings"12 "strings"
13 "sync"13 "sync"
14 14
15+ "github.com/bnema/neferwl/internal/adapters/logging"
15 "github.com/bnema/neferwl/internal/domain"16 "github.com/bnema/neferwl/internal/domain"
16 "github.com/bnema/neferwl/internal/ports"17 "github.com/bnema/neferwl/internal/ports"
17 "golang.org/x/sys/unix"18 "golang.org/x/sys/unix"
@@ -82,8 +83,7 @@ func (s *Shooter) Shoot(ctx context.Context, shots []domain.ShotRequest, inline
82 select {83 select {
83 case s.requests <- request:84 case s.requests <- request:
84 case <-ctx.Done():85 case <-ctx.Done():
85- unix.Munmap(pixels)86+ return results, errors.Join(ctx.Err(), unix.Munmap(pixels))
86- return results, ctx.Err()
87 }87 }
88 completed := false88 completed := false
89 for !completed {89 for !completed {
@@ -94,7 +94,10 @@ func (s *Shooter) Shoot(ctx context.Context, shots []domain.ShotRequest, inline
94 return results, errors.New("control capture sink closed before completion")94 return results, errors.New("control capture sink closed before completion")
95 }95 }
96 if old, ok := s.orphans[done.ID]; ok {96 if old, ok := s.orphans[done.ID]; ok {
97- unix.Munmap(old)97+ if err := unix.Munmap(old); err != nil {
98+ log := logging.For(ctx, "control")
99+ log.Warn().Err(err).Uint64("capture", done.ID).Msg("unmap orphaned capture")
100+ }
98 delete(s.orphans, done.ID)101 delete(s.orphans, done.ID)
99 }102 }
100 if done.ID != id {103 if done.ID != id {
@@ -102,8 +105,7 @@ func (s *Shooter) Shoot(ctx context.Context, shots []domain.ShotRequest, inline
102 }105 }
103 completed = true106 completed = true
104 if done.Err != nil {107 if done.Err != nil {
105- unix.Munmap(pixels)108+ return results, fmt.Errorf("capture %s: %w", q.Output, errors.Join(done.Err, unix.Munmap(pixels)))
106- return results, fmt.Errorf("capture %s: %w", q.Output, done.Err)
107 }109 }
108 case <-ctx.Done():110 case <-ctx.Done():
109 s.orphans[id] = pixels111 s.orphans[id] = pixels
@@ -111,8 +113,7 @@ func (s *Shooter) Shoot(ctx context.Context, shots []domain.ShotRequest, inline
111 }113 }
112 }114 }
113 if err := ctx.Err(); err != nil {115 if err := ctx.Err(); err != nil {
114- unix.Munmap(pixels)116+ return results, errors.Join(err, unix.Munmap(pixels))
115- return results, err
116 }117 }
117 // CaptureFrame.Read writes opaque little-endian XRGB (BGRA bytes):118 // CaptureFrame.Read writes opaque little-endian XRGB (BGRA bytes):
118 // swap to RGBA in the private mapping and encode it in place.119 // swap to RGBA in the private mapping and encode it in place.
@@ -121,8 +122,7 @@ func (s *Shooter) Shoot(ctx context.Context, shots []domain.ShotRequest, inline
121 }122 }
122 img := &image.NRGBA{Pix: pixels, Stride: w * 4, Rect: image.Rect(0, 0, w, h)}123 img := &image.NRGBA{Pix: pixels, Stride: w * 4, Rect: image.Rect(0, 0, w, h)}
123 var encoded bytes.Buffer124 var encoded bytes.Buffer
124- err = shotPNG.Encode(&encoded, img)125+ err = errors.Join(shotPNG.Encode(&encoded, img), unix.Munmap(pixels))
125- unix.Munmap(pixels)
126 if err != nil {126 if err != nil {
127 return results, err127 return results, err
128 }128 }
@@ -134,12 +134,10 @@ func (s *Shooter) Shoot(ctx context.Context, shots []domain.ShotRequest, inline
134 _, writeErr := f.Write(encoded.Bytes())134 _, writeErr := f.Write(encoded.Bytes())
135 closeErr := f.Close()135 closeErr := f.Close()
136 if err := errors.Join(writeErr, closeErr); err != nil {136 if err := errors.Join(writeErr, closeErr); err != nil {
137- os.Remove(f.Name())137+ return results, errors.Join(err, os.Remove(f.Name()))
138- return results, err
139 }138 }
140 if err := os.Rename(f.Name(), path); err != nil {139 if err := os.Rename(f.Name(), path); err != nil {
141- os.Remove(f.Name())140+ return results, errors.Join(err, os.Remove(f.Name()))
142- return results, err
143 }141 }
144 shot := Shot{Output: q.Output, Path: path, Seq: q.MinSeq}142 shot := Shot{Output: q.Output, Path: path, Seq: q.MinSeq}
145 if inline {143 if inline {
M internal/adapters/directseat/directseat_test.go +1 -1
@@ -129,7 +129,7 @@ func TestUnixOpenFlags(t *testing.T) {
129129 require.NoError(t, os.WriteFile(path, nil, 0o600))
130130 fd, err := unixEvdev{}.open(path)
131131 require.NoError(t, err)
132- defer unix.Close(fd)
132+ defer func() { _ = unix.Close(fd) }()
133133 flags, err := unix.FcntlInt(uintptr(fd), unix.F_GETFL, 0)
134134 require.NoError(t, err)
135135 assert.Equal(t, unix.O_RDWR, flags&unix.O_ACCMODE)
@@ -129,7 +129,7 @@ func TestUnixOpenFlags(t *testing.T) {
129 require.NoError(t, os.WriteFile(path, nil, 0o600))129 require.NoError(t, os.WriteFile(path, nil, 0o600))
130 fd, err := unixEvdev{}.open(path)130 fd, err := unixEvdev{}.open(path)
131 require.NoError(t, err)131 require.NoError(t, err)
132- defer unix.Close(fd)132+ defer func() { _ = unix.Close(fd) }()
133 flags, err := unix.FcntlInt(uintptr(fd), unix.F_GETFL, 0)133 flags, err := unix.FcntlInt(uintptr(fd), unix.F_GETFL, 0)
134 require.NoError(t, err)134 require.NoError(t, err)
135 assert.Equal(t, unix.O_RDWR, flags&unix.O_ACCMODE)135 assert.Equal(t, unix.O_RDWR, flags&unix.O_ACCMODE)
M internal/adapters/drm/alloc_test.go +1 -1
@@ -17,7 +17,7 @@ func gbmBuf(planes int) domain.DMABuf {
1717 b := domain.DMABuf{Modifier: tiledMod}
1818 for range planes {
1919 f, w, _ := os.Pipe()
20- w.Close()
20+ _ = w.Close()
2121 b.Planes = append(b.Planes, domain.DMABufPlane{File: f})
2222 }
2323 return b
@@ -17,7 +17,7 @@ func gbmBuf(planes int) domain.DMABuf {
17 b := domain.DMABuf{Modifier: tiledMod}17 b := domain.DMABuf{Modifier: tiledMod}
18 for range planes {18 for range planes {
19 f, w, _ := os.Pipe()19 f, w, _ := os.Pipe()
20- w.Close()20+ _ = w.Close()
21 b.Planes = append(b.Planes, domain.DMABufPlane{File: f})21 b.Planes = append(b.Planes, domain.DMABufPlane{File: f})
22 }22 }
23 return b23 return b
M internal/adapters/drm/amdgpu_rules_test.go +2 -2
@@ -135,7 +135,7 @@ func amdgpuRuleWith(t *testing.T, live func(uint32) bool) func(*atomicReq, uint3
135135 for i, obj := range req.objs {
136136 for _, p := range req.props[i] {
137137 isPlane := obj == tPrimary || obj == tCursor || obj == tOverlay || obj == 53
138- if p.val != state[[2]uint32{obj, p.prop}] && !(isPlane && (p.prop == pFB || p.prop == pFence)) {
138+ if p.val != state[[2]uint32{obj, p.prop}] && (!isPlane || p.prop != pFB && p.prop != pFence) {
139139 t.Logf("amdgpu: async commit changes object %d property %d", obj, p.prop)
140140 return unix.EINVAL
141141 }
@@ -421,7 +421,7 @@ func TestRunProtectedActivationRetriesWithoutStoppingOrEarlyProof(t *testing.T)
421421 r := portsmocks.NewMockRenderer(t)
422422 buf := func() domain.DMABuf {
423423 f, w := protectionFence(t, false)
424- w.Close()
424+ _ = w.Close()
425425 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
426426 }
427427 r.EXPECT().SetHDR(float64(0)).Return().Maybe()
@@ -135,7 +135,7 @@ func amdgpuRuleWith(t *testing.T, live func(uint32) bool) func(*atomicReq, uint3
135 for i, obj := range req.objs {135 for i, obj := range req.objs {
136 for _, p := range req.props[i] {136 for _, p := range req.props[i] {
137 isPlane := obj == tPrimary || obj == tCursor || obj == tOverlay || obj == 53137 isPlane := obj == tPrimary || obj == tCursor || obj == tOverlay || obj == 53
138- if p.val != state[[2]uint32{obj, p.prop}] && !(isPlane && (p.prop == pFB || p.prop == pFence)) {138+ if p.val != state[[2]uint32{obj, p.prop}] && (!isPlane || p.prop != pFB && p.prop != pFence) {
139 t.Logf("amdgpu: async commit changes object %d property %d", obj, p.prop)139 t.Logf("amdgpu: async commit changes object %d property %d", obj, p.prop)
140 return unix.EINVAL140 return unix.EINVAL
141 }141 }
@@ -421,7 +421,7 @@ func TestRunProtectedActivationRetriesWithoutStoppingOrEarlyProof(t *testing.T)
421 r := portsmocks.NewMockRenderer(t)421 r := portsmocks.NewMockRenderer(t)
422 buf := func() domain.DMABuf {422 buf := func() domain.DMABuf {
423 f, w := protectionFence(t, false)423 f, w := protectionFence(t, false)
424- w.Close()424+ _ = w.Close()
425 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}425 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
426 }426 }
427 r.EXPECT().SetHDR(float64(0)).Return().Maybe()427 r.EXPECT().SetHDR(float64(0)).Return().Maybe()
M internal/adapters/drm/capture_test.go +3 -3
@@ -341,7 +341,7 @@ func TestRunChildHoldLiftedWhileDisplayCommitStalls(t *testing.T) {
341341 display := portsmocks.NewMockRenderer(t)
342342 buf := func() domain.DMABuf {
343343 f, w, _ := os.Pipe()
344- w.Close()
344+ _ = w.Close()
345345 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
346346 }
347347 display.EXPECT().SetHDR(float64(0)).Return().Maybe()
@@ -443,7 +443,7 @@ func TestRunCaptureWaitsForItsIndicatorScene(t *testing.T) {
443443 o.flipped = flips
444444 buf := func() domain.DMABuf {
445445 f, w, _ := os.Pipe()
446- w.Close()
446+ _ = w.Close()
447447 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
448448 }
449449 // Only what the renderer draws for scenes after the modeset's black frame.
@@ -551,7 +551,7 @@ func TestRunCaptureWithoutIndicatorFailsAfterTheBoundedWait(t *testing.T) {
551551 o.flipped = flips
552552 buf := func() domain.DMABuf {
553553 f, w, _ := os.Pipe()
554- w.Close()
554+ _ = w.Close()
555555 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
556556 }
557557 r := portsmocks.NewMockRenderer(t)
@@ -341,7 +341,7 @@ func TestRunChildHoldLiftedWhileDisplayCommitStalls(t *testing.T) {
341 display := portsmocks.NewMockRenderer(t)341 display := portsmocks.NewMockRenderer(t)
342 buf := func() domain.DMABuf {342 buf := func() domain.DMABuf {
343 f, w, _ := os.Pipe()343 f, w, _ := os.Pipe()
344- w.Close()344+ _ = w.Close()
345 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}345 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
346 }346 }
347 display.EXPECT().SetHDR(float64(0)).Return().Maybe()347 display.EXPECT().SetHDR(float64(0)).Return().Maybe()
@@ -443,7 +443,7 @@ func TestRunCaptureWaitsForItsIndicatorScene(t *testing.T) {
443 o.flipped = flips443 o.flipped = flips
444 buf := func() domain.DMABuf {444 buf := func() domain.DMABuf {
445 f, w, _ := os.Pipe()445 f, w, _ := os.Pipe()
446- w.Close()446+ _ = w.Close()
447 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}447 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
448 }448 }
449 // Only what the renderer draws for scenes after the modeset's black frame.449 // Only what the renderer draws for scenes after the modeset's black frame.
@@ -551,7 +551,7 @@ func TestRunCaptureWithoutIndicatorFailsAfterTheBoundedWait(t *testing.T) {
551 o.flipped = flips551 o.flipped = flips
552 buf := func() domain.DMABuf {552 buf := func() domain.DMABuf {
553 f, w, _ := os.Pipe()553 f, w, _ := os.Pipe()
554- w.Close()554+ _ = w.Close()
555 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}555 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
556 }556 }
557 r := portsmocks.NewMockRenderer(t)557 r := portsmocks.NewMockRenderer(t)
M internal/adapters/drm/card.go +2 -2
@@ -306,12 +306,12 @@ func (c *Card) open(conn connector, mode modeInfo) (*Output, error) {
306306 // ReadEvents reads commit events until ctx ends and routes them to the
307307 // output of their CRTC. Run it once per card. An event is never dropped:
308308 // the output owes it a pending commit.
309-func (c *Card) ReadEvents(ctx context.Context) error {
309+func (c *Card) ReadEvents(ctx context.Context) (err error) {
310310 waiter, err := fdwait.New()
311311 if err != nil {
312312 return fmt.Errorf("drm event waiter: %w", err)
313313 }
314- defer waiter.Close()
314+ defer func() { err = errors.Join(err, waiter.Close()) }()
315315 waiter.StopOn(ctx)
316316 if err := waiter.Pin(int32(c.fd)); err != nil {
317317 return fmt.Errorf("drm event waiter: %w", err)
@@ -306,12 +306,12 @@ func (c *Card) open(conn connector, mode modeInfo) (*Output, error) {
306 // ReadEvents reads commit events until ctx ends and routes them to the306 // ReadEvents reads commit events until ctx ends and routes them to the
307 // output of their CRTC. Run it once per card. An event is never dropped:307 // output of their CRTC. Run it once per card. An event is never dropped:
308 // the output owes it a pending commit.308 // the output owes it a pending commit.
309-func (c *Card) ReadEvents(ctx context.Context) error {309+func (c *Card) ReadEvents(ctx context.Context) (err error) {
310 waiter, err := fdwait.New()310 waiter, err := fdwait.New()
311 if err != nil {311 if err != nil {
312 return fmt.Errorf("drm event waiter: %w", err)312 return fmt.Errorf("drm event waiter: %w", err)
313 }313 }
314- defer waiter.Close()314+ defer func() { err = errors.Join(err, waiter.Close()) }()
315 waiter.StopOn(ctx)315 waiter.StopOn(ctx)
316 if err := waiter.Pin(int32(c.fd)); err != nil {316 if err := waiter.Pin(int32(c.fd)); err != nil {
317 return fmt.Errorf("drm event waiter: %w", err)317 return fmt.Errorf("drm event waiter: %w", err)
M internal/adapters/drm/commit_test.go +12 -12
@@ -129,7 +129,7 @@ func TestShowImagesTestsBeforeModeset(t *testing.T) {
129129 var b domain.DMABuf
130130 for range 2 {
131131 f, w, _ := os.Pipe()
132- w.Close()
132+ _ = w.Close()
133133 b.Planes = append(b.Planes, domain.DMABufPlane{File: f})
134134 }
135135 b.Modifier = tiledMod
@@ -137,7 +137,7 @@ func TestShowImagesTestsBeforeModeset(t *testing.T) {
137137 }
138138 linear := func() domain.DMABuf {
139139 f, w, _ := os.Pipe()
140- w.Close()
140+ _ = w.Close()
141141 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
142142 }
143143 tiled1 := func() domain.DMABuf {
@@ -183,7 +183,7 @@ func TestShowImagesRetriesSinglePlaneBeforeLinear(t *testing.T) {
183183 b := domain.DMABuf{Modifier: tiledMod}
184184 for range planes {
185185 f, w, _ := os.Pipe()
186- w.Close()
186+ _ = w.Close()
187187 files = append(files, f)
188188 b.Planes = append(b.Planes, domain.DMABufPlane{File: f})
189189 }
@@ -230,7 +230,7 @@ func TestShowImagesOffersThePrimaryPlanesXRGBModifiers(t *testing.T) {
230230 }
231231 buf := func() domain.DMABuf {
232232 f, w, _ := os.Pipe()
233- w.Close()
233+ _ = w.Close()
234234 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
235235 }
236236 r := portsmocks.NewMockRenderer(t)
@@ -259,7 +259,7 @@ func TestShowImagesNoCommonModifierFallsBackWithThePlanesList(t *testing.T) {
259259 o.primary.formats = []domain.DMABufFormat{{Format: fourccXRGB, Modifier: listed}, {Format: fourccXRGB, Modifier: 0}}
260260 buf := func() domain.DMABuf {
261261 f, w, _ := os.Pipe()
262- w.Close()
262+ _ = w.Close()
263263 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
264264 }
265265 r := portsmocks.NewMockRenderer(t)
@@ -337,7 +337,7 @@ func TestShowImagesRefusedLinearImagesAreNotExportedAgain(t *testing.T) {
337337 // linearBuf is a one-plane linear dmabuf over a closed pipe.
338338 func linearBuf() domain.DMABuf {
339339 f, w, _ := os.Pipe()
340- w.Close()
340+ _ = w.Close()
341341 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
342342 }
343343
@@ -348,12 +348,12 @@ func TestShowImagesSkipsSinglePlaneWhenDriverImagesHadOnePlane(t *testing.T) {
348348 o.cursor = nil
349349 buf := func() domain.DMABuf {
350350 f, w, _ := os.Pipe()
351- w.Close()
351+ _ = w.Close()
352352 return domain.DMABuf{Modifier: tiledMod, Planes: []domain.DMABufPlane{{File: f}}}
353353 }
354354 linear := func() domain.DMABuf {
355355 f, w, _ := os.Pipe()
356- w.Close()
356+ _ = w.Close()
357357 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
358358 }
359359 r := portsmocks.NewMockRenderer(t)
@@ -383,7 +383,7 @@ func TestEnableAfterStartAwayModesetsOnce(t *testing.T) {
383383 r := portsmocks.NewMockRenderer(t)
384384 buf := func() domain.DMABuf {
385385 f, w, _ := os.Pipe()
386- w.Close()
386+ _ = w.Close()
387387 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
388388 }
389389 r.EXPECT().SetHDR(float64(0)).Return().Maybe()
@@ -485,7 +485,7 @@ func TestRunReportsSeenAfterCursorCommit(t *testing.T) {
485485 r := portsmocks.NewMockRenderer(t)
486486 buf := func() domain.DMABuf {
487487 f, w, _ := os.Pipe()
488- w.Close()
488+ _ = w.Close()
489489 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
490490 }
491491 r.EXPECT().CursorBuffers(64).Return([2]domain.DMABuf{buf(), buf()}, nil).Once()
@@ -584,7 +584,7 @@ func TestRunClosesFrameFences(t *testing.T) {
584584 r := portsmocks.NewMockRenderer(t)
585585 buf := func() domain.DMABuf {
586586 f, w, _ := os.Pipe()
587- w.Close()
587+ _ = w.Close()
588588 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
589589 }
590590 r.EXPECT().SetHDR(float64(0)).Return().Maybe()
@@ -593,7 +593,7 @@ func TestRunClosesFrameFences(t *testing.T) {
593593 r.EXPECT().Render(mock.Anything, mock.Anything).RunAndReturn(func(domain.Scene, map[domain.WindowID]domain.SurfaceContent) (*os.File, error) {
594594 f, w, _ := os.Pipe()
595595 _, _ = w.Write([]byte{1})
596- w.Close()
596+ _ = w.Close()
597597 return f, nil
598598 })
599599 r.EXPECT().Close().Return().Once()
@@ -129,7 +129,7 @@ func TestShowImagesTestsBeforeModeset(t *testing.T) {
129 var b domain.DMABuf129 var b domain.DMABuf
130 for range 2 {130 for range 2 {
131 f, w, _ := os.Pipe()131 f, w, _ := os.Pipe()
132- w.Close()132+ _ = w.Close()
133 b.Planes = append(b.Planes, domain.DMABufPlane{File: f})133 b.Planes = append(b.Planes, domain.DMABufPlane{File: f})
134 }134 }
135 b.Modifier = tiledMod135 b.Modifier = tiledMod
@@ -137,7 +137,7 @@ func TestShowImagesTestsBeforeModeset(t *testing.T) {
137 }137 }
138 linear := func() domain.DMABuf {138 linear := func() domain.DMABuf {
139 f, w, _ := os.Pipe()139 f, w, _ := os.Pipe()
140- w.Close()140+ _ = w.Close()
141 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}141 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
142 }142 }
143 tiled1 := func() domain.DMABuf {143 tiled1 := func() domain.DMABuf {
@@ -183,7 +183,7 @@ func TestShowImagesRetriesSinglePlaneBeforeLinear(t *testing.T) {
183 b := domain.DMABuf{Modifier: tiledMod}183 b := domain.DMABuf{Modifier: tiledMod}
184 for range planes {184 for range planes {
185 f, w, _ := os.Pipe()185 f, w, _ := os.Pipe()
186- w.Close()186+ _ = w.Close()
187 files = append(files, f)187 files = append(files, f)
188 b.Planes = append(b.Planes, domain.DMABufPlane{File: f})188 b.Planes = append(b.Planes, domain.DMABufPlane{File: f})
189 }189 }
@@ -230,7 +230,7 @@ func TestShowImagesOffersThePrimaryPlanesXRGBModifiers(t *testing.T) {
230 }230 }
231 buf := func() domain.DMABuf {231 buf := func() domain.DMABuf {
232 f, w, _ := os.Pipe()232 f, w, _ := os.Pipe()
233- w.Close()233+ _ = w.Close()
234 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}234 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
235 }235 }
236 r := portsmocks.NewMockRenderer(t)236 r := portsmocks.NewMockRenderer(t)
@@ -259,7 +259,7 @@ func TestShowImagesNoCommonModifierFallsBackWithThePlanesList(t *testing.T) {
259 o.primary.formats = []domain.DMABufFormat{{Format: fourccXRGB, Modifier: listed}, {Format: fourccXRGB, Modifier: 0}}259 o.primary.formats = []domain.DMABufFormat{{Format: fourccXRGB, Modifier: listed}, {Format: fourccXRGB, Modifier: 0}}
260 buf := func() domain.DMABuf {260 buf := func() domain.DMABuf {
261 f, w, _ := os.Pipe()261 f, w, _ := os.Pipe()
262- w.Close()262+ _ = w.Close()
263 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}263 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
264 }264 }
265 r := portsmocks.NewMockRenderer(t)265 r := portsmocks.NewMockRenderer(t)
@@ -337,7 +337,7 @@ func TestShowImagesRefusedLinearImagesAreNotExportedAgain(t *testing.T) {
337 // linearBuf is a one-plane linear dmabuf over a closed pipe.337 // linearBuf is a one-plane linear dmabuf over a closed pipe.
338 func linearBuf() domain.DMABuf {338 func linearBuf() domain.DMABuf {
339 f, w, _ := os.Pipe()339 f, w, _ := os.Pipe()
340- w.Close()340+ _ = w.Close()
341 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}341 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
342 }342 }
343 343
@@ -348,12 +348,12 @@ func TestShowImagesSkipsSinglePlaneWhenDriverImagesHadOnePlane(t *testing.T) {
348 o.cursor = nil348 o.cursor = nil
349 buf := func() domain.DMABuf {349 buf := func() domain.DMABuf {
350 f, w, _ := os.Pipe()350 f, w, _ := os.Pipe()
351- w.Close()351+ _ = w.Close()
352 return domain.DMABuf{Modifier: tiledMod, Planes: []domain.DMABufPlane{{File: f}}}352 return domain.DMABuf{Modifier: tiledMod, Planes: []domain.DMABufPlane{{File: f}}}
353 }353 }
354 linear := func() domain.DMABuf {354 linear := func() domain.DMABuf {
355 f, w, _ := os.Pipe()355 f, w, _ := os.Pipe()
356- w.Close()356+ _ = w.Close()
357 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}357 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
358 }358 }
359 r := portsmocks.NewMockRenderer(t)359 r := portsmocks.NewMockRenderer(t)
@@ -383,7 +383,7 @@ func TestEnableAfterStartAwayModesetsOnce(t *testing.T) {
383 r := portsmocks.NewMockRenderer(t)383 r := portsmocks.NewMockRenderer(t)
384 buf := func() domain.DMABuf {384 buf := func() domain.DMABuf {
385 f, w, _ := os.Pipe()385 f, w, _ := os.Pipe()
386- w.Close()386+ _ = w.Close()
387 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}387 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
388 }388 }
389 r.EXPECT().SetHDR(float64(0)).Return().Maybe()389 r.EXPECT().SetHDR(float64(0)).Return().Maybe()
@@ -485,7 +485,7 @@ func TestRunReportsSeenAfterCursorCommit(t *testing.T) {
485 r := portsmocks.NewMockRenderer(t)485 r := portsmocks.NewMockRenderer(t)
486 buf := func() domain.DMABuf {486 buf := func() domain.DMABuf {
487 f, w, _ := os.Pipe()487 f, w, _ := os.Pipe()
488- w.Close()488+ _ = w.Close()
489 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}489 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
490 }490 }
491 r.EXPECT().CursorBuffers(64).Return([2]domain.DMABuf{buf(), buf()}, nil).Once()491 r.EXPECT().CursorBuffers(64).Return([2]domain.DMABuf{buf(), buf()}, nil).Once()
@@ -584,7 +584,7 @@ func TestRunClosesFrameFences(t *testing.T) {
584 r := portsmocks.NewMockRenderer(t)584 r := portsmocks.NewMockRenderer(t)
585 buf := func() domain.DMABuf {585 buf := func() domain.DMABuf {
586 f, w, _ := os.Pipe()586 f, w, _ := os.Pipe()
587- w.Close()587+ _ = w.Close()
588 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}588 return domain.DMABuf{Planes: []domain.DMABufPlane{{File: f}}}
589 }589 }
590 r.EXPECT().SetHDR(float64(0)).Return().Maybe()590 r.EXPECT().SetHDR(float64(0)).Return().Maybe()
@@ -593,7 +593,7 @@ func TestRunClosesFrameFences(t *testing.T) {
593 r.EXPECT().Render(mock.Anything, mock.Anything).RunAndReturn(func(domain.Scene, map[domain.WindowID]domain.SurfaceContent) (*os.File, error) {593 r.EXPECT().Render(mock.Anything, mock.Anything).RunAndReturn(func(domain.Scene, map[domain.WindowID]domain.SurfaceContent) (*os.File, error) {
594 f, w, _ := os.Pipe()594 f, w, _ := os.Pipe()
595 _, _ = w.Write([]byte{1})595 _, _ = w.Write([]byte{1})
596- w.Close()596+ _ = w.Close()
597 return f, nil597 return f, nil
598 })598 })
599 r.EXPECT().Close().Return().Once()599 r.EXPECT().Close().Return().Once()
M internal/adapters/drm/cursor.go +1 -1
@@ -233,7 +233,7 @@ func (c *Cursor) setImage(pixels []byte, w, h, hotX, hotY int, hdrNits float64)
233233 // when both are busy.
234234 func (c *Cursor) freeSlot() int {
235235 for i, fb := range c.fbs {
236- if fb != c.screen && !(c.flying && c.flight.on && c.flight.fb == fb) {
236+ if fb != c.screen && (!c.flying || !c.flight.on || c.flight.fb != fb) {
237237 return i
238238 }
239239 }
@@ -233,7 +233,7 @@ func (c *Cursor) setImage(pixels []byte, w, h, hotX, hotY int, hdrNits float64)
233 // when both are busy.233 // when both are busy.
234 func (c *Cursor) freeSlot() int {234 func (c *Cursor) freeSlot() int {
235 for i, fb := range c.fbs {235 for i, fb := range c.fbs {
236- if fb != c.screen && !(c.flying && c.flight.on && c.flight.fb == fb) {236+ if fb != c.screen && (!c.flying || !c.flight.on || c.flight.fb != fb) {
237 return i237 return i
238 }238 }
239 }239 }
M internal/adapters/drm/cursor_images.go +1 -1
@@ -137,7 +137,7 @@ func newRendererCursor(k kms, r ports.Renderer, size int) (*rendererCursor, erro
137137 c.fbs[i], err = k.addFB(&bufs[i], fourccARGB)
138138 }
139139 for _, p := range bufs[i].Planes {
140- p.File.Close()
140+ err = errors.Join(err, p.File.Close())
141141 }
142142 }
143143 if err != nil {
@@ -137,7 +137,7 @@ func newRendererCursor(k kms, r ports.Renderer, size int) (*rendererCursor, erro
137 c.fbs[i], err = k.addFB(&bufs[i], fourccARGB)137 c.fbs[i], err = k.addFB(&bufs[i], fourccARGB)
138 }138 }
139 for _, p := range bufs[i].Planes {139 for _, p := range bufs[i].Planes {
140- p.File.Close()140+ err = errors.Join(err, p.File.Close())
141 }141 }
142 }142 }
143 if err != nil {143 if err != nil {
M internal/adapters/drm/dumb_device_test.go +1 -1
@@ -24,7 +24,7 @@ func TestDumbBuffersOnRealDevice(t *testing.T) {
2424 continue
2525 }
2626 done := func() bool {
27- defer f.Close()
27+ defer func() { _ = f.Close() }()
2828 return dumbDeviceRoundTrip(t, path, kmsDevice{fd: int(f.Fd())})
2929 }()
3030 if done {
@@ -24,7 +24,7 @@ func TestDumbBuffersOnRealDevice(t *testing.T) {
24 continue24 continue
25 }25 }
26 done := func() bool {26 done := func() bool {
27- defer f.Close()27+ defer func() { _ = f.Close() }()
28 return dumbDeviceRoundTrip(t, path, kmsDevice{fd: int(f.Fd())})28 return dumbDeviceRoundTrip(t, path, kmsDevice{fd: int(f.Fd())})
29 }()29 }()
30 if done {30 if done {
M internal/adapters/drm/edid.go +16 -3
M internal/adapters/drm/fencegate_test.go +6 -5
M internal/adapters/drm/frame_lifecycle.go +8 -4
M internal/adapters/drm/frame_submit.go +23 -23
M internal/adapters/drm/front_test.go +3 -3
M internal/adapters/drm/gbm/gbm_test.go +9 -9
M internal/adapters/drm/hdr_test.go +4 -4
M internal/adapters/drm/hotplug.go +3 -3
M internal/adapters/drm/images.go +1 -1
M internal/adapters/drm/lease.go +1 -2
M internal/adapters/drm/lease_test.go +2 -2
M internal/adapters/drm/multigpu.go +2 -2
M internal/adapters/drm/multigpu_test.go +12 -11
M internal/adapters/drm/output.go +3 -3
M internal/adapters/drm/output_test.go +18 -18
M internal/adapters/drm/overlay.go +6 -3
M internal/adapters/drm/overlay_test.go +4 -3
M internal/adapters/drm/power_test.go +2 -2
M internal/adapters/drm/protection.go +2 -2
M internal/adapters/drm/protection_retry_test.go +4 -4
M internal/adapters/drm/protection_test.go +2 -2
M internal/adapters/drm/reads.go +10 -2
M internal/adapters/drm/scanout_test.go +2 -1
M internal/adapters/drm/security.go +3 -3
M internal/adapters/drm/security_recovery_test.go +1 -1
M internal/adapters/drm/security_run_test.go +1 -1
M internal/adapters/drm/security_startup_test.go +3 -3
M internal/adapters/drm/stuck_test.go +2 -2
M internal/adapters/drm/supervisor/cards.go +1 -1
M internal/adapters/drm/supervisor/supervisor.go +2 -2
M internal/adapters/drm/supervisor/virtuals_test.go +5 -3
M internal/adapters/drm/vrr.go +1 -1
M internal/adapters/drm/vrr_flip_gap_test.go +1 -1
M internal/adapters/fdwait/duplicate_test.go +6 -6
M internal/adapters/fdwait/edges_test.go +25 -15
M internal/adapters/fdwait/poller.go +5 -10
M internal/adapters/fdwait/poller_test.go +5 -5
M internal/adapters/headless/capture_test.go +1 -1
M internal/adapters/headless/output.go +36 -24
M internal/adapters/headless/output_test.go +2 -2
M internal/adapters/headless/security_capture_test.go +1 -1
M internal/adapters/headless/security_exclude_fence_test.go +1 -1
M internal/adapters/headless/security_test.go +3 -3
M internal/adapters/hints/detector_proc_test.go +1 -1
M internal/adapters/hints/detector_test.go +5 -5
M internal/adapters/hints/dump_test.go +1 -1
M internal/adapters/hints/hints_test.go +1 -1
M internal/adapters/hints/ocr_test.go +3 -3
M internal/adapters/hints/underline_test.go +1 -1
M internal/adapters/launcher/launcher_test.go +2 -1
M internal/adapters/launcher/session.go +5 -1
M internal/adapters/launcher/session_test.go +1 -1
M internal/adapters/libinput/libinput.go +2 -2
A internal/adapters/logging/close.go +32 -0
M internal/adapters/logging/logging.go +31 -16
M internal/adapters/logging/logging_test.go +3 -3
M internal/adapters/outputkit/capture/offscreen.go +14 -7
M internal/adapters/outputkit/capture/offscreen_fence_test.go +1 -1
M internal/adapters/outputkit/capture/pipeline.go +11 -5
M internal/adapters/outputkit/capture/security_test.go +1 -1
M internal/adapters/outputkit/routing/leases.go +15 -5
M internal/adapters/outputkit/routing/leases_test.go +3 -3
M internal/adapters/outputkit/routing/outputs.go +1 -1
M internal/adapters/outputkit/surfaces/surfaces_test.go +4 -4
M internal/adapters/peerexe/peerexe.go +2 -2
M internal/adapters/peerexe/peerexe_test.go +10 -10
M internal/adapters/powerkey/bus_test.go +2 -2
M internal/adapters/powerkey/dial_cancel_test.go +2 -2
M internal/adapters/screencast/acquire_test.go +3 -2
M internal/adapters/screencast/bus_test.go +5 -5
M internal/adapters/screencast/harness_test.go +1 -1
M internal/adapters/screencast/screencast.go +13 -5
M internal/adapters/screencast/session.go +1 -1
M internal/adapters/screensaver/dial_cancel_test.go +2 -2
M internal/adapters/seat/seat.go +6 -5
M internal/adapters/sessiondir/sessiondir.go +20 -17
M internal/adapters/sessiondir/sessiondir_test.go +1 -1
M internal/adapters/statefile/statefile.go +9 -4
M internal/adapters/syncfile/syncfile_test.go +6 -6
M internal/adapters/vulkan/capture_cursor_test.go +1 -1
M internal/adapters/vulkan/capture_dmabuf.go +2 -4
M internal/adapters/vulkan/capture_dmabuf_test.go +4 -4
M internal/adapters/vulkan/capture_import_test.go +2 -2
M internal/adapters/vulkan/capture_test.go +4 -4
M internal/adapters/vulkan/capture_trim_test.go +1 -1
M internal/adapters/vulkan/cast_alloc_test.go +1 -1
M internal/adapters/vulkan/compose_test.go +6 -6
M internal/adapters/vulkan/copy.go +6 -6
M internal/adapters/vulkan/copy_test.go +4 -4
M internal/adapters/vulkan/cursor.go +2 -1
M internal/adapters/vulkan/cursor_test.go +2 -2
M internal/adapters/vulkan/damage_delta_test.go +1 -1
M internal/adapters/vulkan/damage_test.go +1 -1
M internal/adapters/vulkan/dmabuf.go +8 -6
M internal/adapters/vulkan/dmabuf_test.go +5 -5
M internal/adapters/vulkan/extended_linear_test.go +3 -3
M internal/adapters/vulkan/frame.go +6 -3
M internal/adapters/vulkan/gpu_test.go +2 -2
M internal/adapters/vulkan/hdr_composition_test.go +3 -3
M internal/adapters/vulkan/renderer_test.go +1 -1
M internal/adapters/vulkan/scene.go +2 -2
M internal/adapters/vulkan/scene_fade_test.go +1 -1
M internal/adapters/vulkan/shm.go +5 -5
M internal/adapters/vulkan/shm_pread_test.go +6 -6
M internal/adapters/vulkan/targets.go +11 -7
M internal/adapters/vulkan/targets_perf_test.go +1 -1
M internal/adapters/vulkan/targets_test.go +12 -11
M internal/adapters/vulkan/trim_test.go +1 -1
M internal/adapters/vulkan/yuv.go +3 -4
M internal/adapters/vulkan/yuv_test.go +4 -4
M internal/adapters/watchdog/watchdog.go +6 -10
M internal/adapters/wayland/acquire_failure_test.go +3 -3
M internal/adapters/wayland/activation.go +1 -1
M internal/adapters/wayland/alloc_hotpath_test.go +1 -1
M internal/adapters/wayland/captureauth_test.go +4 -4
M internal/adapters/wayland/clipboard.go +8 -8
M internal/adapters/wayland/clipboard_test.go +2 -2
M internal/adapters/wayland/clipboard_xwm.go +4 -3
M internal/adapters/wayland/clipboard_xwm_test.go +4 -4
M internal/adapters/wayland/colormanagement.go +5 -4
M internal/adapters/wayland/commands_test.go +3 -3
M internal/adapters/wayland/commit_hotpath_bench_test.go +3 -3
M internal/adapters/wayland/commit_lifecycle_test.go +6 -5
M internal/adapters/wayland/constraints.go +5 -5
M internal/adapters/wayland/contentlink_test.go +1 -1
M internal/adapters/wayland/cursor_test.go +2 -2
M internal/adapters/wayland/damage_test.go +1 -1
M internal/adapters/wayland/dialog_test.go +1 -1
M internal/adapters/wayland/dmabuf.go +15 -14
M internal/adapters/wayland/dmabuf_test.go +7 -7
M internal/adapters/wayland/dmabuf_yuv_test.go +1 -1
M internal/adapters/wayland/dnd.go +8 -8
M internal/adapters/wayland/dnd_test.go +3 -3
M internal/adapters/wayland/drmlease.go +30 -12
M internal/adapters/wayland/drmlease_test.go +13 -13
M internal/adapters/wayland/exclusion.go +2 -2
M internal/adapters/wayland/fifo.go +3 -3
M internal/adapters/wayland/fifo_test.go +2 -2
M internal/adapters/wayland/foreign_test.go +2 -2
M internal/adapters/wayland/frames.go +1 -1
M internal/adapters/wayland/gestures.go +4 -4
M internal/adapters/wayland/globals.go +20 -10
M internal/adapters/wayland/idle.go +2 -2
M internal/adapters/wayland/idle_test.go +2 -2
M internal/adapters/wayland/inhibit.go +1 -1
M internal/adapters/wayland/initial_fullscreen_test.go +2 -1
M internal/adapters/wayland/input_region_test.go +1 -1
M internal/adapters/wayland/keyboard_test.go +3 -3
M internal/adapters/wayland/layer.go +2 -2
M internal/adapters/wayland/layer_test.go +3 -3
M internal/adapters/wayland/legacy_fullscreen_test.go +2 -1
M internal/adapters/wayland/move_request_test.go +2 -2
M internal/adapters/wayland/outputconfiguration.go +2 -2
M internal/adapters/wayland/outputs.go +3 -3
M internal/adapters/wayland/pace_inline_test.go +1 -1
M internal/adapters/wayland/popup.go +2 -2
M internal/adapters/wayland/postring_test.go +2 -1
M internal/adapters/wayland/presentation.go +5 -5
M internal/adapters/wayland/presentation_test.go +2 -2
M internal/adapters/wayland/protocol_test.go +9 -9
M internal/adapters/wayland/release.go +2 -2
M internal/adapters/wayland/release_test.go +1 -1
M internal/adapters/wayland/scale.go +3 -3
M internal/adapters/wayland/scale_test.go +6 -6
M internal/adapters/wayland/screencast_test.go +2 -1
M internal/adapters/wayland/screencopy.go +10 -8
M internal/adapters/wayland/screencopy_dmabuf_test.go +3 -3
M internal/adapters/wayland/screencopy_test.go +6 -6
M internal/adapters/wayland/seat.go +9 -8
M internal/adapters/wayland/securitycontext.go +10 -9
M internal/adapters/wayland/securitycontext_test.go +7 -7
M internal/adapters/wayland/sensitive_test.go +2 -2
M internal/adapters/wayland/server.go +11 -10
M internal/adapters/wayland/server_test.go +2 -1
M internal/adapters/wayland/session_lock_barrier_test.go +1 -1
M internal/adapters/wayland/session_lock_lifecycle_test.go +3 -3
M internal/adapters/wayland/session_lock_surface_test.go +2 -2
M internal/adapters/wayland/socket.go +19 -5
M internal/adapters/wayland/socket_test.go +11 -10
M internal/adapters/wayland/subsurface_test.go +1 -1
M internal/adapters/wayland/surface.go +1 -1
M internal/adapters/wayland/syncdev.go +6 -4
M internal/adapters/wayland/syncobj.go +33 -26
M internal/adapters/wayland/syncobj_test.go +8 -7
M internal/adapters/wayland/syncwait_test.go +5 -5
M internal/adapters/wayland/textinput.go +2 -2
M internal/adapters/wayland/textinput_test.go +1 -1
M internal/adapters/wayland/tiled_playback_test.go +3 -3
M internal/adapters/wayland/transform_test.go +2 -2
M internal/adapters/wayland/virtualkeyboard.go +9 -8
M internal/adapters/wayland/virtualkeyboard_test.go +2 -2
M internal/adapters/wayland/window.go +4 -4
M internal/adapters/wayland/x11peer_test.go +1 -1
M internal/adapters/wayland/x11window.go +1 -1
M internal/adapters/wayland/x11window_test.go +2 -2
M internal/adapters/wayland/xdg.go +5 -1
M internal/adapters/wayland/xwayland_test.go +4 -4
M internal/adapters/wayland/xwaylandgrab.go +3 -3
M internal/adapters/wayland/xwm/mapflow.go +4 -4
M internal/adapters/wayland/xwm/selection_test.go +8 -8
M internal/adapters/wayland/xwm/xpeer_test.go +1 -1
M internal/adapters/xcursor/xcursor.go +15 -3
M internal/adapters/xwayland/builtin.go +14 -8
M internal/adapters/xwayland/xwayland.go +15 -13
M internal/adapters/xwayland/xwayland_test.go +14 -13
M internal/app/app_test.go +2 -2
M internal/app/control_client_test.go +1 -1
M internal/app/control_test.go +2 -2
M internal/app/gbm_targets_test.go +4 -4
M internal/app/pointercli_test.go +3 -3
M internal/app/session.go +10 -2
M internal/app/session_lock_test.go +2 -2
M internal/app/spawn_client_test.go +3 -3
M internal/app/textinput_test.go +3 -2
M internal/cli/cli.go +5 -5
M internal/cli/commands.go +9 -7
M internal/cli/control.go +9 -4
M internal/cli/control_test.go +7 -7
M internal/cli/inject.go +2 -2
M internal/cli/output.go +2 -2
M internal/cli/output_test.go +2 -2
M internal/cli/run.go +15 -3
M internal/cli/session.go +3 -1
M internal/cli/session_new.go +29 -12
M internal/cli/session_new_test.go +2 -2
M internal/cli/session_rm.go +8 -8
M internal/cli/session_rm_test.go +4 -4
M internal/cli/session_test.go +1 -1
M internal/cli/shot.go +2 -2
M internal/cli/shot_test.go +4 -4
M internal/cli/target_test.go +1 -1
M internal/core/capture_test.go +2 -2
M internal/core/clientgesture_test.go +1 -1
M internal/core/constraint_frame_test.go +1 -1
M internal/core/controloutput_test.go +1 -1
M internal/core/core_test.go +18 -18
M internal/core/device_epoch_test.go +1 -1
M internal/core/drag_test.go +1 -1
M internal/core/edge_target_test.go +3 -2
M internal/core/hint_test.go +3 -3
M internal/core/inhibit_test.go +2 -2
M internal/core/input_bench_test.go +1 -1
M internal/core/layer_input_test.go +8 -8
M internal/core/layout_perf_test.go +1 -1
M internal/core/overview_input_test.go +4 -4
M internal/core/persist_test.go +1 -1
M internal/core/power_test.go +1 -1
M internal/core/repeat_run_test.go +1 -1
M internal/core/screens_test.go +2 -2
M internal/core/sdr_expansion.go +1 -1
M internal/core/seat_test.go +1 -1
M internal/core/separators.go +1 -1
M internal/core/slots_test.go +3 -3
M internal/core/spawn_placement.go +2 -2
M internal/core/swipe_test.go +1 -1
M internal/core/transition_fade_internal_test.go +2 -2
M internal/core/transition_map_internal_test.go +2 -2
M internal/core/transition_overview_internal_test.go +1 -1
M internal/core/transition_stash_internal_test.go +3 -3
M internal/core/transition_unmap_internal_test.go +1 -1
M internal/core/virtualpointer_test.go +2 -2
M internal/core/workspace/layout.go +1 -1
M internal/core/workspace/layout_conformance_geometry_test.go +1 -1
M internal/core/workspace/maximize.go +1 -1
M internal/core/workspace/workspace_operations.go +4 -3
M internal/core/x11active.go +3 -3
M internal/ports/lease.go +6 -4
M internal/ports/lease_test.go +21 -4
M tools/go.mod +1 -1
M tools/go.sum +2 -2

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. On pages with a side panel: into the panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit; in a file, click a line number to select it, shift-click for a range
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
l
merge request: the list of files (j k move, enter opens, esc back)
M
merge request: the merge menu; there 1–3 pick the mode, D deletes the branch, enter merges
R
merge request: mark the head read
esc
close a dialog, leave a field

Branches 33

Tags 15

↑↓ moveenter openesc close