rbd: prevent a go vet error by doing type-casting in C

The void * is (ab)used in C for passing arbitrary data to the callback,
which in our case is a integer index. However, Go tools can not tell
this is OK and throws an error running go vet. Change the wrapper
function to take a uintptr_t and cast that to void* only in the
(unchecked) C layer.

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

View File

@ -17,8 +17,8 @@ static inline int wrap_rbd_diff_iterate2(
uint64_t ofs, uint64_t len, uint64_t ofs, uint64_t len,
uint8_t include_parent, uint8_t whole_object, uint8_t include_parent, uint8_t whole_object,
void *cb, void *cb,
void *arg) { uintptr_t arg) {
return rbd_diff_iterate2(image, fromsnapname, ofs, len, include_parent, whole_object, cb, arg); return rbd_diff_iterate2(image, fromsnapname, ofs, len, include_parent, whole_object, cb, (void*)arg);
} }
*/ */
import "C" import "C"
@ -120,7 +120,7 @@ func (image *Image) DiffIterate(config DiffIterateConfig) error {
C.uint8_t(config.IncludeParent), C.uint8_t(config.IncludeParent),
C.uint8_t(config.WholeObject), C.uint8_t(config.WholeObject),
C.callDiffIterateCallback, C.callDiffIterateCallback,
unsafe.Pointer(uintptr(cbIndex))) C.uintptr_t(cbIndex))
return getError(ret) return getError(ret)
} }