summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--signal-composer-binding/signal-composer.cpp17
-rw-r--r--signal-composer-binding/signal.cpp2
-rw-r--r--signal-composer-binding/source.cpp4
3 files changed, 15 insertions, 8 deletions
diff --git a/signal-composer-binding/signal-composer.cpp b/signal-composer-binding/signal-composer.cpp
index 572a6c4..d9d004c 100644
--- a/signal-composer-binding/signal-composer.cpp
+++ b/signal-composer-binding/signal-composer.cpp
@@ -177,6 +177,7 @@ CtlActionT* Composer::convert2Action(const std::string& name, json_object* actio
char *function;
const char *plugin;
CtlActionT *ctlAction = new CtlActionT;
+ memset(ctlAction, 0, sizeof(CtlActionT));
if(actionJ &&
!wrap_json_unpack(actionJ, "{ss,s?s,s?o !}", "function", &function,
@@ -218,9 +219,12 @@ CtlActionT* Composer::convert2Action(const std::string& name, json_object* actio
}
if(ctlActionJ)
- {ActionLoadOne(nullptr, ctlAction, ctlActionJ, 0);}
+ {
+ if(!ActionLoadOne(nullptr, ctlAction, ctlActionJ, 0))
+ return ctlAction;
+ }
- return ctlAction;
+ return nullptr;
}
/// @brief Add the builtin plugin in the default plugins section definition
@@ -359,13 +363,13 @@ int Composer::loadOneSignal(json_object* signalJ)
const char *id = nullptr,
*event = nullptr,
*unit = nullptr;
- int retention;
+ int retention = 0;
double frequency=0.0;
std::vector<std::string> dependsV;
ssize_t sep;
std::shared_ptr<SourceAPI> src = nullptr;
- int err = wrap_json_unpack(signalJ, "{ss,s?s,s?o,s?o,s?F,s?s,s?F,s?o !}",
+ int err = wrap_json_unpack(signalJ, "{ss,s?s,s?o,s?o,s?i,s?s,s?F,s?o !}",
"uid", &id,
"event", &event,
"depends", &dependsJ,
@@ -443,8 +447,9 @@ int Composer::loadOneSignal(json_object* signalJ)
unit = !unit ? "" : unit;
// Set default onReceived action if not specified
- char* uid = strndup("onReceived_", 11);
- uid = strncat(uid, id, strlen(id));
+ char uid[CONTROL_MAXPATH_LEN] = "onReceived_";
+ strncat(uid, id, strlen(id));
+
if(!onReceivedJ)
{
onReceivedCtl = src->signalsDefault().onReceived ?
diff --git a/signal-composer-binding/signal.cpp b/signal-composer-binding/signal.cpp
index 2af440c..17286f5 100644
--- a/signal-composer-binding/signal.cpp
+++ b/signal-composer-binding/signal.cpp
@@ -142,7 +142,7 @@ json_object* Signal::toJSON() const
struct signalCBT* Signal::get_context()
{
- struct signalCBT* ctx = (struct signalCBT*)calloc (1, sizeof(struct signalCBT));
+ struct signalCBT* ctx = new struct signalCBT;
if(!ctx->searchNsetSignalValue)
{ctx->searchNsetSignalValue = searchNsetSignalValueHandle;}
diff --git a/signal-composer-binding/source.cpp b/signal-composer-binding/source.cpp
index 9e10e65..830f799 100644
--- a/signal-composer-binding/source.cpp
+++ b/signal-composer-binding/source.cpp
@@ -112,12 +112,14 @@ void SourceAPI::makeSubscription()
AFB_ERROR("Error building JSON query object to subscribe to for signal %s", sig.second->id().c_str());
break;
}
- source.uid = sig.second->id().c_str();
+ source.uid = sig.first.c_str();
source.context = (void*)sig.second->get_context();
ActionExecOne(&source, getSignals_, signalJ);
// Considerate signal subscribed no matter what
sig.second->subscribed_ = true;
+ delete(source.context);
}
+ source.uid = "";
ActionExecOne(&source, getSignals_, nullptr);
}
}