From 754d744ac8c814f9a8b0e783f0fc1358b3d67b10 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 9 Mar 2020 16:14:15 -0400 Subject: [PATCH] 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 --- rados/ioctx.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rados/ioctx.go b/rados/ioctx.go index 0c7e641..f91e437 100644 --- a/rados/ioctx.go +++ b/rados/ioctx.go @@ -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).