runtime/cgo: fix cgoCheckArg description

The description is misleading: cgoCheckArg is called by both
cgoCheckPointer and cgoCheckResult.

Mention cgoCheckResult in the cgoCheckArg description. Remove extra
spaces between words.

For #75856

Change-Id: I6780cda76b5cb7b4f9af3fbaa37a6c5099cc8d7d
GitHub-Last-Rev: 531928b679
GitHub-Pull-Request: golang/go#75992
Reviewed-on: https://go-review.googlesource.com/c/go/+/713520
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Ariel Otilibili 2025-10-22 08:36:51 +00:00 committed by t hepudds
parent 50586182ab
commit f92e01c117

View file

@ -33,7 +33,7 @@
// //
// To make it possible for gcc-compiled C code to call a Go function p.GoF, // To make it possible for gcc-compiled C code to call a Go function p.GoF,
// cgo writes a gcc-compiled function named GoF (not p.GoF, since gcc doesn't // cgo writes a gcc-compiled function named GoF (not p.GoF, since gcc doesn't
// know about packages). The gcc-compiled C function f calls GoF. // know about packages). The gcc-compiled C function f calls GoF.
// //
// GoF initializes "frame", a structure containing all of its // GoF initializes "frame", a structure containing all of its
// arguments and slots for p.GoF's results. It calls // arguments and slots for p.GoF's results. It calls
@ -58,10 +58,10 @@
// m.g0 stack, so that it can be restored later. // m.g0 stack, so that it can be restored later.
// //
// runtime.cgocallbackg (below) is now running on a real goroutine // runtime.cgocallbackg (below) is now running on a real goroutine
// stack (not an m.g0 stack). First it calls runtime.exitsyscall, which will // stack (not an m.g0 stack). First it calls runtime.exitsyscall, which will
// block until the $GOMAXPROCS limit allows running this goroutine. // block until the $GOMAXPROCS limit allows running this goroutine.
// Once exitsyscall has returned, it is safe to do things like call the memory // Once exitsyscall has returned, it is safe to do things like call the memory
// allocator or invoke the Go callback function. runtime.cgocallbackg // allocator or invoke the Go callback function. runtime.cgocallbackg
// first defers a function to unwind m.g0.sched.sp, so that if p.GoF // first defers a function to unwind m.g0.sched.sp, so that if p.GoF
// panics, m.g0.sched.sp will be restored to its old value: the m.g0 stack // panics, m.g0.sched.sp will be restored to its old value: the m.g0 stack
// and the m.curg stack will be unwound in lock step. // and the m.curg stack will be unwound in lock step.
@ -393,7 +393,7 @@ func cgocallbackg1(fn, frame unsafe.Pointer, ctxt uintptr) {
// Now we need to set gp.cgoCtxt = s, but we could get // Now we need to set gp.cgoCtxt = s, but we could get
// a SIGPROF signal while manipulating the slice, and // a SIGPROF signal while manipulating the slice, and
// the SIGPROF handler could pick up gp.cgoCtxt while // the SIGPROF handler could pick up gp.cgoCtxt while
// tracing up the stack. We need to ensure that the // tracing up the stack. We need to ensure that the
// handler always sees a valid slice, so set the // handler always sees a valid slice, so set the
// values in an order such that it always does. // values in an order such that it always does.
p := (*slice)(unsafe.Pointer(&gp.cgoCtxt)) p := (*slice)(unsafe.Pointer(&gp.cgoCtxt))
@ -594,9 +594,9 @@ func cgoCheckPointer(ptr any, arg any) {
const cgoCheckPointerFail = "cgo argument has Go pointer to unpinned Go pointer" const cgoCheckPointerFail = "cgo argument has Go pointer to unpinned Go pointer"
const cgoResultFail = "cgo result is unpinned Go pointer or points to unpinned Go pointer" const cgoResultFail = "cgo result is unpinned Go pointer or points to unpinned Go pointer"
// cgoCheckArg is the real work of cgoCheckPointer. The argument p // cgoCheckArg is the real work of cgoCheckPointer and cgoCheckResult.
// is either a pointer to the value (of type t), or the value itself, // The argument p is either a pointer to the value (of type t), or the value
// depending on indir. The top parameter is whether we are at the top // itself, depending on indir. The top parameter is whether we are at the top
// level, where Go pointers are allowed. Go pointers to pinned objects are // level, where Go pointers are allowed. Go pointers to pinned objects are
// allowed as long as they don't reference other unpinned pointers. // allowed as long as they don't reference other unpinned pointers.
func cgoCheckArg(t *_type, p unsafe.Pointer, indir, top bool, msg string) { func cgoCheckArg(t *_type, p unsafe.Pointer, indir, top bool, msg string) {