Fixed build of USB enumerator for go compiler >=1.8.3 (@facchinm)

Fixes #30
This commit is contained in:
Cristian Maglie
2017-06-22 15:40:38 +02:00
parent c4db4e3956
commit 1ba1196861

View File

@@ -152,13 +152,13 @@ func (me *C.io_registry_entry_t) GetStringProperty(key string) (string, error) {
}
defer C.CFRelease(property)
if ptr := C.CFStringGetCStringPtr(property, 0); ptr != nil {
if ptr := C.CFStringGetCStringPtr((C.CFStringRef)(unsafe.Pointer(property)), 0); ptr != nil {
return C.GoString(ptr), nil
}
// in certain circumstances CFStringGetCStringPtr may return NULL
// and we must retrieve the string by copy
buff := make([]C.char, 1024)
if C.CFStringGetCString(property, &buff[0], 1024, 0) != C.true {
if C.CFStringGetCString((C.CFStringRef)(property), &buff[0], 1024, 0) != C.true {
return "", fmt.Errorf("Property '%s' can't be converted", key)
}
return C.GoString(&buff[0]), nil
@@ -173,7 +173,7 @@ func (me *C.io_registry_entry_t) GetIntProperty(key string, intType C.CFNumberTy
}
defer C.CFRelease(property)
var res int
if C.CFNumberGetValue(property, intType, unsafe.Pointer(&res)) != C.true {
if C.CFNumberGetValue((C.CFNumberRef)(property), intType, unsafe.Pointer(&res)) != C.true {
return res, fmt.Errorf("Property '%s' can't be converted or has been truncated", key)
}
return res, nil