Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Filter plugin interface #843

Open
jchabod opened this issue Oct 3, 2022 · 3 comments
Open

Invalid Filter plugin interface #843

jchabod opened this issue Oct 3, 2022 · 3 comments
Assignees

Comments

@jchabod
Copy link

jchabod commented Oct 3, 2022

I'm using Fledge v2.0.0

There seem to be an inconsistency in FILTER plugin API:

 * @param handle     The plugin handle returned from plugin_init
...
void plugin_ingest(PLUGIN_HANDLE *handle,
                   READINGSET *readingSet)
{
        LogFilter *log = (LogFilter *) handle;
        log->ingest(readingSet);
}

But : typedef void * PLUGIN_HANDLE; is defined in plugin_api.h
Thus handle is a void** and C-style casted to LogFilter*, which in no way can be a valid cast. (The comment The plugin handle returned from plugin_init is not helping here)

We may infer that either:

  • The correct API is void plugin_ingest(PLUGIN_HANDLE handle, READINGSET *readingSet
  • Or, the CONTENT of handle holds the pointer value : LogFilter *log = (LogFilter *) (*handle);

Same issue for plugin_reconfigure and plugin_shutdown

@jchabod
Copy link
Author

jchabod commented Oct 3, 2022

Note: in filter_plugin.cpp, it seems that the correct API is void plugin_ingest(PLUGIN_HANDLE handle, READINGSET *readingSet

@MarkRiddoch
Copy link
Contributor

Thanks, I suspect this might be a documentation issue. We will need to look into it.

@mbourhis
Copy link

It seems that issue concerns the code of at least one 'filter' plugin too.

These 2 'filter' plugins don't have the same API:

https://github.com/fledge-iot/fledge-filter-change/blob/develop/plugin.cpp
https://github.com/fledge-iot/fledge-filter-log/blob/develop/plugin.cpp

In one case, we can see
(https://github.com/fledge-iot/fledge-filter-change/blob/c82d07a4e520e9b8b4da68fcd5c83221ca718d28/plugin.cpp#L204)

void plugin_reconfigure(PLUGIN_HANDLE handle, const string& newConfig)

and
(https://github.com/fledge-iot/fledge-filter-change/blob/c82d07a4e520e9b8b4da68fcd5c83221ca718d28/plugin.cpp#L213)

void plugin_shutdown(PLUGIN_HANDLE handle)

and in the second case :
(https://github.com/fledge-iot/fledge-filter-log/blob/6fe471d099137f1548f2cca56f43110ed7b767bf/plugin.cpp#L110)

void plugin_reconfigure(PLUGIN_HANDLE *handle, const std::string& newConfig)

and
(https://github.com/fledge-iot/fledge-filter-log/blob/6fe471d099137f1548f2cca56f43110ed7b767bf/plugin.cpp#L119)

void plugin_shutdown(PLUGIN_HANDLE *handle)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants