summaryrefslogtreecommitdiff
path: root/dl
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-10-26 15:31:23 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-10-26 15:31:23 -0400
commit8bf311c35a97226affb297e164201fa308ee03ce (patch)
tree2b50e2bf9d71317c21b6268cd49bc9c32ff427b2 /dl
parent4f8c1a3dfc5319fd9261eae367f304a04f47600f (diff)
dl: fix a pointer/value issue found by go vet
Diffstat (limited to 'dl')
-rw-r--r--dl/dlfcn.go10
-rw-r--r--dl/dlsym_reserved.go4
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}
}