Skip to content

Commit

Permalink
refactor(server): Small simplifications suggested by static code anal…
Browse files Browse the repository at this point in the history
…ysis
  • Loading branch information
jpfr committed Oct 1, 2024
1 parent 72799b0 commit c166551
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
3 changes: 0 additions & 3 deletions src/server/ua_server_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ getNodeType(UA_Server *server, const UA_NodeHead *head) {
UA_Boolean inverse;
switch(head->nodeClass) {
case UA_NODECLASS_OBJECT:
parentRefIndex = UA_REFERENCETYPEINDEX_HASTYPEDEFINITION;
inverse = false;
break;
case UA_NODECLASS_VARIABLE:
parentRefIndex = UA_REFERENCETYPEINDEX_HASTYPEDEFINITION;
inverse = false;
Expand Down
12 changes: 6 additions & 6 deletions src/server/ua_services_nodemanagement.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,11 @@ typeCheckVariableNode(UA_Server *server, UA_Session *session,
}

/* Type-check the value */
if(retval == UA_STATUSCODE_GOOD &&
!compatibleValue(server, session, &node->dataType, node->valueRank,
node->arrayDimensionsSize, node->arrayDimensions,
&value.value, NULL, &reason)) {
UA_Boolean compatible =
compatibleValue(server, session, &node->dataType,
node->valueRank, node->arrayDimensionsSize,
node->arrayDimensions, &value.value, NULL, &reason);
if(!compatible) {
UA_LOG_NODEID_INFO(&node->head.nodeId,
UA_LOG_INFO_SESSION(server->config.logging, session,
"AddNode (%.*s): The VariableNode value has "
Expand Down Expand Up @@ -1587,10 +1588,9 @@ addNode_finish(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId)
}

cleanup:
UA_NODESTORE_RELEASE(server, node);
if(type)
UA_NODESTORE_RELEASE(server, type);
if(node)
UA_NODESTORE_RELEASE(server, node);
if(retval != UA_STATUSCODE_GOOD)
deleteNode(server, *nodeId, true);
return retval;
Expand Down
5 changes: 2 additions & 3 deletions src/server/ua_subscription_monitoreditem.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ UA_Notification_enqueueAndTrigger(UA_Server *server, UA_Notification *n) {
mon->triggeredUntil > UA_DateTime_nowMonotonic())) {
UA_Notification_enqueueSub(n);
mon->triggeredUntil = UA_INT64_MIN;
UA_LOG_DEBUG_SUBSCRIPTION(server->config.logging, mon->subscription,
UA_LOG_DEBUG_SUBSCRIPTION(server->config.logging, sub,
"Notification enqueued (Queue size %lu)",
(long unsigned)mon->subscription->notificationQueueSize);
(long unsigned)sub->notificationQueueSize);
}

/* Insert into the MonitoredItem. This checks the queue size and
Expand Down Expand Up @@ -430,7 +430,6 @@ UA_Server_registerMonitoredItem(UA_Server *server, UA_MonitoredItem *mon) {
UA_Subscription *sub = mon->subscription;
if(sub) {
mon->monitoredItemId = ++sub->lastMonitoredItemId;
mon->subscription = sub;
sub->monitoredItemsSize++;
LIST_INSERT_HEAD(&sub->monitoredItems, mon, listEntry);
} else {
Expand Down

0 comments on commit c166551

Please sign in to comment.