Browse Source

fix API inconsistency of read-arraydimensions (breaking change)

Julius Pfrommer 6 years ago
parent
commit
0d40923bbd
4 changed files with 25 additions and 11 deletions
  1. 12 0
      CHANGELOG
  2. 4 4
      include/ua_client_highlevel.h
  3. 4 4
      src/client/ua_client_highlevel.c
  4. 5 3
      tests/check_client_highlevel.c

+ 12 - 0
CHANGELOG

@@ -1,6 +1,18 @@
 This changelog reports changes to the public API. Internal refactorings and bug
 fixes are not reported here.
 
+2017-09-07 jpfr <julius.pfrommer at web.de>
+
+ * Make Client Highlevel Interface consistent
+
+   Two methods in the client highlevel interface were not conformant with the
+   API convention that array sizes are given before the array pointer. This
+   changes the signature of UA_Client_writeArrayDimensionsAttribute and
+   UA_Client_readArrayDimensionsAttribute.
+
+   The API changes are detected by the type-matching in the compiler. So there
+   is little risk for bugs due to unaligned implementations.
+
 2017-08-16 jpfr <julius.pfrommer at web.de>
 
  * Default Attribute Values for Node Attributes

+ 4 - 4
include/ua_client_highlevel.h

@@ -152,8 +152,8 @@ UA_Client_readValueRankAttribute(UA_Client *client, const UA_NodeId nodeId,
 
 UA_StatusCode UA_EXPORT
 UA_Client_readArrayDimensionsAttribute(UA_Client *client, const UA_NodeId nodeId,
-                                       UA_UInt32 **outArrayDimensions,
-                                       size_t *outArrayDimensionsSize);
+                                       size_t *outArrayDimensionsSize,
+                                       UA_UInt32 **outArrayDimensions);
 
 static UA_INLINE UA_StatusCode
 UA_Client_readAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId,
@@ -333,8 +333,8 @@ UA_Client_writeValueRankAttribute(UA_Client *client, const UA_NodeId nodeId,
 
 UA_StatusCode UA_EXPORT
 UA_Client_writeArrayDimensionsAttribute(UA_Client *client, const UA_NodeId nodeId,
-                                        const UA_UInt32 *newArrayDimensions,
-                                        size_t newArrayDimensionsSize);
+                                        size_t newArrayDimensionsSize,
+                                        const UA_UInt32 *newArrayDimensions);
 
 static UA_INLINE UA_StatusCode
 UA_Client_writeAccessLevelAttribute(UA_Client *client, const UA_NodeId nodeId,

+ 4 - 4
src/client/ua_client_highlevel.c

@@ -308,8 +308,8 @@ __UA_Client_writeAttribute(UA_Client *client, const UA_NodeId *nodeId,
 
 UA_StatusCode
 UA_Client_writeArrayDimensionsAttribute(UA_Client *client, const UA_NodeId nodeId,
-                                        const UA_UInt32 *newArrayDimensions,
-                                        size_t newArrayDimensionsSize) {
+                                        size_t newArrayDimensionsSize,
+                                        const UA_UInt32 *newArrayDimensions) {
     if(!newArrayDimensions)
       return UA_STATUSCODE_BADTYPEMISMATCH;
 
@@ -430,8 +430,8 @@ processReadArrayDimensionsResult(UA_ReadResponse *response,
 
 UA_StatusCode
 UA_Client_readArrayDimensionsAttribute(UA_Client *client, const UA_NodeId nodeId,
-                                       UA_UInt32 **outArrayDimensions,
-                                       size_t *outArrayDimensionsSize) {
+                                       size_t *outArrayDimensionsSize,
+                                       UA_UInt32 **outArrayDimensions) {
     UA_ReadValueId item;
     UA_ReadValueId_init(&item);
     item.nodeId = nodeId;

+ 5 - 3
tests/check_client_highlevel.c

@@ -859,15 +859,17 @@ START_TEST(Node_ReadWrite_ArrayDimensions) {
 
     UA_UInt32 *arrayDimsRead;
     size_t arrayDimsReadSize;
-    UA_StatusCode retval = UA_Client_readArrayDimensionsAttribute(client, nodeReadWriteGeneric, &arrayDimsRead , &arrayDimsReadSize);
+    UA_StatusCode retval = UA_Client_readArrayDimensionsAttribute(client, nodeReadWriteGeneric,
+                                                                  &arrayDimsReadSize, &arrayDimsRead);
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
     ck_assert_int_eq(arrayDimsReadSize, 0);
 
     UA_UInt32 arrayDimsNew[] = {3};
-    retval = UA_Client_writeArrayDimensionsAttribute(client, nodeReadWriteGeneric, arrayDimsNew , 1);
+    retval = UA_Client_writeArrayDimensionsAttribute(client, nodeReadWriteGeneric, 1, arrayDimsNew);
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
 
-    retval = UA_Client_readArrayDimensionsAttribute(client, nodeReadWriteGeneric, &arrayDimsRead , &arrayDimsReadSize);
+    retval = UA_Client_readArrayDimensionsAttribute(client, nodeReadWriteGeneric,
+                                                    &arrayDimsReadSize, &arrayDimsRead);
     ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
     ck_assert_int_eq(arrayDimsReadSize, 1);
     ck_assert_int_eq(arrayDimsRead[0], 3);