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

att/tegu: managers/res_mgr.go; 40 LoC

Open
#14,479 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 [att/tegu](https://www.github.com/att/tegu) at [managers/res_mgr.go](https://github.com/att/tegu/blob/b7e53b04897cf652dbe52c4156b0fe2becefa4f6/managers/res_mgr.go#L348-L387)

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.

> function call at line 363 may store a reference to rname

[Click here to see the code in its original context.](https://github.com/att/tegu/blob/b7e53b04897cf652dbe52c4156b0fe2becefa4f6/managers/res_mgr.go#L348-L387)

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

```go
for rname, p := range i.cache { // run all pledges that are in the cache
if p != nil {
if (*p).Is_expired() { // some reservations need to be explicitly undone at expiry
if (*p).Is_pushed() { // no need if not pushed
switch (*p).(type) {
case *gizmos.Pledge_mirror: // mirror requests need to be undone when they become inactive
undo_mirror_reservation( p, rname, ch )
}

(*p).Reset_pushed()
}
} else {
if ! (*p).Is_pushed() && ((*p).Is_active() || (*p).Is_active_soon( 15 )) { // not pushed, and became active while we napped, or will activate in the next 15 seconds
switch (*p).(type) {
case *gizmos.Pledge_bwow:
bwow_push_res( p, &rname, ch, hto_limit, pref_v6 )
(*p).Set_pushed( )

case *gizmos.Pledge_bw:
bw_push_count++
bw_push_res( p, &rname, ch, hto_limit, alt_table, pref_v6 )

case *gizmos.Pledge_steer:
st_push_count++
push_st_reservation( p, rname, ch, hto_limit )

case *gizmos.Pledge_mirror:
push_mirror_reservation( p, rname, ch )

case *gizmos.Pledge_pass:
pass_push_res( p, &rname, ch, hto_limit )
}

pushed_count++
} else { // stil pending
pend_count++
}
}
}
}

```

Click here to show extra information the analyzer produced.

```
The following graphviz dot graph describes paths through the callgraph that could lead to a function which writes a pointer argument:
digraph G {
"(bwow_push_res, 5)" -> {}
}

No path was found through the callgraph that could lead to a function which passes a pointer 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: b7e53b04897cf652dbe52c4156b0fe2becefa4f6

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.