github-vet / github-vet/rangeloop-pointer-findings

mendersoftware/mender: statescript/executor.go; 32 LoC

Open
#14,836 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [mendersoftware/mender](https://www.github.com/mendersoftware/mender) at [statescript/executor.go](https://github.com/mendersoftware/mender/blob/0632a83ecc06e76971a73f8cced05172c022d159/statescript/executor.go#L333-L364)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.

> range-loop variable s used in defer or goroutine at line 355

[Click here to see the code in its original context.](https://github.com/mendersoftware/mender/blob/0632a83ecc06e76971a73f8cced05172c022d159/statescript/executor.go#L333-L364)

Click here to show the 32 line(s) of Go which triggered the analyzer.

```go
for _, s := range scr {
// check if script is executable
if s.Mode()&execBits == 0 {
if ignoreError {
log.Errorf("statescript: Ignoring script '%s' being not executable",
filepath.Join(dir, s.Name()))
continue
} else {
return errors.Errorf("statescript: script '%s' is not executable",
filepath.Join(dir, s.Name()))
}
}

subStatus := fmt.Sprintf("Executing script: %s", s.Name())
log.Debugf(subStatus)
if report != nil {
if err = reportScriptStatus(report, subStatus); err != nil {
log.Errorf("statescript: Can not send start status to server: %s", err.Error())
}

defer func() {
if err = reportScriptStatus(report,
fmt.Sprintf("finished executing script: %s", s.Name())); err != nil {
log.Errorf("statescript: Can not send finished status to server: %s", err.Error())
}
}()
}

if err = executeScript(s, dir, l, timeout, ignoreError); err != nil {
return err
}
}

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: 0632a83ecc06e76971a73f8cced05172c022d159

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.