github-vet / github-vet/rangeloop-pointer-findings
jeffwilliams/wwwmp3: scan/db.go; 52 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [jeffwilliams/wwwmp3](https://www.github.com/jeffwilliams/wwwmp3) at [scan/db.go](https://github.com/jeffwilliams/wwwmp3/blob/5668e1bd4d523d7dfa3f423c89738185144d802b/scan/db.go#L106-L157)
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.
>
[Click here to see the code in its original context.](https://github.com/jeffwilliams/wwwmp3/blob/5668e1bd4d523d7dfa3f423c89738185144d802b/scan/db.go#L106-L157)
Click here to show the 52 line(s) of Go which triggered the analyzer.
```go
for m := range c {
var cnt int
err := db.stmtPathExists.QueryRow(m.Path).Scan(&cnt)
if err != nil {
doCallback(&m, fmt.Errorf("ScanMp3sToDb: querying for existence failed: %v", err))
errCnt++
continue
}
tx, err := db.DB.Begin()
// Don't call the callback since we are not returning, and we want the callback called
// once per metadata.
if err != nil {
//doCallback(&m, fmt.Errorf("ScanMp3sToDb: creating transaction failed: %v", err))
errCnt++
continue
}
var stmt *sql.Stmt
if cnt == 0 {
// No rows with that path.
stmt = tx.Stmt(db.stmtAddMp3)
} else {
// Row exists.
stmt = tx.Stmt(db.stmtUpdateMp3)
}
if pathTransform != nil {
m.Path = pathTransform(m.Path)
}
_, err = stmt.Exec(m.Artist, m.Album, m.Title, m.Tracknum, m.Path)
if err != nil {
doCallback(&m, fmt.Errorf("ScanMp3sToDb: inserting or updating failed: %v\n", err))
errCnt++
continue
}
err = tx.Commit()
// Don't call the callback since we are not returning, and we want the callback called
// once per metadata.
if err != nil {
// doCallback(&m, fmt.Errorf("ScanMp3sToDb: commit failed: %v", err))
errCnt++
}
succCnt++
if callback != nil {
doCallback(&m, nil)
}
}
```
Click here to show extra information the analyzer produced.
```
No path was found through the callgraph that could lead to a function which writes a pointer argument.
No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.
root signature {doCallback 2} was not found in the callgraph; reference was passed directly to third-party code
```
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: 5668e1bd4d523d7dfa3f423c89738185144d802b
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.