Skip to content

Conversation

@azelcs
Copy link
Contributor

@azelcs azelcs commented Mar 24, 2025

No description provided.

@azelcs azelcs added the wip Work in progress label Mar 25, 2025
@azelcs azelcs removed the wip Work in progress label Mar 27, 2025
@azelcs
Copy link
Contributor Author

azelcs commented Jun 11, 2025

@rrundzans Hi! Would it be possible to check and publish this?

@azelcs azelcs requested a review from ebeigarts September 10, 2025 16:46
@ebeigarts ebeigarts requested a review from Copilot September 11, 2025 14:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for reading and writing UA_String types in the OPC-UA client and enhances the test infrastructure by running tests against a real OPC server.

  • Implements string type support in both C extension and test server
  • Refactors server variable creation functions for better type safety
  • Adds comprehensive integration tests using a compiled OPC server

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/server/server.cpp Adds string type support and refactors variable creation with type-specific functions
tools/server/makefile Updates build output name from 'server' to 'opcua-server'
spec/core_spec.rb Adds comprehensive integration tests for all data types using real OPC server
ext/opcua_client/opcua_client.c Implements string read/write support in the C extension
README.md Updates documentation with string methods and corrected server executable name
.github/workflows/build.yml Removes Windows from CI matrix

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

addVariableV2(server, nsId, type, variable, &defaultValue);
}

static void addVariableFloat(UA_Server *server, UA_Int16 nsId, int type, const char *variable, UA_Float defaultValue = 0) {
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default parameter value should be 0.0f instead of 0 to maintain type consistency with UA_Float.

Suggested change
static void addVariableFloat(UA_Server *server, UA_Int16 nsId, int type, const char *variable, UA_Float defaultValue = 0) {
static void addVariableFloat(UA_Server *server, UA_Int16 nsId, int type, const char *variable, UA_Float defaultValue = 0.0f) {

Copilot uses AI. Check for mistakes.
Check_Type(v_newValue, T_STRING);
UA_String newValue = UA_STRING(StringValueCStr(v_newValue));
values[i].data = UA_malloc(sizeof(UA_String));
UA_String_copy(&newValue, (UA_String*)values[i].data);
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memory leak potential: if UA_String_copy fails, the allocated memory from UA_malloc will not be freed. Consider checking the return value of UA_String_copy and freeing the allocated memory on failure.

Suggested change
UA_String_copy(&newValue, (UA_String*)values[i].data);
UA_StatusCode copyStatus = UA_String_copy(&newValue, (UA_String*)values[i].data);
if (copyStatus != UA_STATUSCODE_GOOD) {
UA_free(values[i].data);
return raise_ua_status_error(copyStatus);
}

Copilot uses AI. Check for mistakes.
} else if (uaType == UA_TYPES_STRING) {
UA_String newValue = UA_STRING(StringValueCStr(v_newValue));
value.data = UA_malloc(sizeof(UA_String));
UA_String_copy(&newValue, (UA_String*)value.data);
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memory leak potential: same issue as in the multi-write function. If UA_String_copy fails, the allocated memory from UA_malloc will not be freed.

Suggested change
UA_String_copy(&newValue, (UA_String*)value.data);
UA_StatusCode copyStatus = UA_String_copy(&newValue, (UA_String*)value.data);
if (copyStatus != UA_STATUSCODE_GOOD) {
UA_free(value.data);
rb_raise(cError, "UA_String_copy failed");
}

Copilot uses AI. Check for mistakes.
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

Successfully merging this pull request may close these issues.

2 participants