github-vet / github-vet/rangeloop-pointer-findings
mindreframer/golang-devops-stuff: src/github.com/influxdb/influxdb/datastore/shard.go; 39 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [mindreframer/golang-devops-stuff](https://www.github.com/mindreframer/golang-devops-stuff) at [src/github.com/influxdb/influxdb/datastore/shard.go](https://github.com/mindreframer/golang-devops-stuff/blob/bb6c6c16ff0ae7892cd0ed0715b8a6b769052f9f/src/github.com/influxdb/influxdb/datastore/shard.go#L52-L90)
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/mindreframer/golang-devops-stuff/blob/bb6c6c16ff0ae7892cd0ed0715b8a6b769052f9f/src/github.com/influxdb/influxdb/datastore/shard.go#L52-L90)
Click here to show the 39 line(s) of Go which triggered the analyzer.
```go
for fieldIndex, id := range s.FieldIds {
for _, point := range s.Points {
// keyBuffer and dataBuffer have to be recreated since we are
// batching the writes, otherwise new writes will override the
// old writes that are still in memory
keyBuffer := bytes.NewBuffer(make([]byte, 0, 24))
dataBuffer := proto.NewBuffer(nil)
var err error
binary.Write(keyBuffer, binary.BigEndian, &id)
timestamp := self.convertTimestampToUint(point.GetTimestampInMicroseconds())
// pass the uint64 by reference so binary.Write() doesn't create a new buffer
// see the source code for intDataSize() in binary.go
binary.Write(keyBuffer, binary.BigEndian, ×tamp)
binary.Write(keyBuffer, binary.BigEndian, point.SequenceNumber)
pointKey := keyBuffer.Bytes()
if point.Values[fieldIndex].GetIsNull() {
wb = append(wb, storage.Write{Key: pointKey, Value: nil})
goto check
}
err = dataBuffer.Marshal(point.Values[fieldIndex])
if err != nil {
return err
}
wb = append(wb, storage.Write{Key: pointKey, Value: dataBuffer.Bytes()})
check:
count++
if count >= self.writeBatchSize {
err = self.db.BatchPut(wb)
if err != nil {
return err
}
count = 0
wb = make([]storage.Write, 0, self.writeBatchSize)
}
}
}
```
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 {Write 3} 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: bb6c6c16ff0ae7892cd0ed0715b8a6b769052f9f
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.