From 45ea9b2888dc9539fbcba70b3cf0e9e9de9870f4 Mon Sep 17 00:00:00 2001 From: guidfort Date: Mon, 16 Sep 2024 08:01:50 +0000 Subject: [PATCH] fix: provider: 'cgo argument has Go pointer to unpinned Go pointer' --- pkg/datalayer/nodeHandler.c | 30 +++++++++++++++--------------- pkg/datalayer/nodeHandler.go | 11 +++++------ 2 files changed, 20 insertions(+), 21 deletions(-) mode change 100755 => 100644 pkg/datalayer/nodeHandler.c mode change 100755 => 100644 pkg/datalayer/nodeHandler.go diff --git a/pkg/datalayer/nodeHandler.c b/pkg/datalayer/nodeHandler.c old mode 100755 new mode 100644 index a5b9c01..6516a6a --- a/pkg/datalayer/nodeHandler.c +++ b/pkg/datalayer/nodeHandler.c @@ -1,18 +1,18 @@ /** * MIT License - * - * Copyright (c) 2021-2022 Bosch Rexroth AG - * + * + * Copyright (c) 2021-2024 Bosch Rexroth AG + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -32,39 +32,39 @@ typedef DLR_PROVIDER_NODE_CALLBACK TYPE_CB; typedef DLR_PROVIDER_NODE_CALLBACKDATA TYPE_CBDATA; -void callCallbackC(TYPE_CB cb, TYPE_CBDATA cbdata, DLR_RESULT result, DLR_VARIANT data) +void callCallbackC(TYPE_CB cb, uint64_t cbdata, DLR_RESULT result, DLR_VARIANT data) { - cb(cbdata, result, data); + cb((TYPE_CBDATA)cbdata, result, data); } -extern void nodeCallbackGo(void *userdata, char *address, DLR_VARIANT data, TYPE_CB cb, TYPE_CBDATA cbdata, int action); +extern void nodeCallbackGo(void *userdata, char *address, DLR_VARIANT data, TYPE_CB cb, uint64_t cbdata, int action); void nodeCallbackOnCreate(void *userdata, char *address, DLR_VARIANT data, TYPE_CB cb, TYPE_CBDATA cbdata) { - nodeCallbackGo(userdata, address, data, cb, cbdata, NODE_ACTION_ON_CREATE); + nodeCallbackGo(userdata, address, data, cb, (uint64_t)cbdata, NODE_ACTION_ON_CREATE); } void nodeCallbackOnRemove(void *userdata, char *address, TYPE_CB cb, TYPE_CBDATA cbdata) { - nodeCallbackGo(userdata, address, NULL, cb, cbdata, NODE_ACTION_ON_REMOVE); + nodeCallbackGo(userdata, address, NULL, cb, (uint64_t)cbdata, NODE_ACTION_ON_REMOVE); } void nodeCallbackOnBrowse(void *userdata, char *address, TYPE_CB cb, TYPE_CBDATA cbdata) { - nodeCallbackGo(userdata, address, NULL, cb, cbdata, NODE_ACTION_ON_BROWSE); + nodeCallbackGo(userdata, address, NULL, cb, (uint64_t)cbdata, NODE_ACTION_ON_BROWSE); } void nodeCallbackOnRead(void *userdata, char *address, DLR_VARIANT data, TYPE_CB cb, TYPE_CBDATA cbdata) { - nodeCallbackGo(userdata, address, data, cb, cbdata, NODE_ACTION_ON_READ); + nodeCallbackGo(userdata, address, data, cb, (uint64_t)cbdata, NODE_ACTION_ON_READ); } void nodeCallbackOnWrite(void *userdata, char *address, DLR_VARIANT data, TYPE_CB cb, TYPE_CBDATA cbdata) { - nodeCallbackGo(userdata, address, data, cb, cbdata, NODE_ACTION_ON_WRITE); + nodeCallbackGo(userdata, address, data, cb, (uint64_t)cbdata, NODE_ACTION_ON_WRITE); } void nodeCallbackOnMetadata(void *userdata, char *address, TYPE_CB cb, TYPE_CBDATA cbdata) { - nodeCallbackGo(userdata, address, NULL, cb, cbdata, NODE_ACTION_ON_METADATA); -} \ No newline at end of file + nodeCallbackGo(userdata, address, NULL, cb, (uint64_t)cbdata, NODE_ACTION_ON_METADATA); +} diff --git a/pkg/datalayer/nodeHandler.go b/pkg/datalayer/nodeHandler.go old mode 100755 new mode 100644 index 1403330..cb5c762 --- a/pkg/datalayer/nodeHandler.go +++ b/pkg/datalayer/nodeHandler.go @@ -1,6 +1,6 @@ // MIT License // -// Copyright (c) 2021-2022 Bosch Rexroth AG +// Copyright (c) 2021-2024 Bosch Rexroth AG // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -41,15 +41,14 @@ typedef enum NODE_ACTION { NODE_ACTION_ON_METADATA, }NODE_ACTION; -extern void callCallbackC(TYPE_CB cb, TYPE_CBDATA cbdata, DLR_RESULT result, DLR_VARIANT data); +extern void callCallbackC(TYPE_CB cb, uint64_t cbdata, DLR_RESULT result, DLR_VARIANT data); extern void nodeCallbackOnCreate(void* userdata, char* address, DLR_VARIANT data, TYPE_CB cb, TYPE_CBDATA cbdata); extern void nodeCallbackOnRemove(void* userdata, char* address, TYPE_CB cb, TYPE_CBDATA cbdata); extern void nodeCallbackOnBrowse(void* userdata, char* address, TYPE_CB cb, TYPE_CBDATA cbdata); extern void nodeCallbackOnRead(void* userdata, char* address, DLR_VARIANT data, TYPE_CB cb, TYPE_CBDATA cbdata); extern void nodeCallbackOnWrite(void* userdata, char* address, DLR_VARIANT data, TYPE_CB cb, TYPE_CBDATA cbdata); -extern void nodeCallbackOnMetadata(void* userdata, char* address, TYPE_CB cb, TYPE_CBDATA cbdata); -*/ +extern void nodeCallbackOnMetadata(void* userdata, char* address, TYPE_CB cb, TYPE_CBDATA cbdata);*/ import "C" import ( "sync" @@ -75,7 +74,7 @@ type nodeUserData struct { } //export nodeCallbackGo -func nodeCallbackGo(cuserdata unsafe.Pointer, caddress *C.char, cdata C.DLR_VARIANT, cb C.TYPE_CB, cbdata C.TYPE_CBDATA, action C.int) { +func nodeCallbackGo(cuserdata unsafe.Pointer, caddress *C.char, cdata C.DLR_VARIANT, cb C.TYPE_CB, cbdata C.ulong, action C.int) { var i int = *(*int)(cuserdata) var userdata *nodeUserData = nodeLookup(i) address := C.GoString(caddress) @@ -118,7 +117,7 @@ func getNodeUserdata(channels ProviderNodeChannels) unsafe.Pointer { } // createCallbackC closure to hide C types -func createCallbackC(cb C.TYPE_CB, cbdata C.TYPE_CBDATA) ProviderNodeCallback { +func createCallbackC(cb C.TYPE_CB, cbdata C.ulong) ProviderNodeCallback { return func(result Result, data *Variant) { if data == nil { C.callCallbackC(cb, cbdata, C.DLR_RESULT(result), nil)