From 8bf311c35a97226affb297e164201fa308ee03ce Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 26 Oct 2015 15:31:23 -0400 Subject: dl: fix a pointer/value issue found by go vet --- dl/dlfcn.go | 10 +++++----- dl/dlsym_reserved.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dl/dlfcn.go b/dl/dlfcn.go index db8bd63..f182cfe 100644 --- a/dl/dlfcn.go +++ b/dl/dlfcn.go @@ -66,7 +66,7 @@ type Handle struct { // symbol table for the current process; if the name contains a slash, // then it is interpretted as a pathname; otherwise, it is // interpretted in an implementation-defined manner. -func Open(name string, flags Flag) (Handle, error) { +func Open(name string, flags Flag) (*Handle, error) { nameC := C.CString(name) defer C.free(unsafe.Pointer(nameC)) if name == "" { @@ -76,9 +76,9 @@ func Open(name string, flags Flag) (Handle, error) { dlerror() ptr := C.dlopen(nameC, C.int(flags)) if ptr == nil { - return Handle{}, dlerror() + return &Handle{}, dlerror() } - return Handle{c: ptr, o: 1}, nil + return &Handle{c: ptr, o: 1}, nil } // Look up a symbol, and return a pointer to it. @@ -86,7 +86,7 @@ func Open(name string, flags Flag) (Handle, error) { // This returns uintptr instead of unsafe.Pointer so that code using // dl cannot obtain unsafe.Pointers without importing the unsafe // package explicitly. -func (h Handle) Sym(symbol string) (uintptr, error) { +func (h *Handle) Sym(symbol string) (uintptr, error) { h.l.RLock() defer h.l.RUnlock() @@ -108,7 +108,7 @@ func (h Handle) Sym(symbol string) (uintptr, error) { // Close this handle on a shared object; decrementint the reference // count; if the reference count drops below 0, then the object is // unloaded. -func (h Handle) Close() error { +func (h *Handle) Close() error { h.l.Lock() defer h.l.Unlock() diff --git a/dl/dlsym_reserved.go b/dl/dlsym_reserved.go index 081e012..e4f9eec 100644 --- a/dl/dlsym_reserved.go +++ b/dl/dlsym_reserved.go @@ -58,6 +58,6 @@ var ( ) func init() { - RTLD_DEFAULT = Handle{c: unsafe.Pointer(uintptr(C.rtld_default)), o: 2} - RTLD_DEFAULT = Handle{c: unsafe.Pointer(uintptr(C.rtld_next)), o: 2} + RTLD_DEFAULT = &Handle{c: unsafe.Pointer(uintptr(C.rtld_default)), o: 2} + RTLD_DEFAULT = &Handle{c: unsafe.Pointer(uintptr(C.rtld_next)), o: 2} } -- cgit v1.2.3-54-g00ecf