1
0
mirror of https://github.com/golang/go synced 2024-11-23 17:50:06 -07:00

runtime: remove redundant explicit deref in trace.go

Replaces legacy Go syntax for pointer struct member access
with more modern auto-deref alternative.

Found using https://go-critic.github.io/overview#underef-ref

Change-Id: I71a3c424126c4ff5d89f9e4bacb6cc01c6fa2ddf
Reviewed-on: https://go-review.googlesource.com/122895
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Iskander Sharipov 2018-07-10 08:32:56 +03:00 committed by Brad Fitzpatrick
parent fa6639d626
commit fd7d3259c9

View File

@ -532,12 +532,12 @@ func traceEvent(ev byte, skip int, args ...uint64) {
}
func traceEventLocked(extraBytes int, mp *m, pid int32, bufp *traceBufPtr, ev byte, skip int, args ...uint64) {
buf := (*bufp).ptr()
buf := bufp.ptr()
// TODO: test on non-zero extraBytes param.
maxSize := 2 + 5*traceBytesPerNumber + extraBytes // event type, length, sequence, timestamp, stack id and two add params
if buf == nil || len(buf.arr)-buf.pos < maxSize {
buf = traceFlush(traceBufPtrOf(buf), pid).ptr()
(*bufp).set(buf)
bufp.set(buf)
}
ticks := uint64(cputicks()) / traceTickDiv
@ -689,11 +689,11 @@ func traceString(bufp *traceBufPtr, pid int32, s string) (uint64, *traceBufPtr)
// so there must be no memory allocation or any activities
// that causes tracing after this point.
buf := (*bufp).ptr()
buf := bufp.ptr()
size := 1 + 2*traceBytesPerNumber + len(s)
if buf == nil || len(buf.arr)-buf.pos < size {
buf = traceFlush(traceBufPtrOf(buf), pid).ptr()
(*bufp).set(buf)
bufp.set(buf)
}
buf.byte(traceEvString)
buf.varint(id)
@ -708,7 +708,7 @@ func traceString(bufp *traceBufPtr, pid int32, s string) (uint64, *traceBufPtr)
buf.varint(uint64(slen))
buf.pos += copy(buf.arr[buf.pos:], s[:slen])
(*bufp).set(buf)
bufp.set(buf)
return id, bufp
}
@ -1206,7 +1206,7 @@ func trace_userLog(id uint64, category, message string) {
traceEventLocked(extraSpace, mp, pid, bufp, traceEvUserLog, 3, id, categoryID)
// traceEventLocked reserved extra space for val and len(val)
// in buf, so buf now has room for the following.
buf := (*bufp).ptr()
buf := bufp.ptr()
// double-check the message and its length can fit.
// Otherwise, truncate the message.