You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Most of the documentation involving PLUGIN_HANDLE provides erroneous usage examples for the C++ implementation of a plugin.
The plugin_init() function is correct and returns a PLUGIN_HANDLE type (void*) containing a pointer to the main plugin class (in this example a DHT11*):
But then most of the other functions in the documentation take a PLUGIN_HANDLE* as parameter (void**) when it should in fact use a PLUGIN_HANDLE only. It is clearly visible that the input type is actually the same type as the one returned by plugin_init() when the input type is casted into DHT11* here:
All of the documentation involving this type needs to be reviewed: some functions may actually need PLUGIN_HANDLE* as an input, but most of them doesn't and must be fixed.
Sadly most of the existing plugins are based on those examples and do contain this erroneous implementation which is not raising any error because it is using the "jocker" void* type.
As an example in one of the plugins I reviewed this led to really messed up codes likes this one where you end up casting a PLUGIN_HANDLE into PLUGIN_HANDLE* which makes zero sense in term of pure C++:
Fix the issue fledge-iot#1069
In the 'plugin_developers_guide/03_south_C_plugins.html' documentation page,
the signature of some plugin functions involving PLUGIN_HANDLE is erroneous.
According to the definitions of the function pointers about the South
plugins ($FLEDGE_ROOT/C/services/south/include/south_plugin.h),
fix these signatures.
And use the appropriate C++ 'cast' operator,
more restrictive and accurate 'cast' operator than the C one,
for the 'PLUGIN_HANDLE' object.
Signed-off-by: Mikael Bourhis <[email protected]>
Most of the documentation involving PLUGIN_HANDLE provides erroneous usage examples for the C++ implementation of a plugin.
The
plugin_init()
function is correct and returns aPLUGIN_HANDLE
type (void*
) containing a pointer to the main plugin class (in this example aDHT11*
):But then most of the other functions in the documentation take a
PLUGIN_HANDLE*
as parameter (void**
) when it should in fact use aPLUGIN_HANDLE
only. It is clearly visible that the input type is actually the same type as the one returned byplugin_init()
when the input type is casted intoDHT11*
here:All of the documentation involving this type needs to be reviewed: some functions may actually need
PLUGIN_HANDLE*
as an input, but most of them doesn't and must be fixed.Sadly most of the existing plugins are based on those examples and do contain this erroneous implementation which is not raising any error because it is using the "jocker"
void*
type.As an example in one of the plugins I reviewed this led to really messed up codes likes this one where you end up casting a
PLUGIN_HANDLE
intoPLUGIN_HANDLE*
which makes zero sense in term of pure C++:The text was updated successfully, but these errors were encountered: