Add golangci-lint gate and fix its findings
Configure golangci-lint v2 for the whole tree (brlapi/duckdb build tags, curated linters, documented exclusions) and resolve what it reports: dead code, wrapped-error comparisons and %w wrapping, unclosed websocket handshake bodies, staticcheck SA/S items, ineffectual assignments, and explicit _ = discards for best-effort teardown errors. Document the gate in CONTRIBUTING and AGENTS.
This commit is contained in:
1 parent
b03cb8917d
commit
0459fb8e50
43 files changed
+166
-112
No files matched your search
@@ -0,0 +1,64 @@
|
|||||||
|
version: "2"
|
||||||
|
|
||||||
|
run:
|
||||||
|
# The Braille helper and the DuckDB debug-log sink live behind build tags;
|
||||||
|
# without listing them here those files are silently never analyzed.
|
||||||
|
# Analyzing with these tags needs the same development libraries as the
|
||||||
|
# Arch PKGBUILD (at-spi2, gtk3, brltty, liblouis, duckdb headers).
|
||||||
|
build-tags:
|
||||||
|
- brlapi
|
||||||
|
- duckdb
|
||||||
|
timeout: 5m
|
||||||
|
|
||||||
|
linters:
|
||||||
|
default: standard
|
||||||
|
enable:
|
||||||
|
- bodyclose
|
||||||
|
- errorlint
|
||||||
|
- misspell
|
||||||
|
settings:
|
||||||
|
staticcheck:
|
||||||
|
# Bug (SA) and simplification (S) checks only. ST style checks
|
||||||
|
# conflict with deliberate complete, capitalized user-facing
|
||||||
|
# messages, and QF quickfixes are optional rewrites; neither should
|
||||||
|
# gate contributions. S1005 conflicts with errcheck: receiving an
|
||||||
|
# error result purely for synchronization is discarded explicitly
|
||||||
|
# with _ = <-ch rather than silently.
|
||||||
|
checks:
|
||||||
|
- all
|
||||||
|
- -ST*
|
||||||
|
- -QF*
|
||||||
|
- -S1005
|
||||||
|
errcheck:
|
||||||
|
exclude-functions:
|
||||||
|
# CLI usage/status output: there is nothing useful to do if writing
|
||||||
|
# the message itself fails.
|
||||||
|
- fmt.Fprint
|
||||||
|
- fmt.Fprintf
|
||||||
|
- fmt.Fprintln
|
||||||
|
exclusions:
|
||||||
|
rules:
|
||||||
|
# Close on cleanup paths (pipe ends after spawning helpers,
|
||||||
|
# connections and files being discarded) is best-effort teardown
|
||||||
|
# with no actionable recovery. Closes whose errors protect data
|
||||||
|
# (flushing writers, saved configuration, the debug database)
|
||||||
|
# are handled explicitly at those call sites and must stay handled.
|
||||||
|
- text: 'Error return value of `[^`]+\.Close` is not checked'
|
||||||
|
linters:
|
||||||
|
- errcheck
|
||||||
|
# Tests routinely ignore fixture teardown errors, and assert exact
|
||||||
|
# sentinel identity on errors they constructed unwrapped.
|
||||||
|
# Production code must still handle errors or discard them
|
||||||
|
# explicitly with _ =.
|
||||||
|
- path: _test\.go
|
||||||
|
linters:
|
||||||
|
- errcheck
|
||||||
|
- errorlint
|
||||||
|
|
||||||
|
issues:
|
||||||
|
max-issues-per-linter: 0
|
||||||
|
max-same-issues: 0
|
||||||
|
|
||||||
|
formatters:
|
||||||
|
enable:
|
||||||
|
- gofmt
|
||||||
@@ -41,6 +41,7 @@ go test ./... -count=1
|
|||||||
go test -race ./... -count=1
|
go test -race ./... -count=1
|
||||||
go test -tags brlapi ./... -count=1
|
go test -tags brlapi ./... -count=1
|
||||||
go vet ./...
|
go vet ./...
|
||||||
|
golangci-lint run ./...
|
||||||
go build ./cmd/...
|
go build ./cmd/...
|
||||||
go run ./cmd/parityledger validate testdata/parity-ledger.csv
|
go run ./cmd/parityledger validate testdata/parity-ledger.csv
|
||||||
```
|
```
|
||||||
@@ -54,6 +55,19 @@ they use isolated fake tools and require no network or running reader.
|
|||||||
|
|
||||||
Start verification with the affected packages; run broader checks when the change affects shared behavior or before submission where practical. Format edited Go files with `gofmt`; run `shellcheck` for edited shell scripts. Use deterministic tests and synchronization instead of timing sleeps. Keep fixtures generic, without real usernames or personal identifiers.
|
Start verification with the affected packages; run broader checks when the change affects shared behavior or before submission where practical. Format edited Go files with `gofmt`; run `shellcheck` for edited shell scripts. Use deterministic tests and synchronization instead of timing sleeps. Keep fixtures generic, without real usernames or personal identifiers.
|
||||||
|
|
||||||
|
Lint with `golangci-lint run ./...` before submission. The configuration in
|
||||||
|
`.golangci.yml` is v2-schema and already sets the `brlapi` and `duckdb`
|
||||||
|
build tags, so tagged native files are analyzed; that needs the same
|
||||||
|
development libraries as the Arch `PKGBUILD`, including BrlAPI/liblouis and
|
||||||
|
the DuckDB headers. Keep `golangci-lint` built with a Go version at least
|
||||||
|
as new as the project toolchain: an older linter cannot decode current
|
||||||
|
export data and reports spurious typecheck errors. Deliberate exclusions
|
||||||
|
(cleanup `Close` calls, test-fixture error handling, style checks that
|
||||||
|
conflict with complete user-facing messages) are documented in the config;
|
||||||
|
do not weaken them to silence a finding that should be fixed in code
|
||||||
|
instead. Lint is a development gate only and is not run by the Arch package
|
||||||
|
`check()`, so distribution linter updates cannot break package builds.
|
||||||
|
|
||||||
### Version update pre-commit hook
|
### Version update pre-commit hook
|
||||||
|
|
||||||
The optional `hooks/pre-commit` hook updates the Go `Version` constant to the
|
The optional `hooks/pre-commit` hook updates the Go `Version` constant to the
|
||||||
|
|||||||
@@ -70,7 +70,10 @@ func run() (runError error) {
|
|||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
if state, err := session.Status(); state != tentacle.Ready {
|
if state, err := session.Status(); state != tentacle.Ready {
|
||||||
return fmt.Errorf("startup %s: %v", state, err)
|
if err == nil {
|
||||||
|
return fmt.Errorf("startup %s: <nil>", state)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("startup %s: %w", state, err)
|
||||||
}
|
}
|
||||||
if err := session.Activate(); err != nil {
|
if err := session.Activate(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ func (worker *brailleWorker) session(ctx context.Context) (connectedFor time.Dur
|
|||||||
if detail := strings.TrimSpace(stderr.String()); detail != "" {
|
if detail := strings.TrimSpace(stderr.String()); detail != "" {
|
||||||
result = fmt.Errorf("%w: %s", result, detail)
|
result = fmt.Errorf("%w: %s", result, detail)
|
||||||
} else if waitErr != nil {
|
} else if waitErr != nil {
|
||||||
result = fmt.Errorf("%w: %v", result, waitErr)
|
result = fmt.Errorf("%w: %w", result, waitErr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ func watch_clipboard(ctx context.Context, live *liveSettings, gate *focusGate, s
|
|||||||
if err := command.Start(); err != nil {
|
if err := command.Start(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() { cancel(); in.Close(); out.Close(); command.Wait() }()
|
defer func() { cancel(); in.Close(); out.Close(); _ = command.Wait() }()
|
||||||
changes := make(chan clipboard.TextChange, 128)
|
changes := make(chan clipboard.TextChange, 128)
|
||||||
failures := make(chan error, 1)
|
failures := make(chan error, 1)
|
||||||
readerDone := make(chan struct{})
|
readerDone := make(chan struct{})
|
||||||
|
|||||||
@@ -76,23 +76,23 @@ func (speaker *echoSpeaker) UpdateConfiguration(ctx context.Context, settings co
|
|||||||
client := speech.NewWithSettings(speaker.socket, values)
|
client := speech.NewWithSettings(speaker.socket, values)
|
||||||
candidates[kind] = client
|
candidates[kind] = client
|
||||||
if err := client.Connect(ctx); err != nil {
|
if err := client.Connect(ctx); err != nil {
|
||||||
closeClients(candidates)
|
_ = closeClients(candidates)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
speaker.mu.Lock()
|
speaker.mu.Lock()
|
||||||
defer speaker.mu.Unlock()
|
defer speaker.mu.Unlock()
|
||||||
if speaker.closed {
|
if speaker.closed {
|
||||||
closeClients(candidates)
|
_ = closeClients(candidates)
|
||||||
return errors.New("speech is closed")
|
return errors.New("speech is closed")
|
||||||
}
|
}
|
||||||
if err := ctx.Err(); err != nil {
|
if err := ctx.Err(); err != nil {
|
||||||
closeClients(candidates)
|
_ = closeClients(candidates)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, client := range speaker.voices {
|
for _, client := range speaker.voices {
|
||||||
if err := client.Cancel(ctx); err != nil {
|
if err := client.Cancel(ctx); err != nil {
|
||||||
closeClients(candidates)
|
_ = closeClients(candidates)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,10 +270,6 @@ func (presenter *eventPresenter) speak(event atspi.Event, capturedIntent ...inpu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func presentationFallbackText(event atspi.Event, options presentation.Options) string {
|
|
||||||
return presentationFallbackSpeech(event, options).Text
|
|
||||||
}
|
|
||||||
|
|
||||||
func presentationFallbackSpeech(event atspi.Event, options presentation.Options) presentation.Speech {
|
func presentationFallbackSpeech(event atspi.Event, options presentation.Options) presentation.Speech {
|
||||||
if options.RoleSoundPresentation != "sound_only" {
|
if options.RoleSoundPresentation != "sound_only" {
|
||||||
return presentation.Speech{}
|
return presentation.Speech{}
|
||||||
|
|||||||
+2
-1
@@ -7,6 +7,7 @@ package app
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ func i3ModeName(name string, markup bool) string {
|
|||||||
var text strings.Builder
|
var text strings.Builder
|
||||||
for {
|
for {
|
||||||
token, err := decoder.Token()
|
token, err := decoder.Token()
|
||||||
if err == io.EOF {
|
if errors.Is(err, io.EOF) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+17
-17
@@ -187,7 +187,7 @@ func (ui *internalUI) run(ctx context.Context) {
|
|||||||
documentList = review.DocumentListSnapshot{}
|
documentList = review.DocumentListSnapshot{}
|
||||||
return closeErr
|
return closeErr
|
||||||
}
|
}
|
||||||
defer func() { finish(internalUIResult{Cancelled: true}) }()
|
defer func() { _ = finish(internalUIResult{Cancelled: true}) }()
|
||||||
// Native capture can be revoked by lock, focus change or handoff without a
|
// Native capture can be revoked by lock, focus change or handoff without a
|
||||||
// command being delivered (secure input deliberately drains command queues).
|
// command being delivered (secure input deliberately drains command queues).
|
||||||
ticker := time.NewTicker(50 * time.Millisecond)
|
ticker := time.NewTicker(50 * time.Millisecond)
|
||||||
@@ -197,10 +197,10 @@ func (ui *internalUI) run(ctx context.Context) {
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
case <-requestDone:
|
case <-requestDone:
|
||||||
finish(internalUIResult{Cancelled: true})
|
_ = finish(internalUIResult{Cancelled: true})
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if sessionID != 0 && ui.keys.InternalUISession() != sessionID {
|
if sessionID != 0 && ui.keys.InternalUISession() != sessionID {
|
||||||
finish(internalUIResult{Cancelled: true})
|
_ = finish(internalUIResult{Cancelled: true})
|
||||||
}
|
}
|
||||||
case notice := <-ui.notices:
|
case notice := <-ui.notices:
|
||||||
if sessionID != 0 && requestDone == notice.ctx.Done() && ui.keys.InternalUISession() == sessionID {
|
if sessionID != 0 && requestDone == notice.ctx.Done() && ui.keys.InternalUISession() == sessionID {
|
||||||
@@ -245,7 +245,7 @@ func (ui *internalUI) run(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
cancel()
|
cancel()
|
||||||
if sessionID == 0 || ui.keys.InternalUISession() != sessionID {
|
if sessionID == 0 || ui.keys.InternalUISession() != sessionID {
|
||||||
finish(internalUIResult{Cancelled: true})
|
_ = finish(internalUIResult{Cancelled: true})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err != nil || session == nil {
|
if err != nil || session == nil {
|
||||||
@@ -253,7 +253,7 @@ func (ui *internalUI) run(ctx context.Context) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
message = "Browser list unavailable"
|
message = "Browser list unavailable"
|
||||||
}
|
}
|
||||||
finish(internalUIResult{Err: err})
|
_ = finish(internalUIResult{Err: err})
|
||||||
ui.browserListMessage(message)
|
ui.browserListMessage(message)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -269,13 +269,13 @@ func (ui *internalUI) run(ctx context.Context) {
|
|||||||
sessionID, err = ui.keys.BeginInternalUI(lookupCtx)
|
sessionID, err = ui.keys.BeginInternalUI(lookupCtx)
|
||||||
cancel()
|
cancel()
|
||||||
if err != nil || sessionID == 0 || ui.keys.InternalUISession() != sessionID {
|
if err != nil || sessionID == 0 || ui.keys.InternalUISession() != sessionID {
|
||||||
finish(internalUIResult{Cancelled: true})
|
_ = finish(internalUIResult{Cancelled: true})
|
||||||
ui.emoji_message("Emoji Menu unavailable")
|
ui.emoji_message("Emoji Menu unavailable")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
session, err = emoji.NewSession(copyEmoji)
|
session, err = emoji.NewSession(copyEmoji)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
finish(internalUIResult{Err: err})
|
_ = finish(internalUIResult{Err: err})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
emojiActive = true
|
emojiActive = true
|
||||||
@@ -284,11 +284,11 @@ func (ui *internalUI) run(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
if event.Command == input.ShowActions {
|
if event.Command == input.ShowActions {
|
||||||
if sessionID != 0 {
|
if sessionID != 0 {
|
||||||
finish(internalUIResult{Cancelled: true})
|
_ = finish(internalUIResult{Cancelled: true})
|
||||||
}
|
}
|
||||||
sessionID = event.UISession
|
sessionID = event.UISession
|
||||||
if sessionID == 0 || ui.actions == nil || ui.interest == nil {
|
if sessionID == 0 || ui.actions == nil || ui.interest == nil {
|
||||||
finish(internalUIResult{Err: errors.New("actions unavailable")})
|
_ = finish(internalUIResult{Err: errors.New("actions unavailable")})
|
||||||
ui.speech.Enqueue(speechRequest{Text: "Actions unavailable", Role: "system", Cause: "internal-ui"})
|
ui.speech.Enqueue(speechRequest{Text: "Actions unavailable", Role: "system", Cause: "internal-ui"})
|
||||||
if ui.braille != nil {
|
if ui.braille != nil {
|
||||||
ui.braille.EnqueueMessage("Actions unavailable")
|
ui.braille.EnqueueMessage("Actions unavailable")
|
||||||
@@ -303,11 +303,11 @@ func (ui *internalUI) run(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
cancel()
|
cancel()
|
||||||
if ui.keys.InternalUISession() != sessionID {
|
if ui.keys.InternalUISession() != sessionID {
|
||||||
finish(internalUIResult{Cancelled: true})
|
_ = finish(internalUIResult{Cancelled: true})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err != nil || len(actions.Actions) == 0 {
|
if err != nil || len(actions.Actions) == 0 {
|
||||||
finish(internalUIResult{Err: err})
|
_ = finish(internalUIResult{Err: err})
|
||||||
message := "No actions found"
|
message := "No actions found"
|
||||||
if err != nil {
|
if err != nil {
|
||||||
message = "Actions unavailable"
|
message = "Actions unavailable"
|
||||||
@@ -324,7 +324,7 @@ func (ui *internalUI) run(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
session, err = interaction.NewSession(interaction.Form{Title: "Actions", Elements: []interaction.Element{{ID: "actions", Label: "Actions", Kind: interaction.List, Items: items}}})
|
session, err = interaction.NewSession(interaction.Form{Title: "Actions", Elements: []interaction.Element{{ID: "actions", Label: "Actions", Kind: interaction.List, Items: items}}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
finish(internalUIResult{Err: err})
|
_ = finish(internalUIResult{Err: err})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
target = actions.Target
|
target = actions.Target
|
||||||
@@ -335,17 +335,17 @@ func (ui *internalUI) run(ctx context.Context) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if event.Command == input.InternalUIDismiss {
|
if event.Command == input.InternalUIDismiss {
|
||||||
finish(internalUIResult{Cancelled: true})
|
_ = finish(internalUIResult{Cancelled: true})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
key := internal_ui_event(event)
|
key := internal_ui_event(event)
|
||||||
effect := session.Handle(key)
|
effect := session.Handle(key)
|
||||||
if effect.Cancelled {
|
if effect.Cancelled {
|
||||||
finish(internalUIResult{Cancelled: true})
|
_ = finish(internalUIResult{Cancelled: true})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ui.keys.InternalUISession() != sessionID {
|
if ui.keys.InternalUISession() != sessionID {
|
||||||
finish(internalUIResult{Cancelled: true})
|
_ = finish(internalUIResult{Cancelled: true})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if effect.Paste {
|
if effect.Paste {
|
||||||
@@ -353,7 +353,7 @@ func (ui *internalUI) run(ctx context.Context) {
|
|||||||
text, err := read_internal_clipboard(clipboardCtx)
|
text, err := read_internal_clipboard(clipboardCtx)
|
||||||
cancel()
|
cancel()
|
||||||
if ui.keys.InternalUISession() != sessionID {
|
if ui.keys.InternalUISession() != sessionID {
|
||||||
finish(internalUIResult{Cancelled: true})
|
_ = finish(internalUIResult{Cancelled: true})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -367,7 +367,7 @@ func (ui *internalUI) run(ctx context.Context) {
|
|||||||
err := (xclipOCRCopier{}).Copy(copyCtx, *effect.Copy)
|
err := (xclipOCRCopier{}).Copy(copyCtx, *effect.Copy)
|
||||||
cancel()
|
cancel()
|
||||||
if ui.keys.InternalUISession() != sessionID {
|
if ui.keys.InternalUISession() != sessionID {
|
||||||
finish(internalUIResult{Cancelled: true})
|
_ = finish(internalUIResult{Cancelled: true})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
message := "Copied"
|
message := "Copied"
|
||||||
|
|||||||
@@ -129,13 +129,13 @@ func TestNativeBrowserNamedLinks(t *testing.T) {
|
|||||||
if _, err := cursor.SyncFocus(ctx, labelOnly.ID()); err != nil {
|
if _, err := cursor.SyncFocus(ctx, labelOnly.ID()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for _, want := range []rune("xample Info Page.") {
|
for _, want := range "xample Info Page." {
|
||||||
move, err := cursor.MoveCaret(ctx, adapter, review.CaretNextCharacter)
|
move, err := cursor.MoveCaret(ctx, adapter, review.CaretNextCharacter)
|
||||||
if err != nil || !move.Moved || move.Text != string(want) {
|
if err != nil || !move.Moved || move.Text != string(want) {
|
||||||
t.Fatalf("label-only character: %+v, %v; want %q", move, err, want)
|
t.Fatalf("label-only character: %+v, %v; want %q", move, err, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, want := range []rune("egaP ofnI elpmaxE") {
|
for _, want := range "egaP ofnI elpmaxE" {
|
||||||
move, err := cursor.MoveCaret(ctx, adapter, review.CaretPreviousCharacter)
|
move, err := cursor.MoveCaret(ctx, adapter, review.CaretPreviousCharacter)
|
||||||
if err != nil || !move.Moved || move.Text != string(want) {
|
if err != nil || !move.Moved || move.Text != string(want) {
|
||||||
t.Fatalf("reverse label-only character: %+v, %v; want %q", move, err, want)
|
t.Fatalf("reverse label-only character: %+v, %v; want %q", move, err, want)
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ func (session *ocrSession) refresh_locked(automatic bool) {
|
|||||||
// interruption are observed without waiting on the speech worker.
|
// interruption are observed without waiting on the speech worker.
|
||||||
if automatic && session.readAllContext != nil && session.readAllContext.Err() == nil {
|
if automatic && session.readAllContext != nil && session.readAllContext.Err() == nil {
|
||||||
select {
|
select {
|
||||||
case <-session.readAllDone:
|
case _ = <-session.readAllDone:
|
||||||
default:
|
default:
|
||||||
session.schedule_refresh_locked()
|
session.schedule_refresh_locked()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -85,10 +85,14 @@ func (worker *preferencesWorker) window(ctx context.Context) (result error) {
|
|||||||
result = fmt.Errorf("preferences helper exited: %w", waitErr)
|
result = fmt.Errorf("preferences helper exited: %w", waitErr)
|
||||||
}
|
}
|
||||||
if result != nil {
|
if result != nil {
|
||||||
|
helperExit := "<nil>"
|
||||||
|
if waitErr != nil {
|
||||||
|
helperExit = waitErr.Error()
|
||||||
|
}
|
||||||
if detail := diagnostic.String(); detail != "" {
|
if detail := diagnostic.String(); detail != "" {
|
||||||
result = fmt.Errorf("%w (helper exit: %v; stderr: %s)", result, waitErr, detail)
|
result = fmt.Errorf("%w (helper exit: %s; stderr: %s)", result, helperExit, detail)
|
||||||
} else {
|
} else {
|
||||||
result = fmt.Errorf("%w (helper exit: %v)", result, waitErr)
|
result = fmt.Errorf("%w (helper exit: %s)", result, helperExit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ func run_remote_speech_stream(ctx context.Context, incoming <-chan tentacle.Remo
|
|||||||
defer func() {
|
defer func() {
|
||||||
interrupt()
|
interrupt()
|
||||||
if active != nil {
|
if active != nil {
|
||||||
<-finished // Renderer owns cleanup; no replacement can overtake it.
|
_ = <-finished // Renderer owns cleanup; no replacement can overtake it.
|
||||||
release(active)
|
release(active)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
@@ -222,7 +223,7 @@ func (w *speechHistoryWindows) window(ctx context.Context, mode string, updates
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
case err := <-readDone:
|
case err := <-readDone:
|
||||||
if err == nil || err == io.EOF {
|
if err == nil || errors.Is(err, io.EOF) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ func readClipboardTarget(ctx context.Context, target string) (string, error) {
|
|||||||
}
|
}
|
||||||
data, readErr := io.ReadAll(io.LimitReader(pipe, 8193))
|
data, readErr := io.ReadAll(io.LimitReader(pipe, 8193))
|
||||||
if readErr != nil || len(data) > 8192 {
|
if readErr != nil || len(data) > 8192 {
|
||||||
command.Process.Kill()
|
_ = command.Process.Kill()
|
||||||
command.Wait()
|
_ = command.Wait()
|
||||||
return "", errors.New("clipboard too large")
|
return "", errors.New("clipboard too large")
|
||||||
}
|
}
|
||||||
err = command.Wait()
|
err = command.Wait()
|
||||||
@@ -94,7 +94,7 @@ func clipboardPNG(ctx context.Context) (tentaclewire.Item, error) {
|
|||||||
keep := false
|
keep := false
|
||||||
defer func() {
|
defer func() {
|
||||||
if !keep {
|
if !keep {
|
||||||
os.RemoveAll(directory)
|
_ = os.RemoveAll(directory)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
path := filepath.Join(directory, "clipboard.png")
|
path := filepath.Join(directory, "clipboard.png")
|
||||||
@@ -114,8 +114,8 @@ func clipboardPNG(ctx context.Context) (tentaclewire.Item, error) {
|
|||||||
}
|
}
|
||||||
count, copyErr := io.Copy(file, io.LimitReader(pipe, 32*1024*1024+1))
|
count, copyErr := io.Copy(file, io.LimitReader(pipe, 32*1024*1024+1))
|
||||||
if copyErr != nil || count > 32*1024*1024 {
|
if copyErr != nil || count > 32*1024*1024 {
|
||||||
command.Process.Kill()
|
_ = command.Process.Kill()
|
||||||
command.Wait()
|
_ = command.Wait()
|
||||||
return tentaclewire.Item{}, errors.New("clipboard image too large")
|
return tentaclewire.Item{}, errors.New("clipboard image too large")
|
||||||
}
|
}
|
||||||
if err = command.Wait(); err != nil {
|
if err = command.Wait(); err != nil {
|
||||||
|
|||||||
@@ -56,13 +56,13 @@ func (runtime *tentacleRuntime) interact(ctx context.Context, command tentacleCo
|
|||||||
if len(command.session.RemoteGrants()) != 0 && cleanupNext != "" && command.session.OutputContext().Err() == nil {
|
if len(command.session.RemoteGrants()) != 0 && cleanupNext != "" && command.session.OutputContext().Err() == nil {
|
||||||
cleanupCtx, stopCleanup := context.WithTimeout(context.Background(), 2*time.Second)
|
cleanupCtx, stopCleanup := context.WithTimeout(context.Background(), 2*time.Second)
|
||||||
defer stopCleanup()
|
defer stopCleanup()
|
||||||
runtime.callInteraction(cleanupCtx, command, cleanupNext, tentaclewire.Submission{Cancelled: true})
|
_, _ = runtime.callInteraction(cleanupCtx, command, cleanupNext, tentaclewire.Submission{Cancelled: true})
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
var temporaryFiles []string
|
var temporaryFiles []string
|
||||||
defer func() {
|
defer func() {
|
||||||
for _, path := range temporaryFiles {
|
for _, path := range temporaryFiles {
|
||||||
os.RemoveAll(filepath.Dir(path))
|
_ = os.RemoveAll(filepath.Dir(path))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
for transitions := 0; transitions < 1024 && ctx.Err() == nil; transitions++ {
|
for transitions := 0; transitions < 1024 && ctx.Err() == nil; transitions++ {
|
||||||
@@ -147,7 +147,7 @@ func (runtime *tentacleRuntime) interact(ctx context.Context, command tentacleCo
|
|||||||
var submission tentaclewire.Submission
|
var submission tentaclewire.Submission
|
||||||
if value.Form != nil {
|
if value.Form != nil {
|
||||||
if runtime.forms == nil {
|
if runtime.forms == nil {
|
||||||
runtime.callInteraction(ctx, command, value.Next, tentaclewire.Submission{Cancelled: true})
|
_, _ = runtime.callInteraction(ctx, command, value.Next, tentaclewire.Submission{Cancelled: true})
|
||||||
cleanupNext = ""
|
cleanupNext = ""
|
||||||
runtime.report("Internal UI unavailable.")
|
runtime.report("Internal UI unavailable.")
|
||||||
return
|
return
|
||||||
@@ -156,7 +156,7 @@ func (runtime *tentacleRuntime) interact(ctx context.Context, command tentacleCo
|
|||||||
replies, openErr := runtime.open_tentacle_form(formCtx, command, *value.Form)
|
replies, openErr := runtime.open_tentacle_form(formCtx, command, *value.Form)
|
||||||
if openErr != nil {
|
if openErr != nil {
|
||||||
closeForm()
|
closeForm()
|
||||||
runtime.callInteraction(ctx, command, value.Next, tentaclewire.Submission{Cancelled: true})
|
_, _ = runtime.callInteraction(ctx, command, value.Next, tentaclewire.Submission{Cancelled: true})
|
||||||
cleanupNext = ""
|
cleanupNext = ""
|
||||||
runtime.report("Internal UI unavailable.")
|
runtime.report("Internal UI unavailable.")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ func (runtime *tentacleRuntime) Manage(ctx context.Context, request tentacle.Man
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer prepared.Discard()
|
defer func() { _ = prepared.Discard() }()
|
||||||
operation := "add"
|
operation := "add"
|
||||||
if request.Action == "upgrade" {
|
if request.Action == "upgrade" {
|
||||||
operation = "update"
|
operation = "update"
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ func TestWineReviewEmptyFocusCanReachOutput(t *testing.T) {
|
|||||||
if err = cursor.Refresh(context.Background(), tree, w.Focus()); err != nil {
|
if err = cursor.Refresh(context.Background(), tree, w.Focus()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
_, _, err = cursor.Read(review.Line, 0)
|
_, _, _ = cursor.Read(review.Line, 0)
|
||||||
position, _, err := cursor.Read(review.Line, 1)
|
position, _, err := cursor.Read(review.Line, 1)
|
||||||
if err != nil || position.Text != "alpha beta!" {
|
if err != nil || position.Text != "alpha beta!" {
|
||||||
t.Fatalf("empty anchor: %+v %v", position, err)
|
t.Fatalf("empty anchor: %+v %v", position, err)
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ func TestCaptureDesktopRejectsUnavailableAdapterAndCanceledContext(t *testing.T)
|
|||||||
if _, err := adapter.CaptureDesktop(canceled); !errors.Is(err, context.Canceled) {
|
if _, err := adapter.CaptureDesktop(canceled); !errors.Is(err, context.Canceled) {
|
||||||
t.Fatalf("canceled capture error = %v", err)
|
t.Fatalf("canceled capture error = %v", err)
|
||||||
}
|
}
|
||||||
if _, err := adapter.CaptureDesktop(nil); err == nil {
|
if _, err := adapter.CaptureDesktop(nil); err == nil { //nolint:staticcheck // SA1012: verifies nil contexts are rejected
|
||||||
t.Fatal("capture accepted a nil context")
|
t.Fatal("capture accepted a nil context")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,10 +71,6 @@ func (document DocumentSnapshot) SubtreeEnd(index int) int {
|
|||||||
return end
|
return end
|
||||||
}
|
}
|
||||||
|
|
||||||
func document_entry_error(entry treeEntry) error {
|
|
||||||
return document_entry_error_tolerating(entry, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
// document_entry_error_tolerating optionally ignores text, geometry, and
|
// document_entry_error_tolerating optionally ignores text, geometry, and
|
||||||
// child-order staleness. Caret movement reads text and line bounds live
|
// child-order staleness. Caret movement reads text and line bounds live
|
||||||
// from the provider and generation-checks every endpoint, so captured
|
// from the provider and generation-checks every endpoint, so captured
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ type viewport struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *viewport) replace(text string) {
|
func (v *viewport) replace(text string) {
|
||||||
v.setFrame(Frame{Text: text, Cursor: -1})
|
_ = v.setFrame(Frame{Text: text, Cursor: -1})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *viewport) setFrame(frame Frame) error {
|
func (v *viewport) setFrame(frame Frame) error {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func WriteGreeterSettings(path string, settings Settings) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("create greeter settings copy: %w", err)
|
return fmt.Errorf("create greeter settings copy: %w", err)
|
||||||
}
|
}
|
||||||
defer os.Remove(temporary.Name())
|
defer func() { _ = os.Remove(temporary.Name()) }()
|
||||||
if _, err := temporary.Write(contents); err != nil {
|
if _, err := temporary.Write(contents); err != nil {
|
||||||
temporary.Close()
|
temporary.Close()
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ func (c *connection) request(kind uint32, body []byte, result any) error {
|
|||||||
if err := c.SetDeadline(time.Now().Add(queryTimeout)); err != nil {
|
if err := c.SetDeadline(time.Now().Add(queryTimeout)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer c.SetDeadline(time.Time{})
|
defer func() { _ = c.SetDeadline(time.Time{}) }()
|
||||||
if err := writeMessage(c, kind, body); err != nil {
|
if err := writeMessage(c, kind, body); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ func session(ctx context.Context, path string, emit func(Event)) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
m, err = readMessage(io.MultiReader(bytes.NewReader(first[:]), c))
|
m, err = readMessage(io.MultiReader(bytes.NewReader(first[:]), c))
|
||||||
c.SetReadDeadline(time.Time{})
|
_ = c.SetReadDeadline(time.Time{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,10 +74,11 @@ func liveSocketTest(t *testing.T) {
|
|||||||
httpTest := httptest.NewServer(http.HandlerFunc(server.handleHTTP))
|
httpTest := httptest.NewServer(http.HandlerFunc(server.handleHTTP))
|
||||||
defer httpTest.Close()
|
defer httpTest.Close()
|
||||||
url := "ws" + strings.TrimPrefix(httpTest.URL, "http")
|
url := "ws" + strings.TrimPrefix(httpTest.URL, "http")
|
||||||
connection, _, err := websocket.DefaultDialer.Dial(url, nil)
|
connection, response, err := websocket.DefaultDialer.Dial(url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("dial WebSocket: %v", err)
|
t.Fatalf("dial WebSocket: %v", err)
|
||||||
}
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
defer connection.Close()
|
defer connection.Close()
|
||||||
|
|
||||||
if err := connection.WriteMessage(websocket.TextMessage, []byte("Accessibility mod loaded.")); err != nil {
|
if err := connection.WriteMessage(websocket.TextMessage, []byte("Accessibility mod loaded.")); err != nil {
|
||||||
@@ -129,10 +130,11 @@ func TestStartStopClosesActiveConnection(t *testing.T) {
|
|||||||
if err := server.Start(context.Background()); err != nil {
|
if err := server.Start(context.Background()); err != nil {
|
||||||
t.Fatalf("start server: %v", err)
|
t.Fatalf("start server: %v", err)
|
||||||
}
|
}
|
||||||
connection, _, err := websocket.DefaultDialer.Dial(fmt.Sprintf("ws://127.0.0.1:%d", port), nil)
|
connection, response, err := websocket.DefaultDialer.Dial(fmt.Sprintf("ws://127.0.0.1:%d", port), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("dial server: %v", err)
|
t.Fatalf("dial server: %v", err)
|
||||||
}
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
defer connection.Close()
|
defer connection.Close()
|
||||||
if err := server.Stop(context.Background()); err != nil {
|
if err := server.Stop(context.Background()); err != nil {
|
||||||
t.Fatalf("stop server: %v", err)
|
t.Fatalf("stop server: %v", err)
|
||||||
|
|||||||
@@ -315,11 +315,8 @@ func (listener *Listener) stop(
|
|||||||
}
|
}
|
||||||
C.XSync(controlDisplay, 0)
|
C.XSync(controlDisplay, 0)
|
||||||
|
|
||||||
select {
|
if status := <-enableDone; status == 0 {
|
||||||
case status := <-enableDone:
|
stopError = errors.Join(stopError, errors.New("X11 listener stop: record loop exited with failure"))
|
||||||
if status == 0 {
|
|
||||||
stopError = errors.Join(stopError, errors.New("X11 listener stop: record loop exited with failure"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if C.XRecordFreeContext(controlDisplay, recordContext) == 0 {
|
if C.XRecordFreeContext(controlDisplay, recordContext) == 0 {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func TestNativeRemoteCaptureForwardsBypassesAndEscapes(t *testing.T) {
|
|||||||
t.Fatalf("xdotool %v: %v %s", args, err, data)
|
t.Fatalf("xdotool %v: %v %s", args, err, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session, events, err := listener.BeginRemoteCapture(ctx, "tentacle/remote-1/")
|
_, events, err := listener.BeginRemoteCapture(ctx, "tentacle/remote-1/")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ func TestNativeRemoteCaptureForwardsBypassesAndEscapes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
time.Sleep(time.Millisecond)
|
time.Sleep(time.Millisecond)
|
||||||
}
|
}
|
||||||
session, events, err = listener.BeginRemoteCapture(ctx, "tentacle/remote-1/")
|
session, events, err := listener.BeginRemoteCapture(ctx, "tentacle/remote-1/")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,6 @@ import (
|
|||||||
"github.com/godbus/dbus/v5/introspect"
|
"github.com/godbus/dbus/v5/introspect"
|
||||||
)
|
)
|
||||||
|
|
||||||
func introspectionMethods() []introspect.Method {
|
|
||||||
return serviceMethods(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func serviceMethods(orca bool) []introspect.Method {
|
func serviceMethods(orca bool) []introspect.Method {
|
||||||
methods := []introspect.Method{
|
methods := []introspect.Method{
|
||||||
{Name: "ShowPreferences", Args: []introspect.Arg{{Name: "accepted", Type: "b", Direction: "out"}}},
|
{Name: "ShowPreferences", Args: []introspect.Arg{{Name: "accepted", Type: "b", Direction: "out"}}},
|
||||||
|
|||||||
@@ -75,15 +75,6 @@ func modulePath(base dbus.ObjectPath, name string) dbus.ObjectPath {
|
|||||||
return dbus.ObjectPath(string(base) + "/" + name)
|
return dbus.ObjectPath(string(base) + "/" + name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func moduleFor(name string) *moduleSpec {
|
|
||||||
for i := range modules {
|
|
||||||
if modules[i].name == name {
|
|
||||||
return &modules[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (spec moduleSpec) property(name string) (propertySpec, bool) {
|
func (spec moduleSpec) property(name string) (propertySpec, bool) {
|
||||||
for _, item := range spec.properties {
|
for _, item := range spec.properties {
|
||||||
if item.name == name {
|
if item.name == name {
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ func (service *Service) Start(ctx context.Context) error {
|
|||||||
if !started {
|
if !started {
|
||||||
for index := exported - 1; index >= 0; index-- {
|
for index := exported - 1; index >= 0; index-- {
|
||||||
binding := registrations[index]
|
binding := registrations[index]
|
||||||
connection.Export(nil, binding.path, binding.iface)
|
_ = connection.Export(nil, binding.path, binding.iface)
|
||||||
}
|
}
|
||||||
connection.Close()
|
connection.Close()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ func run(ctx context.Context, epoch uint64, control, lifetime io.ReadCloser, out
|
|||||||
operation, err = DecodeOperation(frame)
|
operation, err = DecodeOperation(frame)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if errors.Is(err, io.EOF) {
|
||||||
cancelOwner(errEOF)
|
cancelOwner(errEOF)
|
||||||
} else {
|
} else {
|
||||||
cancelOwner(ErrProtocol)
|
cancelOwner(ErrProtocol)
|
||||||
@@ -140,12 +140,12 @@ func run(ctx context.Context, epoch uint64, control, lifetime io.ReadCloser, out
|
|||||||
reason := ReasonEOF
|
reason := ReasonEOF
|
||||||
ownerStopped := func() {
|
ownerStopped := func() {
|
||||||
cause = context.Cause(ownerContext)
|
cause = context.Cause(ownerContext)
|
||||||
switch cause {
|
switch {
|
||||||
case errEOF:
|
case errors.Is(cause, errEOF):
|
||||||
cause, reason = nil, ReasonEOF
|
cause, reason = nil, ReasonEOF
|
||||||
case ErrProtocol:
|
case errors.Is(cause, ErrProtocol):
|
||||||
reason = ReasonProtocol
|
reason = ReasonProtocol
|
||||||
case ErrOutput:
|
case errors.Is(cause, ErrOutput):
|
||||||
reason = ReasonOutput
|
reason = ReasonOutput
|
||||||
default:
|
default:
|
||||||
cause = ctx.Err()
|
cause = ctx.Err()
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ func (supervisor *Supervisor) serve(ctx context.Context, epoch uint64, client *C
|
|||||||
case result := <-acks:
|
case result := <-acks:
|
||||||
if result.err != nil {
|
if result.err != nil {
|
||||||
streamEnded = true
|
streamEnded = true
|
||||||
if result.err != io.EOF {
|
if !errors.Is(result.err, io.EOF) {
|
||||||
protocolFailed = true
|
protocolFailed = true
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@@ -276,7 +276,7 @@ func (supervisor *Supervisor) serve(ctx context.Context, epoch uint64, client *C
|
|||||||
case result := <-acks:
|
case result := <-acks:
|
||||||
if result.err != nil {
|
if result.err != nil {
|
||||||
streamEnded = true
|
streamEnded = true
|
||||||
if result.err != io.EOF {
|
if !errors.Is(result.err, io.EOF) {
|
||||||
protocolFailed = true
|
protocolFailed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,7 +194,8 @@ func next_available_table_cell(cells []atspi.DocumentNode, current atspi.Documen
|
|||||||
}
|
}
|
||||||
s := node.Snapshot
|
s := node.Snapshot
|
||||||
rowEnd, colEnd := s.TableRowIndex+max(1, s.TableRowSpan)-1, s.TableColumnIndex+max(1, s.TableColumnSpan)-1
|
rowEnd, colEnd := s.TableRowIndex+max(1, s.TableRowSpan)-1, s.TableColumnIndex+max(1, s.TableColumnSpan)-1
|
||||||
candidateRow, candidateCol := row, col
|
candidateCol := col
|
||||||
|
var candidateRow int
|
||||||
if dr != 0 {
|
if dr != 0 {
|
||||||
if col < s.TableColumnIndex || col > colEnd {
|
if col < s.TableColumnIndex || col > colEnd {
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -555,11 +555,6 @@ func TestStopTimeoutPreservesShutdownCueForRetry(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type stopCountingPlayer struct {
|
|
||||||
stopData []byte
|
|
||||||
stopCalls int
|
|
||||||
}
|
|
||||||
|
|
||||||
type queueBlockingPlayer struct {
|
type queueBlockingPlayer struct {
|
||||||
stopData []byte
|
stopData []byte
|
||||||
entered chan struct{}
|
entered chan struct{}
|
||||||
@@ -577,13 +572,6 @@ func (player *queueBlockingPlayer) Play(ctx context.Context, data []byte, _, _ f
|
|||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (player *stopCountingPlayer) Play(_ context.Context, data []byte, _, _ float64) error {
|
|
||||||
if bytes.Equal(data, player.stopData) {
|
|
||||||
player.stopCalls++
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type stagedStopPlayer struct {
|
type stagedStopPlayer struct {
|
||||||
stopData []byte
|
stopData []byte
|
||||||
entered chan struct{}
|
entered chan struct{}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func connectWithAutospawn(ctx context.Context, endpoint serverAddress, dial serv
|
|||||||
return conn, err
|
return conn, err
|
||||||
}
|
}
|
||||||
if spawnErr := spawn(ctx, endpoint); spawnErr != nil {
|
if spawnErr := spawn(ctx, endpoint); spawnErr != nil {
|
||||||
return nil, fmt.Errorf("%w; autostart Speech Dispatcher: %v", err, spawnErr)
|
return nil, fmt.Errorf("%w; autostart Speech Dispatcher: %w", err, spawnErr)
|
||||||
}
|
}
|
||||||
retryContext, cancel := context.WithTimeout(ctx, connectTimeout)
|
retryContext, cancel := context.WithTimeout(ctx, connectTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ func prepare_package(ctx context.Context, root string, repository Repository, lo
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer os.Remove(archive.Name())
|
defer func() { _ = os.Remove(archive.Name()) }()
|
||||||
defer archive.Close()
|
defer archive.Close()
|
||||||
digest := sha256.New()
|
digest := sha256.New()
|
||||||
count, err := io.Copy(io.MultiWriter(archive, digest), io.LimitReader(response.Body, maxPackageBytes+1))
|
count, err := io.Copy(io.MultiWriter(archive, digest), io.LimitReader(response.Body, maxPackageBytes+1))
|
||||||
@@ -316,7 +316,7 @@ func extract_package(ctx context.Context, archive io.Reader, directory string) e
|
|||||||
if err := os.MkdirAll(target, 0700); err != nil {
|
if err := os.MkdirAll(target, 0700); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case tar.TypeReg, tar.TypeRegA:
|
case tar.TypeReg, 0: // 0 is tar.TypeRegA, the pre-POSIX regular-file marker
|
||||||
if err := os.MkdirAll(filepath.Dir(target), 0700); err != nil {
|
if err := os.MkdirAll(filepath.Dir(target), 0700); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ func (store *PageStore) Save(values PageValues) error {
|
|||||||
if err := syscall.Flock(int(lock.Fd()), syscall.LOCK_EX|syscall.LOCK_NB); err != nil {
|
if err := syscall.Flock(int(lock.Fd()), syscall.LOCK_EX|syscall.LOCK_NB); err != nil {
|
||||||
return errors.New("tentacle preferences are being edited")
|
return errors.New("tentacle preferences are being edited")
|
||||||
}
|
}
|
||||||
defer syscall.Flock(int(lock.Fd()), syscall.LOCK_UN)
|
defer func() { _ = syscall.Flock(int(lock.Fd()), syscall.LOCK_UN) }()
|
||||||
current, err := read_registry(store.Path)
|
current, err := read_registry(store.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -81,7 +81,7 @@ func (store *PageStore) Save(values PageValues) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer os.Remove(file.Name())
|
defer func() { _ = os.Remove(file.Name()) }()
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
if _, err := file.Write(data); err != nil {
|
if _, err := file.Write(data); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -329,7 +329,7 @@ func (session *Session) read_replies(reader io.Reader) {
|
|||||||
for session.ctx.Err() == nil {
|
for session.ctx.Err() == nil {
|
||||||
frame, err := read_frame(buffer)
|
frame, err := read_frame(buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if errors.Is(err, io.EOF) {
|
||||||
err = ErrExited
|
err = ErrExited
|
||||||
}
|
}
|
||||||
session.fail(err)
|
session.fail(err)
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ func (registry *Registry) SaveState(entries []Entry, repositories []Repository)
|
|||||||
if err := syscall.Flock(int(lock.Fd()), syscall.LOCK_EX|syscall.LOCK_NB); err != nil {
|
if err := syscall.Flock(int(lock.Fd()), syscall.LOCK_EX|syscall.LOCK_NB); err != nil {
|
||||||
return errors.New("tentacle registry is being edited")
|
return errors.New("tentacle registry is being edited")
|
||||||
}
|
}
|
||||||
defer syscall.Flock(int(lock.Fd()), syscall.LOCK_UN)
|
defer func() { _ = syscall.Flock(int(lock.Fd()), syscall.LOCK_UN) }()
|
||||||
current, err := read_registry(registry.Path)
|
current, err := read_registry(registry.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -221,7 +221,7 @@ func (registry *Registry) SaveState(entries []Entry, repositories []Repository)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer os.Remove(temporary.Name())
|
defer func() { _ = os.Remove(temporary.Name()) }()
|
||||||
defer temporary.Close()
|
defer temporary.Close()
|
||||||
if _, err := temporary.Write(data); err != nil {
|
if _, err := temporary.Write(data); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ func FetchRepository(ctx context.Context, origin string) (Repository, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return Repository{}, err
|
return Repository{}, err
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(directory)
|
defer func() { _ = os.RemoveAll(directory) }()
|
||||||
if _, err := repository_git(ctx, directory, "init", "--bare", "--template="); err != nil {
|
if _, err := repository_git(ctx, directory, "init", "--bare", "--template="); err != nil {
|
||||||
return Repository{}, err
|
return Repository{}, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ func TestBlockedPipeCannotBlockSubmissionOrDisable(t *testing.T) {
|
|||||||
|
|
||||||
func TestLaunchValidationAndMissingExecutable(t *testing.T) {
|
func TestLaunchValidationAndMissingExecutable(t *testing.T) {
|
||||||
manager := test_manager(t, DefaultLimits(), nil)
|
manager := test_manager(t, DefaultLimits(), nil)
|
||||||
if _, err := manager.Start(nil, child_spec(t, "sample", "echo")); err == nil {
|
if _, err := manager.Start(nil, child_spec(t, "sample", "echo")); err == nil { //nolint:staticcheck // SA1012: verifies nil contexts are rejected
|
||||||
t.Fatal("nil context accepted")
|
t.Fatal("nil context accepted")
|
||||||
}
|
}
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ func (set *helperSet) publish(root string) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(temporary)
|
defer func() { _ = os.RemoveAll(temporary) }()
|
||||||
for _, file := range set.files {
|
for _, file := range set.files {
|
||||||
if err := os.WriteFile(filepath.Join(temporary, file.name), file.data, file.mode); err != nil {
|
if err := os.WriteFile(filepath.Join(temporary, file.name), file.data, file.mode); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ func (r *ReviewRegistry) Stop(ctx context.Context) error {
|
|||||||
r.mutex.Unlock()
|
r.mutex.Unlock()
|
||||||
if conn != nil {
|
if conn != nil {
|
||||||
conn.RemoveSignal(signals)
|
conn.RemoveSignal(signals)
|
||||||
conn.RemoveMatchSignal(dbus.WithMatchSender("org.freedesktop.DBus"), dbus.WithMatchInterface("org.freedesktop.DBus"), dbus.WithMatchMember("NameOwnerChanged"))
|
_ = conn.RemoveMatchSignal(dbus.WithMatchSender("org.freedesktop.DBus"), dbus.WithMatchInterface("org.freedesktop.DBus"), dbus.WithMatchMember("NameOwnerChanged"))
|
||||||
conn.Close()
|
conn.Close()
|
||||||
}
|
}
|
||||||
if done != nil {
|
if done != nil {
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ func ApplyReviewSnapshot(tree *atspi.AccessibleTree, snapshot ReviewSnapshot, se
|
|||||||
err = tree.Replace(root, nodes)
|
err = tree.Replace(root, nodes)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, atspi.ObjectID{}, fmt.Errorf("%w: %v", ErrReviewInvalid, err)
|
return nil, atspi.ObjectID{}, fmt.Errorf("%w: %w", ErrReviewInvalid, err)
|
||||||
}
|
}
|
||||||
return tree, ReviewID(sender, snapshot.Instance, snapshot.Window, snapshot.Focus), nil
|
return tree, ReviewID(sender, snapshot.Instance, snapshot.Window, snapshot.Focus), nil
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user