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

Eventfilter ternary logic consistency fixes #6393

Open
wants to merge 4 commits into
base: 1.4
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(server): Initialize target value for Event Filter casting early
  • Loading branch information
jpfr committed Apr 8, 2024
commit 9fea9e50017f1eebb83eeb46802a5c70bcd9b5a2
7 changes: 3 additions & 4 deletions src/server/ua_subscription_events_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ implicitCastTargetType(const UA_DataType *t1, const UA_DataType *t2) {
static void
castNumerical(const UA_Variant *in, const UA_DataType *type, UA_Variant *out) {
UA_assert(UA_Variant_isScalar(in));
UA_Variant_init(out); /* Set to null value */
UA_assert(UA_Variant_isEmpty(out));

UA_Int64 i = 0;
UA_UInt64 u = 0;
Expand Down Expand Up @@ -349,10 +349,8 @@ castImplicitFromString(const UA_Variant *in, const UA_DataType *outType, UA_Vari
static UA_StatusCode
castImplicit(const UA_Variant *in, const UA_DataType *outType, UA_Variant *out) {
/* Of the input is empty, casting results in a NULL value */
if(UA_Variant_isEmpty(in)) {
UA_Variant_init(out);
if(UA_Variant_isEmpty(in))
return UA_STATUSCODE_GOOD;
}

/* TODO: We only support scalar values for now */
if(!UA_Variant_isScalar(in))
Expand Down Expand Up @@ -687,6 +685,7 @@ castResolveOperands(UA_FilterEvalContext *ctx, size_t index, UA_Boolean setError
/* Cast the operands. Put the result in the same location on the stack. */
for(size_t pos = 0; pos < ctx->top; pos++) {
UA_Variant orig = ctx->stack[pos];
UA_Variant_init(&ctx->stack[pos]);
res = castImplicit(&orig, targetType, &ctx->stack[pos]);
if(res != UA_STATUSCODE_GOOD)
return (setError) ? setOperandError(ctx, index, pos, res) : res;
Expand Down