rados: return an unsafe.Pointer from ioctx Pointer call

This improves the code in two ways: first, it makes the function name and the
return type match. Second, it avoids issues found by go vet converting
from uintptr to unsafe.Pointer without any obvious pointer math.
(See: https://pkg.go.dev/unsafe)

Technically, this is an API breaking change but this function is only
public to exchange the internal ceph structure between the rados and
rbd modules. This had the smallest delta and doesn't feel any more
hacky than what already existed in the code. If someone was using this
function externally then too bad.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-03-09 16:14:15 -04:00 committed by Niels de Vos
parent 944510bd8c
commit 754d744ac8
1 changed files with 4 additions and 3 deletions

View File

@ -90,9 +90,10 @@ type IOContext struct {
ioctx C.rados_ioctx_t
}
// Pointer returns a uintptr representation of the IOContext.
func (ioctx *IOContext) Pointer() uintptr {
return uintptr(ioctx.ioctx)
// Pointer returns a pointer reference to an internal structure.
// This function should NOT be used outside of go-ceph itself.
func (ioctx *IOContext) Pointer() unsafe.Pointer {
return unsafe.Pointer(ioctx.ioctx)
}
// SetNamespace sets the namespace for objects within this IO context (pool).