Browse Source

add Wshadow and Wconversion compiler flags; fix all warnings; networklayer takes the logger from the server at startup

Julius Pfrommer 9 years ago
parent
commit
2ae7fef1e4
53 changed files with 420 additions and 353 deletions
  1. 3 3
      CMakeLists.txt
  2. 5 7
      README.md
  3. 6 6
      deps/pcg_basic.c
  4. 4 4
      deps/pcg_basic.h
  5. 2 2
      examples/client.c
  6. 3 3
      examples/server.c
  7. 1 1
      examples/server.cpp
  8. 2 2
      examples/server_datasource.c
  9. 2 2
      examples/server_firstSteps.c
  10. 1 1
      examples/server_method.c
  11. 1 1
      examples/server_nodeset.c
  12. 1 1
      examples/server_repeated_job.c
  13. 1 1
      examples/server_variable.c
  14. 2 2
      include/ua_client.h
  15. 1 1
      include/ua_client_highlevel.h
  16. 3 3
      include/ua_server.h
  17. 5 5
      include/ua_types.h
  18. 4 4
      src/client/ua_client.c
  19. 3 3
      src/client/ua_client_highlevel.c
  20. 2 2
      src/client/ua_client_highlevel_subscriptions.c
  21. 17 17
      src/client/ua_client_internal.h
  22. 17 17
      src/server/ua_nodestore.c
  23. 2 2
      src/server/ua_nodestore_concurrent.c
  24. 10 8
      src/server/ua_nodestore_hash.inc
  25. 4 4
      src/server/ua_securechannel_manager.h
  26. 12 11
      src/server/ua_server.c
  27. 2 1
      src/server/ua_server_binary.c
  28. 16 3
      src/server/ua_server_worker.c
  29. 1 1
      src/server/ua_services.h
  30. 30 27
      src/server/ua_services_attribute.c
  31. 1 1
      src/server/ua_services_call.c
  32. 2 2
      src/server/ua_services_discovery.c
  33. 43 45
      src/server/ua_services_nodemanagement.c
  34. 1 1
      src/server/ua_services_securechannel.c
  35. 4 4
      src/server/ua_services_subscription.c
  36. 6 6
      src/server/ua_services_view.c
  37. 4 4
      src/server/ua_session_manager.h
  38. 7 5
      src/server/ua_subscription.c
  39. 7 7
      src/server/ua_subscription.h
  40. 11 8
      src/server/ua_subscription_manager.c
  41. 11 8
      src/server/ua_subscription_manager.h
  42. 18 5
      src/ua_connection.c
  43. 12 1
      src/ua_securechannel.c
  44. 0 14
      src/ua_session.c
  45. 1 2
      src/ua_session.h
  46. 15 11
      src/ua_types.c
  47. 42 33
      src/ua_types_encoding_binary.c
  48. 4 4
      src_extra/logger_stdout.c
  49. 56 40
      src_extra/networklayer_tcp.c
  50. 1 1
      src_extra/networklayer_tcp.h
  51. 2 0
      tests/CMakeLists.txt
  52. 8 5
      tests/check_builtin.c
  53. 1 1
      tools/pyUANamespace/open62541_MacroHelper.py

+ 3 - 3
CMakeLists.txt

@@ -58,14 +58,14 @@ list(APPEND open62541_LIBRARIES "")
 # compiler flags
 # compiler flags
 if(CMAKE_COMPILER_IS_GNUCC OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang")
 if(CMAKE_COMPILER_IS_GNUCC OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang")
     add_definitions(-std=c99 -pipe -Wall -Wextra -Werror -Wformat -Wno-unused-parameter
     add_definitions(-std=c99 -pipe -Wall -Wextra -Werror -Wformat -Wno-unused-parameter
-                    -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wreturn-type -Wsign-compare -Wmultichar
-                    -Wcast-qual -Wmissing-prototypes -Wstrict-prototypes #-Wshadow #-Wconversion
+                    -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wreturn-type -Wsign-compare
+                    -Wmultichar -Wstrict-overflow -Wcast-qual -Wmissing-prototypes -Wstrict-prototypes
                     -Winit-self -Wuninitialized -Wformat-security -Wformat-nonliteral)
                     -Winit-self -Wuninitialized -Wformat-security -Wformat-nonliteral)
 
 
   # library linking
   # library linking
   set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # cmake sets -rdynamic by default
   set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # cmake sets -rdynamic by default
   if(NOT WIN32 AND NOT CYGWIN)
   if(NOT WIN32 AND NOT CYGWIN)
-	add_definitions(-fvisibility=hidden -fPIC)
+	add_definitions(-Wshadow -Wconversion -fvisibility=hidden -fPIC)
     if(NOT APPLE)
     if(NOT APPLE)
       set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,--build-id=none")
       set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,--build-id=none")
     endif()
     endif()

+ 5 - 7
README.md

@@ -38,9 +38,8 @@ With the GCC compiler, just run ```gcc -std=c99 <server.c> open62541.c -o server
 
 
 #define PORT 16664
 #define PORT 16664
 
 
-UA_Logger logger = Logger_Stdout;
 UA_Boolean running = UA_TRUE;
 UA_Boolean running = UA_TRUE;
-void signalHandler(int sign) {
+void signalHandler(int sig) {
     running = UA_FALSE;
     running = UA_FALSE;
 }
 }
 
 
@@ -50,9 +49,9 @@ int main(int argc, char** argv)
     signal(SIGINT, signalHandler);
     signal(SIGINT, signalHandler);
 
 
     /* init the server */
     /* init the server */
+    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, PORT);
     UA_ServerConfig config = UA_ServerConfig_standard;
     UA_ServerConfig config = UA_ServerConfig_standard;
-    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664, logger);
-    config.logger = logger;
+    config.logger = Logger_Stdout;
     config.networkLayers = &nl;
     config.networkLayers = &nl;
     config.networkLayersSize = 1;
     config.networkLayersSize = 1;
     UA_Server *server = UA_Server_new(config);
     UA_Server *server = UA_Server_new(config);
@@ -73,9 +72,8 @@ int main(int argc, char** argv)
     UA_QualifiedName browseName = UA_QUALIFIEDNAME(1, "the answer");
     UA_QualifiedName browseName = UA_QUALIFIEDNAME(1, "the answer");
 
 
     /* 3) add the variable */
     /* 3) add the variable */
-    UA_Server_addVariableNode(server, newNodeId, parentNodeId,
-                              parentReferenceNodeId, browseName,
-                              variableType, attr, NULL);
+    UA_Server_addVariableNode(server, newNodeId, parentNodeId, parentReferenceNodeId,
+                              browseName, variableType, attr, NULL);
 
 
     /* run the server loop */
     /* run the server loop */
     UA_StatusCode retval = UA_Server_run(server, &running);
     UA_StatusCode retval = UA_Server_run(server, &running);

+ 6 - 6
deps/pcg_basic.c

@@ -34,17 +34,17 @@
 
 
 static pcg32_random_t pcg32_global = PCG32_INITIALIZER;
 static pcg32_random_t pcg32_global = PCG32_INITIALIZER;
 
 
-// pcg32_srandom(initstate, initseq)
-// pcg32_srandom_r(rng, initstate, initseq):
+// pcg32_srandom(initial_state, initseq)
+// pcg32_srandom_r(rng, initial_state, initseq):
 //     Seed the rng.  Specified in two parts, state initializer and a
 //     Seed the rng.  Specified in two parts, state initializer and a
 //     sequence selection constant (a.k.a. stream id)
 //     sequence selection constant (a.k.a. stream id)
 
 
-void pcg32_srandom_r(pcg32_random_t* rng, uint64_t initstate, uint64_t initseq)
+void pcg32_srandom_r(pcg32_random_t* rng, uint64_t initial_state, uint64_t initseq)
 {
 {
     rng->state = 0U;
     rng->state = 0U;
     rng->inc = (initseq << 1u) | 1u;
     rng->inc = (initseq << 1u) | 1u;
     pcg32_random_r(rng);
     pcg32_random_r(rng);
-    rng->state += initstate;
+    rng->state += initial_state;
     pcg32_random_r(rng);
     pcg32_random_r(rng);
 }
 }
 
 
@@ -61,8 +61,8 @@ uint32_t pcg32_random_r(pcg32_random_t* rng)
 {
 {
     uint64_t oldstate = rng->state;
     uint64_t oldstate = rng->state;
     rng->state = oldstate * 6364136223846793005ULL + rng->inc;
     rng->state = oldstate * 6364136223846793005ULL + rng->inc;
-    uint32_t xorshifted = ((oldstate >> 18u) ^ oldstate) >> 27u;
-    uint32_t rot = oldstate >> 59u;
+    uint32_t xorshifted = (uint32_t)(((oldstate >> 18u) ^ oldstate) >> 27u);
+    uint32_t rot = (uint32_t)(oldstate >> 59u);
     return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
     return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
 }
 }
 
 

+ 4 - 4
deps/pcg_basic.h

@@ -48,13 +48,13 @@ typedef struct pcg_state_setseq_64 pcg32_random_t;
 
 
 #define PCG32_INITIALIZER   { 0x853c49e6748fea9bULL, 0xda3e39cb94b95bdbULL }
 #define PCG32_INITIALIZER   { 0x853c49e6748fea9bULL, 0xda3e39cb94b95bdbULL }
 
 
-// pcg32_srandom(initstate, initseq)
-// pcg32_srandom_r(rng, initstate, initseq):
+// pcg32_srandom(initial_state, initseq)
+// pcg32_srandom_r(rng, initial_state, initseq):
 //     Seed the rng.  Specified in two parts, state initializer and a
 //     Seed the rng.  Specified in two parts, state initializer and a
 //     sequence selection constant (a.k.a. stream id)
 //     sequence selection constant (a.k.a. stream id)
 
 
-void pcg32_srandom(uint64_t initstate, uint64_t initseq);
-void pcg32_srandom_r(pcg32_random_t* rng, uint64_t initstate,
+void pcg32_srandom(uint64_t initial_state, uint64_t initseq);
+void pcg32_srandom_r(pcg32_random_t* rng, uint64_t initial_state,
                      uint64_t initseq);
                      uint64_t initseq);
 
 
 // pcg32_random()
 // pcg32_random()

+ 2 - 2
examples/client.c

@@ -143,12 +143,12 @@ int main(int argc, char *argv[]) {
     UA_Variant_init(&input);
     UA_Variant_init(&input);
     UA_Variant_setScalarCopy(&input, &argString, &UA_TYPES[UA_TYPES_STRING]);
     UA_Variant_setScalarCopy(&input, &argString, &UA_TYPES[UA_TYPES_STRING]);
     
     
-    UA_Int32 outputSize;
+    size_t outputSize;
     UA_Variant *output;
     UA_Variant *output;
     retval = UA_Client_call(client, UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
     retval = UA_Client_call(client, UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
                             UA_NODEID_NUMERIC(1, 62541), 1, &input, &outputSize, &output);
                             UA_NODEID_NUMERIC(1, 62541), 1, &input, &outputSize, &output);
     if(retval == UA_STATUSCODE_GOOD) {
     if(retval == UA_STATUSCODE_GOOD) {
-        printf("Method call was successfull, and %i returned values available.\n", outputSize);
+        printf("Method call was successfull, and %zu returned values available.\n", outputSize);
         UA_Array_delete(output, outputSize, &UA_TYPES[UA_TYPES_VARIANT]);
         UA_Array_delete(output, outputSize, &UA_TYPES[UA_TYPES_VARIANT]);
     } else {
     } else {
         printf("Method call was unsuccessfull, and %x returned values available.\n", retval);
         printf("Method call was unsuccessfull, and %x returned values available.\n", retval);

+ 3 - 3
examples/server.c

@@ -180,7 +180,7 @@ static UA_ByteString loadCertificate(void) {
     }
     }
 
 
     fseek(fp, 0, SEEK_END);
     fseek(fp, 0, SEEK_END);
-    certificate.length = ftell(fp);
+    certificate.length = (size_t)ftell(fp);
     certificate.data = malloc(certificate.length*sizeof(UA_Byte));
     certificate.data = malloc(certificate.length*sizeof(UA_Byte));
 	if(!certificate.data){
 	if(!certificate.data){
 		fclose(fp);
 		fclose(fp);
@@ -212,10 +212,10 @@ int main(int argc, char** argv) {
     pthread_rwlock_init(&writeLock, 0);
     pthread_rwlock_init(&writeLock, 0);
 #endif
 #endif
 
 
+    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664);
     UA_ServerConfig config = UA_ServerConfig_standard;
     UA_ServerConfig config = UA_ServerConfig_standard;
-    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664, logger);
-    config.serverCertificate = loadCertificate();
     config.logger = Logger_Stdout;
     config.logger = Logger_Stdout;
+    config.serverCertificate = loadCertificate();
     config.networkLayers = &nl;
     config.networkLayers = &nl;
     config.networkLayersSize = 1;
     config.networkLayersSize = 1;
     UA_Server *server = UA_Server_new(config);
     UA_Server *server = UA_Server_new(config);

+ 1 - 1
examples/server.cpp

@@ -35,7 +35,7 @@ int main() {
     signal(SIGINT, stopHandler); /* catches ctrl-c */
     signal(SIGINT, stopHandler); /* catches ctrl-c */
 
 
     UA_ServerConfig config = UA_ServerConfig_standard;
     UA_ServerConfig config = UA_ServerConfig_standard;
-    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664, logger);
+    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664);
     config.logger = Logger_Stdout;
     config.logger = Logger_Stdout;
     config.networkLayers = &nl;
     config.networkLayers = &nl;
     config.networkLayersSize = 1;
     config.networkLayersSize = 1;

+ 2 - 2
examples/server_datasource.c

@@ -39,7 +39,7 @@ static UA_StatusCode
 writeInteger(void *handle, const UA_NodeId nodeid,
 writeInteger(void *handle, const UA_NodeId nodeid,
              const UA_Variant *data, const UA_NumericRange *range) {
              const UA_Variant *data, const UA_NumericRange *range) {
     if(UA_Variant_isScalar(data) && data->type == &UA_TYPES[UA_TYPES_INT32] && data->data){
     if(UA_Variant_isScalar(data) && data->type == &UA_TYPES[UA_TYPES_INT32] && data->data){
-        *(UA_UInt32*)handle = *(UA_Int32*)data->data;
+        *(UA_UInt32*)handle = *(UA_UInt32*)data->data;
     }
     }
     // we know the nodeid is a string
     // we know the nodeid is a string
     UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Node written %.*s",
     UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Node written %.*s",
@@ -53,7 +53,7 @@ int main(int argc, char** argv) {
     signal(SIGINT, stopHandler); /* catches ctrl-c */
     signal(SIGINT, stopHandler); /* catches ctrl-c */
 
 
     UA_ServerConfig config = UA_ServerConfig_standard;
     UA_ServerConfig config = UA_ServerConfig_standard;
-    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664, logger);
+    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664);
     config.logger = Logger_Stdout;
     config.logger = Logger_Stdout;
     config.networkLayers = &nl;
     config.networkLayers = &nl;
     config.networkLayersSize = 1;
     config.networkLayersSize = 1;

+ 2 - 2
examples/server_firstSteps.c

@@ -14,7 +14,7 @@
 #endif
 #endif
 
 
 UA_Boolean running = UA_TRUE;
 UA_Boolean running = UA_TRUE;
-static void stopHandler(int signal) {
+static void stopHandler(int sig) {
     running = UA_FALSE;
     running = UA_FALSE;
 }
 }
 
 
@@ -23,7 +23,7 @@ int main(void) {
     signal(SIGTERM, stopHandler);
     signal(SIGTERM, stopHandler);
 
 
     UA_ServerConfig config = UA_ServerConfig_standard;
     UA_ServerConfig config = UA_ServerConfig_standard;
-    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664, Logger_Stdout);
+    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664);
     config.logger = Logger_Stdout;
     config.logger = Logger_Stdout;
     config.networkLayers = &nl;
     config.networkLayers = &nl;
     config.networkLayersSize = 1;
     config.networkLayersSize = 1;

+ 1 - 1
examples/server_method.c

@@ -54,7 +54,7 @@ int main(int argc, char** argv) {
 
 
     /* initialize the server */
     /* initialize the server */
     UA_ServerConfig config = UA_ServerConfig_standard;
     UA_ServerConfig config = UA_ServerConfig_standard;
-    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664, logger);
+    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664);
     config.logger = Logger_Stdout;
     config.logger = Logger_Stdout;
     config.networkLayers = &nl;
     config.networkLayers = &nl;
     config.networkLayersSize = 1;
     config.networkLayersSize = 1;

+ 1 - 1
examples/server_nodeset.c

@@ -31,7 +31,7 @@ int main(int argc, char** argv) {
 
 
     /* initialize the server */
     /* initialize the server */
     UA_ServerConfig config = UA_ServerConfig_standard;
     UA_ServerConfig config = UA_ServerConfig_standard;
-    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664, logger);
+    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664);
     config.logger = Logger_Stdout;
     config.logger = Logger_Stdout;
     config.networkLayers = &nl;
     config.networkLayers = &nl;
     config.networkLayersSize = 1;
     config.networkLayersSize = 1;

+ 1 - 1
examples/server_repeated_job.c

@@ -30,7 +30,7 @@ int main(int argc, char** argv) {
     signal(SIGINT, stopHandler); /* catches ctrl-c */
     signal(SIGINT, stopHandler); /* catches ctrl-c */
 
 
     UA_ServerConfig config = UA_ServerConfig_standard;
     UA_ServerConfig config = UA_ServerConfig_standard;
-    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664, logger);
+    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664);
     config.logger = Logger_Stdout;
     config.logger = Logger_Stdout;
     config.networkLayers = &nl;
     config.networkLayers = &nl;
     config.networkLayersSize = 1;
     config.networkLayersSize = 1;

+ 1 - 1
examples/server_variable.c

@@ -37,7 +37,7 @@ int main(int argc, char** argv) {
     signal(SIGINT, stopHandler); /* catches ctrl-c */
     signal(SIGINT, stopHandler); /* catches ctrl-c */
 
 
     UA_ServerConfig config = UA_ServerConfig_standard;
     UA_ServerConfig config = UA_ServerConfig_standard;
-    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664, logger);
+    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664);
     config.logger = Logger_Stdout;
     config.logger = Logger_Stdout;
     config.networkLayers = &nl;
     config.networkLayers = &nl;
     config.networkLayersSize = 1;
     config.networkLayersSize = 1;

+ 2 - 2
include/ua_client.h

@@ -15,8 +15,8 @@ struct UA_Client;
 typedef struct UA_Client UA_Client;
 typedef struct UA_Client UA_Client;
 
 
 typedef struct UA_ClientConfig {
 typedef struct UA_ClientConfig {
-    UA_Int32 timeout; //sync response timeout
-    UA_Int32 secureChannelLifeTime; // lifetime in ms (then the channel needs to be renewed)
+    UA_UInt32 timeout; //sync response timeout
+    UA_UInt32 secureChannelLifeTime; // lifetime in ms (then the channel needs to be renewed)
     UA_ConnectionConfig localConnectionConfig;
     UA_ConnectionConfig localConnectionConfig;
 } UA_ClientConfig;
 } UA_ClientConfig;
 
 

+ 1 - 1
include/ua_client_highlevel.h

@@ -249,7 +249,7 @@ UA_Client_readUserExecutableAttribute(UA_Client *client, UA_NodeId nodeId, UA_Bo
 
 
 UA_StatusCode UA_EXPORT
 UA_StatusCode UA_EXPORT
 UA_Client_call(UA_Client *client, const UA_NodeId objectId, const UA_NodeId methodId,
 UA_Client_call(UA_Client *client, const UA_NodeId objectId, const UA_NodeId methodId,
-               UA_Int32 inputSize, const UA_Variant *input, UA_Int32 *outputSize, UA_Variant **output);
+               size_t inputSize, const UA_Variant *input, size_t *outputSize, UA_Variant **output);
 
 
 /**************************/
 /**************************/
 /* Subscriptions Handling */
 /* Subscriptions Handling */

+ 3 - 3
include/ua_server.h

@@ -125,7 +125,7 @@ struct UA_ServerNetworkLayer {
      * @param logger The logger
      * @param logger The logger
      * @return Returns UA_STATUSCODE_GOOD or an error code.
      * @return Returns UA_STATUSCODE_GOOD or an error code.
      */
      */
-    UA_StatusCode (*start)(UA_ServerNetworkLayer *nl);
+    UA_StatusCode (*start)(UA_ServerNetworkLayer *nl, UA_Logger logger);
     
     
     /**
     /**
      * Gets called from the main server loop and returns the jobs (accumulated messages and close
      * Gets called from the main server loop and returns the jobs (accumulated messages and close
@@ -345,8 +345,8 @@ UA_Server_addMethodNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
                         const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
                         const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
                         const UA_QualifiedName browseName, const UA_MethodAttributes attr,
                         const UA_QualifiedName browseName, const UA_MethodAttributes attr,
                         UA_MethodCallback method, void *handle,
                         UA_MethodCallback method, void *handle,
-                        UA_Int32 inputArgumentsSize, const UA_Argument* inputArguments, 
-                        UA_Int32 outputArgumentsSize, const UA_Argument* outputArguments,
+                        size_t inputArgumentsSize, const UA_Argument* inputArguments, 
+                        size_t outputArgumentsSize, const UA_Argument* outputArguments,
                         UA_NodeId *outNewNodeId);
                         UA_NodeId *outNewNodeId);
 #endif
 #endif
 
 

+ 5 - 5
include/ua_types.h

@@ -35,7 +35,7 @@ extern "C" {
 /* Builtin Type Definitions */
 /* Builtin Type Definitions */
 /****************************/
 /****************************/
 
 
-#define UA_BUILTIN_TYPES_COUNT 25
+#define UA_BUILTIN_TYPES_COUNT 25U
 
 
 /** Boolean: A two-state logical value (true or false) */
 /** Boolean: A two-state logical value (true or false) */
 typedef bool UA_Boolean;
 typedef bool UA_Boolean;
@@ -146,9 +146,9 @@ typedef struct UA_DateTimeStruct {
     UA_UInt16 year;
     UA_UInt16 year;
 } UA_DateTimeStruct;
 } UA_DateTimeStruct;
 
 
-UA_DateTimeStruct UA_EXPORT UA_DateTime_toStruct(UA_DateTime time);
+UA_DateTimeStruct UA_EXPORT UA_DateTime_toStruct(UA_DateTime t);
 
 
-UA_String UA_EXPORT UA_DateTime_toString(UA_DateTime time);
+UA_String UA_EXPORT UA_DateTime_toString(UA_DateTime t);
 
 
 /**************************************************************************/
 /**************************************************************************/
 /* Guid: A 16 byte value that can be used as a globally unique identifier */
 /* Guid: A 16 byte value that can be used as a globally unique identifier */
@@ -222,7 +222,7 @@ static UA_INLINE UA_Boolean UA_NodeId_isNull(const UA_NodeId *p) {
 
 
 UA_Boolean UA_EXPORT UA_NodeId_equal(const UA_NodeId *n1, const UA_NodeId *n2);
 UA_Boolean UA_EXPORT UA_NodeId_equal(const UA_NodeId *n1, const UA_NodeId *n2);
 
 
-static UA_INLINE UA_NodeId UA_NODEID_NUMERIC(UA_UInt16 nsIndex, UA_Int32 identifier) {
+static UA_INLINE UA_NodeId UA_NODEID_NUMERIC(UA_UInt16 nsIndex, UA_UInt32 identifier) {
     UA_NodeId id; id.namespaceIndex = nsIndex; id.identifierType = UA_NODEIDTYPE_NUMERIC;
     UA_NodeId id; id.namespaceIndex = nsIndex; id.identifierType = UA_NODEIDTYPE_NUMERIC;
     id.identifier.numeric = identifier; return id; }
     id.identifier.numeric = identifier; return id; }
 
 
@@ -255,7 +255,7 @@ typedef struct {
     UA_UInt32 serverIndex;
     UA_UInt32 serverIndex;
 } UA_ExpandedNodeId;
 } UA_ExpandedNodeId;
 
 
-static UA_INLINE UA_ExpandedNodeId UA_EXPANDEDNODEID_NUMERIC(UA_UInt16 nsIndex, UA_Int32 identifier) {
+static UA_INLINE UA_ExpandedNodeId UA_EXPANDEDNODEID_NUMERIC(UA_UInt16 nsIndex, UA_UInt32 identifier) {
     UA_ExpandedNodeId id; id.nodeId = UA_NODEID_NUMERIC(nsIndex, identifier);
     UA_ExpandedNodeId id; id.nodeId = UA_NODEID_NUMERIC(nsIndex, identifier);
     id.serverIndex = 0; id.namespaceUri = UA_STRING_NULL; return id; }
     id.serverIndex = 0; id.namespaceUri = UA_STRING_NULL; return id; }
 
 

+ 4 - 4
src/client/ua_client.c

@@ -113,7 +113,7 @@ static UA_StatusCode HelAckHandshake(UA_Client *c) {
 
 
     size_t offset = 8;
     size_t offset = 8;
     retval |= UA_TcpHelloMessage_encodeBinary(&hello, &message, &offset);
     retval |= UA_TcpHelloMessage_encodeBinary(&hello, &message, &offset);
-    messageHeader.messageSize = offset;
+    messageHeader.messageSize = (UA_UInt32)offset;
     offset = 0;
     offset = 0;
     retval |= UA_TcpMessageHeader_encodeBinary(&messageHeader, &message, &offset);
     retval |= UA_TcpMessageHeader_encodeBinary(&messageHeader, &message, &offset);
     UA_TcpHelloMessage_deleteMembers(&hello);
     UA_TcpHelloMessage_deleteMembers(&hello);
@@ -223,7 +223,7 @@ static UA_StatusCode SecureChannelHandshake(UA_Client *client, UA_Boolean renew)
     retval |= UA_SequenceHeader_encodeBinary(&seqHeader, &message, &offset);
     retval |= UA_SequenceHeader_encodeBinary(&seqHeader, &message, &offset);
     retval |= UA_NodeId_encodeBinary(&requestType, &message, &offset);
     retval |= UA_NodeId_encodeBinary(&requestType, &message, &offset);
     retval |= UA_OpenSecureChannelRequest_encodeBinary(&opnSecRq, &message, &offset);
     retval |= UA_OpenSecureChannelRequest_encodeBinary(&opnSecRq, &message, &offset);
-    messageHeader.messageHeader.messageSize = offset;
+    messageHeader.messageHeader.messageSize = (UA_UInt32)offset;
     offset = 0;
     offset = 0;
     retval |= UA_SecureConversationMessageHeader_encodeBinary(&messageHeader, &message, &offset);
     retval |= UA_SecureConversationMessageHeader_encodeBinary(&messageHeader, &message, &offset);
 
 
@@ -287,7 +287,7 @@ static UA_StatusCode SecureChannelHandshake(UA_Client *client, UA_Boolean renew)
 
 
     //response.securityToken.revisedLifetime is UInt32 we need to cast it to DateTime=Int64
     //response.securityToken.revisedLifetime is UInt32 we need to cast it to DateTime=Int64
     //we take 75% of lifetime to start renewing as described in standard
     //we take 75% of lifetime to start renewing as described in standard
-    client->scRenewAt = UA_DateTime_now() + (UA_DateTime)response.securityToken.revisedLifetime * 10000 * 0.75;
+    client->scRenewAt = UA_DateTime_now() + (UA_DateTime)(response.securityToken.revisedLifetime * (UA_Double)UA_MSEC_TO_DATETIME * 0.75);
     retval = response.responseHeader.serviceResult;
     retval = response.responseHeader.serviceResult;
 
 
     if(retval != UA_STATUSCODE_GOOD)
     if(retval != UA_STATUSCODE_GOOD)
@@ -462,7 +462,7 @@ static UA_StatusCode CloseSecureChannel(UA_Client *client) {
     retval |= UA_NodeId_encodeBinary(&typeId, &message, &offset);
     retval |= UA_NodeId_encodeBinary(&typeId, &message, &offset);
     retval |= UA_encodeBinary(&request, &UA_TYPES[UA_TYPES_CLOSESECURECHANNELREQUEST], &message, &offset);
     retval |= UA_encodeBinary(&request, &UA_TYPES[UA_TYPES_CLOSESECURECHANNELREQUEST], &message, &offset);
 
 
-    msgHeader.messageHeader.messageSize = offset;
+    msgHeader.messageHeader.messageSize = (UA_UInt32)offset;
     offset = 0;
     offset = 0;
     retval |= UA_SecureConversationMessageHeader_encodeBinary(&msgHeader, &message, &offset);
     retval |= UA_SecureConversationMessageHeader_encodeBinary(&msgHeader, &message, &offset);
 
 

+ 3 - 3
src/client/ua_client_highlevel.c

@@ -33,7 +33,7 @@ UA_Client_NamespaceGetIndex(UA_Client *client, UA_String *namespaceUri, UA_UInt1
     UA_String *ns = response.results[0].value.data;
     UA_String *ns = response.results[0].value.data;
     for(size_t i = 0; i < response.results[0].value.arrayLength; i++){
     for(size_t i = 0; i < response.results[0].value.arrayLength; i++){
         if(UA_String_equal(namespaceUri, &ns[i])) {
         if(UA_String_equal(namespaceUri, &ns[i])) {
-            *namespaceIndex = i;
+            *namespaceIndex = (UA_UInt16)i;
             retval = UA_STATUSCODE_GOOD;
             retval = UA_STATUSCODE_GOOD;
             break;
             break;
         }
         }
@@ -178,8 +178,8 @@ __UA_Client_addNode(UA_Client *client, const UA_NodeClass nodeClass, const UA_No
 /********/
 /********/
 
 
 UA_StatusCode
 UA_StatusCode
-UA_Client_call(UA_Client *client, const UA_NodeId objectId, const UA_NodeId methodId, UA_Int32 inputSize,
-               const UA_Variant *input, UA_Int32 *outputSize, UA_Variant **output) {
+UA_Client_call(UA_Client *client, const UA_NodeId objectId, const UA_NodeId methodId, size_t inputSize,
+               const UA_Variant *input, size_t *outputSize, UA_Variant **output) {
     UA_CallRequest request;
     UA_CallRequest request;
     UA_CallRequest_init(&request);
     UA_CallRequest_init(&request);
     UA_CallMethodRequest item;
     UA_CallMethodRequest item;

+ 2 - 2
src/client/ua_client_highlevel_subscriptions.c

@@ -230,8 +230,8 @@ UA_Client_processPublishRx(UA_Client *client, UA_PublishResponse response) {
         if(msg.notificationData[k].content.decoded.type == &UA_TYPES[UA_TYPES_DATACHANGENOTIFICATION]) {
         if(msg.notificationData[k].content.decoded.type == &UA_TYPES[UA_TYPES_DATACHANGENOTIFICATION]) {
             // This is a dataChangeNotification
             // This is a dataChangeNotification
             UA_DataChangeNotification *dataChangeNotification = msg.notificationData[k].content.decoded.data;
             UA_DataChangeNotification *dataChangeNotification = msg.notificationData[k].content.decoded.data;
-            for(size_t i = 0; i < dataChangeNotification->monitoredItemsSize; i++) {
-            UA_MonitoredItemNotification *mitemNot = &dataChangeNotification->monitoredItems[i];
+            for(size_t j = 0; j < dataChangeNotification->monitoredItemsSize; j++) {
+            UA_MonitoredItemNotification *mitemNot = &dataChangeNotification->monitoredItems[j];
                 // find this client handle
                 // find this client handle
                 LIST_FOREACH(mon, &sub->MonitoredItems, listEntry) {
                 LIST_FOREACH(mon, &sub->MonitoredItems, listEntry) {
                     if(mon->ClientHandle == mitemNot->clientHandle) {
                     if(mon->ClientHandle == mitemNot->clientHandle) {

+ 17 - 17
src/client/ua_client_internal.h

@@ -16,26 +16,26 @@ typedef struct UA_Client_NotificationsAckNumber_s {
 } UA_Client_NotificationsAckNumber;
 } UA_Client_NotificationsAckNumber;
 
 
 typedef struct UA_Client_MonitoredItem_s {
 typedef struct UA_Client_MonitoredItem_s {
-    UA_UInt32          MonitoredItemId;
-    UA_UInt32          MonitoringMode;
-    UA_NodeId          monitoredNodeId;
-    UA_UInt32          AttributeID;
-    UA_UInt32          ClientHandle;
-    UA_UInt32          SamplingInterval;
-    UA_UInt32          QueueSize;
-    UA_Boolean         DiscardOldest;
-    void               (*handler)(UA_UInt32 handle, UA_DataValue *value, void *context);
-    void               *handlerContext;
+    UA_UInt32  MonitoredItemId;
+    UA_UInt32  MonitoringMode;
+    UA_NodeId  monitoredNodeId;
+    UA_UInt32  AttributeID;
+    UA_UInt32  ClientHandle;
+    UA_Double  SamplingInterval;
+    UA_UInt32  QueueSize;
+    UA_Boolean DiscardOldest;
+    void       (*handler)(UA_UInt32 handle, UA_DataValue *value, void *context);
+    void       *handlerContext;
     LIST_ENTRY(UA_Client_MonitoredItem_s)  listEntry;
     LIST_ENTRY(UA_Client_MonitoredItem_s)  listEntry;
 } UA_Client_MonitoredItem;
 } UA_Client_MonitoredItem;
 
 
 typedef struct UA_Client_Subscription_s {
 typedef struct UA_Client_Subscription_s {
-    UA_UInt32    LifeTime;
-    UA_Int32     KeepAliveCount;
-    UA_DateTime  PublishingInterval;
-    UA_UInt32    SubscriptionID;
-    UA_Int32     NotificationsPerPublish;
-    UA_UInt32    Priority;
+    UA_UInt32 LifeTime;
+    UA_UInt32 KeepAliveCount;
+    UA_Double PublishingInterval;
+    UA_UInt32 SubscriptionID;
+    UA_UInt32 NotificationsPerPublish;
+    UA_UInt32 Priority;
     LIST_ENTRY(UA_Client_Subscription_s) listEntry;
     LIST_ENTRY(UA_Client_Subscription_s) listEntry;
     LIST_HEAD(UA_ListOfClientMonitoredItems, UA_Client_MonitoredItem_s) MonitoredItems;
     LIST_HEAD(UA_ListOfClientMonitoredItems, UA_Client_MonitoredItem_s) MonitoredItems;
 } UA_Client_Subscription;
 } UA_Client_Subscription;
@@ -69,7 +69,7 @@ struct UA_Client {
     UA_UInt32 requestHandle;
     UA_UInt32 requestHandle;
     
     
 #ifdef UA_ENABLE_SUBSCRIPTIONS
 #ifdef UA_ENABLE_SUBSCRIPTIONS
-    UA_Int32 monitoredItemHandles;
+    UA_UInt32 monitoredItemHandles;
     LIST_HEAD(UA_ListOfUnacknowledgedNotificationNumbers, UA_Client_NotificationsAckNumber_s) pendingNotificationsAcks;
     LIST_HEAD(UA_ListOfUnacknowledgedNotificationNumbers, UA_Client_NotificationsAckNumber_s) pendingNotificationsAcks;
     LIST_HEAD(UA_ListOfClientSubscriptionItems, UA_Client_Subscription_s) subscriptions;
     LIST_HEAD(UA_ListOfClientSubscriptionItems, UA_Client_Subscription_s) subscriptions;
 #endif
 #endif

+ 17 - 17
src/server/ua_nodestore.c

@@ -29,13 +29,13 @@ static hash_t const primes[] = {
     134217689, 268435399,  536870909,  1073741789, 2147483647,  4294967291
     134217689, 268435399,  536870909,  1073741789, 2147483647,  4294967291
 };
 };
 
 
-static UA_Int16 higher_prime_index(hash_t n) {
+static UA_UInt16 higher_prime_index(hash_t n) {
     UA_UInt16 low  = 0;
     UA_UInt16 low  = 0;
-    UA_UInt16 high = sizeof(primes) / sizeof(hash_t);
+    UA_UInt16 high = (UA_UInt16)(sizeof(primes) / sizeof(hash_t));
     while(low != high) {
     while(low != high) {
-        UA_UInt16 mid = low + (high - low) / 2;
+        UA_UInt16 mid = (UA_UInt16)(low + ((high - low) / 2));
         if(n > primes[mid])
         if(n > primes[mid])
-            low = mid + 1;
+            low = (UA_UInt16)(mid + 1);
         else
         else
             high = mid;
             high = mid;
     }
     }
@@ -90,31 +90,31 @@ static UA_Boolean
 containsNodeId(const UA_NodeStore *ns, const UA_NodeId *nodeid, UA_NodeStoreEntry ***entry) {
 containsNodeId(const UA_NodeStore *ns, const UA_NodeId *nodeid, UA_NodeStoreEntry ***entry) {
     hash_t h = hash(nodeid);
     hash_t h = hash(nodeid);
     UA_UInt32 size = ns->size;
     UA_UInt32 size = ns->size;
-    hash_t index = mod(h, size);
-    UA_NodeStoreEntry *e = ns->entries[index];
+    hash_t idx = mod(h, size);
+    UA_NodeStoreEntry *e = ns->entries[idx];
 
 
     if(!e) {
     if(!e) {
-        *entry = &ns->entries[index];
+        *entry = &ns->entries[idx];
         return UA_FALSE;
         return UA_FALSE;
     }
     }
 
 
     if(UA_NodeId_equal(&e->node.nodeId, nodeid)) {
     if(UA_NodeId_equal(&e->node.nodeId, nodeid)) {
-        *entry = &ns->entries[index];
+        *entry = &ns->entries[idx];
         return UA_TRUE;
         return UA_TRUE;
     }
     }
 
 
     hash_t hash2 = mod2(h, size);
     hash_t hash2 = mod2(h, size);
     for(;;) {
     for(;;) {
-        index += hash2;
-        if(index >= size)
-            index -= size;
-        e = ns->entries[index];
+        idx += hash2;
+        if(idx >= size)
+            idx -= size;
+        e = ns->entries[idx];
         if(!e) {
         if(!e) {
-            *entry = &ns->entries[index];
+            *entry = &ns->entries[idx];
             return UA_FALSE;
             return UA_FALSE;
         }
         }
         if(UA_NodeId_equal(&e->node.nodeId, nodeid)) {
         if(UA_NodeId_equal(&e->node.nodeId, nodeid)) {
-            *entry = &ns->entries[index];
+            *entry = &ns->entries[idx];
             return UA_TRUE;
             return UA_TRUE;
         }
         }
     }
     }
@@ -133,7 +133,7 @@ static UA_StatusCode expand(UA_NodeStore *ns) {
 
 
     UA_NodeStoreEntry **oentries = ns->entries;
     UA_NodeStoreEntry **oentries = ns->entries;
     UA_UInt32 nindex = higher_prime_index(count * 2);
     UA_UInt32 nindex = higher_prime_index(count * 2);
-    UA_Int32 nsize = primes[nindex];
+    UA_UInt32 nsize = primes[nindex];
     UA_NodeStoreEntry **nentries;
     UA_NodeStoreEntry **nentries;
     if(!(nentries = UA_calloc(nsize, sizeof(UA_NodeStoreEntry*))))
     if(!(nentries = UA_calloc(nsize, sizeof(UA_NodeStoreEntry*))))
         return UA_STATUSCODE_BADOUTOFMEMORY;
         return UA_STATUSCODE_BADOUTOFMEMORY;
@@ -210,8 +210,8 @@ UA_StatusCode UA_NodeStore_insert(UA_NodeStore *ns, UA_Node *node) {
         if(node->nodeId.namespaceIndex == 0)
         if(node->nodeId.namespaceIndex == 0)
             node->nodeId.namespaceIndex = 1;
             node->nodeId.namespaceIndex = 1;
         /* find a free nodeid */
         /* find a free nodeid */
-        UA_Int32 identifier = ns->count+1; // start value
-        UA_Int32 size = ns->size;
+        UA_UInt32 identifier = ns->count+1; // start value
+        UA_UInt32 size = ns->size;
         hash_t increase = mod2(identifier, size);
         hash_t increase = mod2(identifier, size);
         while(UA_TRUE) {
         while(UA_TRUE) {
             node->nodeId.identifier.numeric = identifier;
             node->nodeId.identifier.numeric = identifier;

+ 2 - 2
src/server/ua_nodestore_concurrent.c

@@ -128,13 +128,13 @@ UA_StatusCode UA_NodeStore_insert(UA_NodeStore *ns, UA_Node *node) {
         cds_lfht_count_nodes(ht, &before, &identifier, &after); // current amount of nodes stored
         cds_lfht_count_nodes(ht, &before, &identifier, &after); // current amount of nodes stored
         identifier++;
         identifier++;
 
 
-        node->nodeId.identifier.numeric = identifier;
+        node->nodeId.identifier.numeric = (UA_UInt32)identifier;
         while(UA_TRUE) {
         while(UA_TRUE) {
             hash_t h = hash(&node->nodeId);
             hash_t h = hash(&node->nodeId);
             result = cds_lfht_add_unique(ht, h, compare, &node->nodeId, &entry->htn);
             result = cds_lfht_add_unique(ht, h, compare, &node->nodeId, &entry->htn);
             if(result == &entry->htn)
             if(result == &entry->htn)
                 break;
                 break;
-            node->nodeId.identifier.numeric += (identifier * 2654435761);
+            node->nodeId.identifier.numeric += (UA_UInt32)(identifier * 2654435761);
         }
         }
     }
     }
     return UA_STATUSCODE_GOOD;
     return UA_STATUSCODE_GOOD;

+ 10 - 8
src/server/ua_nodestore_hash.inc

@@ -8,7 +8,7 @@ static hash_t hash_array(const UA_Byte *data, UA_UInt32 len, UA_UInt32 seed) {
     if(data == NULL)
     if(data == NULL)
         return 0;
         return 0;
 
 
-    const int32_t   nblocks = len / 4;
+    const int32_t nblocks = (int32_t)(len / 4);
     const uint32_t *blocks;
     const uint32_t *blocks;
     static const uint32_t c1 = 0xcc9e2d51;
     static const uint32_t c1 = 0xcc9e2d51;
     static const uint32_t c2 = 0x1b873593;
     static const uint32_t c2 = 0x1b873593;
@@ -36,12 +36,12 @@ static hash_t hash_array(const UA_Byte *data, UA_UInt32 len, UA_UInt32 seed) {
     }
     }
 
 
     const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
     const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
-    uint32_t       k1   = 0;
+    uint32_t k1 = 0;
     switch(len & 3) {
     switch(len & 3) {
     case 3:
     case 3:
-        k1 ^= tail[2] << 16;
+        k1 ^= (uint32_t)(tail[2] << 16);
     case 2:
     case 2:
-        k1 ^= tail[1] << 8;
+        k1 ^= (uint32_t)(tail[1] << 8);
     case 1:
     case 1:
         k1   ^= tail[0];
         k1   ^= tail[0];
         k1   *= c1;
         k1   *= c1;
@@ -63,13 +63,15 @@ static hash_t hash(const UA_NodeId *n) {
     switch(n->identifierType) {
     switch(n->identifierType) {
     case UA_NODEIDTYPE_NUMERIC:
     case UA_NODEIDTYPE_NUMERIC:
         /*  Knuth's multiplicative hashing */
         /*  Knuth's multiplicative hashing */
-        return (n->identifier.numeric + n->namespaceIndex) * 2654435761;   // mod(2^32) is implicit
+        return (hash_t)((n->identifier.numeric + n->namespaceIndex) * 2654435761); // mod(2^32) is implicit
     case UA_NODEIDTYPE_STRING:
     case UA_NODEIDTYPE_STRING:
-        return hash_array(n->identifier.string.data, n->identifier.string.length, n->namespaceIndex);
+        return hash_array(n->identifier.string.data, (UA_UInt32)n->identifier.string.length,
+                          n->namespaceIndex);
     case UA_NODEIDTYPE_GUID:
     case UA_NODEIDTYPE_GUID:
-        return hash_array((const UA_Byte *)&(n->identifier.guid), sizeof(UA_Guid), n->namespaceIndex);
+        return hash_array((const UA_Byte*)&(n->identifier.guid), sizeof(UA_Guid), n->namespaceIndex);
     case UA_NODEIDTYPE_BYTESTRING:
     case UA_NODEIDTYPE_BYTESTRING:
-        return hash_array((const UA_Byte *)n->identifier.byteString.data, n->identifier.byteString.length, n->namespaceIndex);
+        return hash_array((const UA_Byte*)n->identifier.byteString.data,
+                          (UA_UInt32)n->identifier.byteString.length, n->namespaceIndex);
     default:
     default:
         UA_assert(UA_FALSE);
         UA_assert(UA_FALSE);
         return 0;
         return 0;

+ 4 - 4
src/server/ua_securechannel_manager.h

@@ -13,13 +13,13 @@ typedef struct channel_list_entry {
 
 
 typedef struct UA_SecureChannelManager {
 typedef struct UA_SecureChannelManager {
     LIST_HEAD(channel_list, channel_list_entry) channels; // doubly-linked list of channels
     LIST_HEAD(channel_list, channel_list_entry) channels; // doubly-linked list of channels
-    size_t    maxChannelCount;
+    size_t maxChannelCount;
     size_t currentChannelCount;
     size_t currentChannelCount;
-    UA_DateTime maxChannelLifetime;
+    UA_UInt32 maxChannelLifetime;
     UA_MessageSecurityMode securityMode;
     UA_MessageSecurityMode securityMode;
     UA_DateTime channelLifeTime;
     UA_DateTime channelLifeTime;
-    UA_Int32    lastChannelId;
-    UA_UInt32   lastTokenId;
+    UA_UInt32 lastChannelId;
+    UA_UInt32 lastTokenId;
 } UA_SecureChannelManager;
 } UA_SecureChannelManager;
 
 
 UA_StatusCode
 UA_StatusCode

+ 12 - 11
src/server/ua_server.c

@@ -133,7 +133,7 @@ UA_UInt16 UA_Server_addNamespace(UA_Server *server, const char* name) {
                                     sizeof(UA_String) * (server->namespacesSize+1));
                                     sizeof(UA_String) * (server->namespacesSize+1));
     server->namespaces[server->namespacesSize] = UA_STRING_ALLOC(name);
     server->namespaces[server->namespacesSize] = UA_STRING_ALLOC(name);
     server->namespacesSize++;
     server->namespacesSize++;
-    return (UA_UInt16)server->namespacesSize - 1;
+    return (UA_UInt16)(server->namespacesSize - 1);
 }
 }
 
 
 UA_StatusCode
 UA_StatusCode
@@ -365,7 +365,7 @@ static void copyNames(UA_Node *node, char *name) {
 }
 }
 
 
 static void
 static void
-addDataTypeNode(UA_Server *server, char* name, UA_UInt32 datatypeid, UA_Int32 parent) {
+addDataTypeNode(UA_Server *server, char* name, UA_UInt32 datatypeid, UA_UInt32 parent) {
     UA_DataTypeNode *datatype = UA_NodeStore_newDataTypeNode();
     UA_DataTypeNode *datatype = UA_NodeStore_newDataTypeNode();
     copyNames((UA_Node*)datatype, name);
     copyNames((UA_Node*)datatype, name);
     datatype->nodeId.identifier.numeric = datatypeid;
     datatype->nodeId.identifier.numeric = datatypeid;
@@ -374,7 +374,7 @@ addDataTypeNode(UA_Server *server, char* name, UA_UInt32 datatypeid, UA_Int32 pa
 
 
 static void
 static void
 addObjectTypeNode(UA_Server *server, char* name, UA_UInt32 objecttypeid,
 addObjectTypeNode(UA_Server *server, char* name, UA_UInt32 objecttypeid,
-                  UA_Int32 parent, UA_Int32 parentreference) {
+                  UA_UInt32 parent, UA_UInt32 parentreference) {
     UA_ObjectTypeNode *objecttype = UA_NodeStore_newObjectTypeNode();
     UA_ObjectTypeNode *objecttype = UA_NodeStore_newObjectTypeNode();
     copyNames((UA_Node*)objecttype, name);
     copyNames((UA_Node*)objecttype, name);
     objecttype->nodeId.identifier.numeric = objecttypeid;
     objecttype->nodeId.identifier.numeric = objecttypeid;
@@ -384,7 +384,7 @@ addObjectTypeNode(UA_Server *server, char* name, UA_UInt32 objecttypeid,
 
 
 static UA_VariableTypeNode*
 static UA_VariableTypeNode*
 createVariableTypeNode(UA_Server *server, char* name, UA_UInt32 variabletypeid,
 createVariableTypeNode(UA_Server *server, char* name, UA_UInt32 variabletypeid,
-                       UA_Int32 parent, UA_Boolean abstract) {
+                       UA_UInt32 parent, UA_Boolean abstract) {
     UA_VariableTypeNode *variabletype = UA_NodeStore_newVariableTypeNode();
     UA_VariableTypeNode *variabletype = UA_NodeStore_newVariableTypeNode();
     copyNames((UA_Node*)variabletype, name);
     copyNames((UA_Node*)variabletype, name);
     variabletype->nodeId.identifier.numeric = variabletypeid;
     variabletype->nodeId.identifier.numeric = variabletypeid;
@@ -395,14 +395,14 @@ createVariableTypeNode(UA_Server *server, char* name, UA_UInt32 variabletypeid,
 
 
 static void
 static void
 addVariableTypeNode_organized(UA_Server *server, char* name, UA_UInt32 variabletypeid,
 addVariableTypeNode_organized(UA_Server *server, char* name, UA_UInt32 variabletypeid,
-                              UA_Int32 parent, UA_Boolean abstract) {
+                              UA_UInt32 parent, UA_Boolean abstract) {
     UA_VariableTypeNode *variabletype = createVariableTypeNode(server, name, variabletypeid, parent, abstract);
     UA_VariableTypeNode *variabletype = createVariableTypeNode(server, name, variabletypeid, parent, abstract);
     addNodeInternal(server, (UA_Node*)variabletype, UA_NODEID_NUMERIC(0, parent), nodeIdOrganizes);
     addNodeInternal(server, (UA_Node*)variabletype, UA_NODEID_NUMERIC(0, parent), nodeIdOrganizes);
 }
 }
 
 
 static void
 static void
 addVariableTypeNode_subtype(UA_Server *server, char* name, UA_UInt32 variabletypeid,
 addVariableTypeNode_subtype(UA_Server *server, char* name, UA_UInt32 variabletypeid,
-                            UA_Int32 parent, UA_Boolean abstract) {
+                            UA_UInt32 parent, UA_Boolean abstract) {
     UA_VariableTypeNode *variabletype =
     UA_VariableTypeNode *variabletype =
         createVariableTypeNode(server, name, variabletypeid, parent, abstract);
         createVariableTypeNode(server, name, variabletypeid, parent, abstract);
     addNodeInternal(server, (UA_Node*)variabletype, UA_NODEID_NUMERIC(0, parent), nodeIdHasSubType);
     addNodeInternal(server, (UA_Node*)variabletype, UA_NODEID_NUMERIC(0, parent), nodeIdHasSubType);
@@ -467,10 +467,11 @@ UA_Server * UA_Server_new(const UA_ServerConfig config) {
         /* The standard says "the HostName specified in the Server Certificate is the
         /* The standard says "the HostName specified in the Server Certificate is the
            same as the HostName contained in the endpointUrl provided in the
            same as the HostName contained in the endpointUrl provided in the
            EndpointDescription */
            EndpointDescription */
-        UA_String_copy(&server->config.networkLayers[i].discoveryUrl, &endpoint->endpointUrl);
         UA_String_copy(&server->config.serverCertificate, &endpoint->serverCertificate);
         UA_String_copy(&server->config.serverCertificate, &endpoint->serverCertificate);
-
         UA_ApplicationDescription_copy(&server->config.applicationDescription, &endpoint->server);
         UA_ApplicationDescription_copy(&server->config.applicationDescription, &endpoint->server);
+        
+        /* copy the discovery url only once the networlayer has been started */
+        // UA_String_copy(&server->config.networkLayers[i].discoveryUrl, &endpoint->endpointUrl);
     } 
     } 
 
 
 #define MAXCHANNELCOUNT 100
 #define MAXCHANNELCOUNT 100
@@ -1104,7 +1105,7 @@ UA_Server * UA_Server_new(const UA_ServerConfig config) {
 
 
 UA_StatusCode
 UA_StatusCode
 __UA_Server_write(UA_Server *server, const UA_NodeId *nodeId,
 __UA_Server_write(UA_Server *server, const UA_NodeId *nodeId,
-                  const UA_AttributeId attributeId, const UA_DataType *type,
+                  const UA_AttributeId attributeId, const UA_DataType *attr_type,
                   const void *value) {
                   const void *value) {
     UA_WriteValue wvalue;
     UA_WriteValue wvalue;
     UA_WriteValue_init(&wvalue);
     UA_WriteValue_init(&wvalue);
@@ -1112,9 +1113,9 @@ __UA_Server_write(UA_Server *server, const UA_NodeId *nodeId,
     wvalue.attributeId = attributeId;
     wvalue.attributeId = attributeId;
     if(attributeId != UA_ATTRIBUTEID_VALUE)
     if(attributeId != UA_ATTRIBUTEID_VALUE)
         /* hacked cast. the target WriteValue is used as const anyway */
         /* hacked cast. the target WriteValue is used as const anyway */
-        UA_Variant_setScalar(&wvalue.value.value, (void*)(uintptr_t)value, type);
+        UA_Variant_setScalar(&wvalue.value.value, (void*)(uintptr_t)value, attr_type);
     else {
     else {
-        if(type != &UA_TYPES[UA_TYPES_VARIANT])
+        if(attr_type != &UA_TYPES[UA_TYPES_VARIANT])
             return UA_STATUSCODE_BADTYPEMISMATCH;
             return UA_STATUSCODE_BADTYPEMISMATCH;
         wvalue.value.value = *(const UA_Variant*)value;
         wvalue.value.value = *(const UA_Variant*)value;
     }
     }

+ 2 - 1
src/server/ua_server_binary.c

@@ -140,7 +140,7 @@ static void processOPN(UA_Connection *connection, UA_Server *server, const UA_By
         connection->releaseSendBuffer(connection, &resp_msg);
         connection->releaseSendBuffer(connection, &resp_msg);
         connection->close(connection);
         connection->close(connection);
     } else {
     } else {
-        respHeader.messageHeader.messageSize = tmpPos;
+        respHeader.messageHeader.messageSize = (UA_UInt32)tmpPos;
         tmpPos = 0;
         tmpPos = 0;
         UA_SecureConversationMessageHeader_encodeBinary(&respHeader, &resp_msg, &tmpPos);
         UA_SecureConversationMessageHeader_encodeBinary(&respHeader, &resp_msg, &tmpPos);
         resp_msg.length = respHeader.messageHeader.messageSize;
         resp_msg.length = respHeader.messageHeader.messageSize;
@@ -397,6 +397,7 @@ processMSG(UA_Connection *connection, UA_Server *server, const UA_ByteString *ms
         UA_SecureChannel_getSession(channel, &((UA_RequestHeader*)request)->authenticationToken);
         UA_SecureChannel_getSession(channel, &((UA_RequestHeader*)request)->authenticationToken);
     UA_Session anonymousSession;
     UA_Session anonymousSession;
     if(!session) {
     if(!session) {
+        /* session id 0 -> anonymous session */
         UA_Session_init(&anonymousSession);
         UA_Session_init(&anonymousSession);
         anonymousSession.channel = channel;
         anonymousSession.channel = channel;
         anonymousSession.activated = UA_TRUE;
         anonymousSession.activated = UA_TRUE;

+ 16 - 3
src/server/ua_server_worker.c

@@ -338,9 +338,9 @@ static UA_UInt16 processRepeatedJobs(UA_Server *server) {
     // check if the next repeated job is sooner than the usual timeout
     // check if the next repeated job is sooner than the usual timeout
     // calc in 32 bit must be ok
     // calc in 32 bit must be ok
     struct RepeatedJobs *first = LIST_FIRST(&server->repeatedJobs);
     struct RepeatedJobs *first = LIST_FIRST(&server->repeatedJobs);
-    UA_UInt32 timeout = MAXTIMEOUT;
+    UA_UInt16 timeout = MAXTIMEOUT;
     if(first) {
     if(first) {
-        timeout = (UA_UInt32)((first->nextTime - current) / 10);
+        timeout = (UA_UInt16)((first->nextTime - current) / 10);
         if(timeout > MAXTIMEOUT)
         if(timeout > MAXTIMEOUT)
             return MAXTIMEOUT;
             return MAXTIMEOUT;
     }
     }
@@ -494,6 +494,12 @@ static void dispatchDelayedJobs(UA_Server *server, void *data /* not used, but n
         dw = dw->next;
         dw = dw->next;
     }
     }
 
 
+#if (__GNUC__ <= 4 && __GNUC_MINOR__ <= 6)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wextra"
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#pragma GCC diagnostic ignored "-Wunused-value"
+#endif
     /* process and free all delayed jobs from here on */
     /* process and free all delayed jobs from here on */
     while(dw) {
     while(dw) {
         processJobs(server, dw->jobs, dw->jobsCount);
         processJobs(server, dw->jobs, dw->jobsCount);
@@ -502,6 +508,10 @@ static void dispatchDelayedJobs(UA_Server *server, void *data /* not used, but n
         UA_free(dw->workerCounters);
         UA_free(dw->workerCounters);
         dw = next;
         dw = next;
     }
     }
+#if (__GNUC__ <= 4 && __GNUC_MINOR__ <= 6)
+#pragma GCC diagnostic pop
+#endif
+
 }
 }
 
 
 #endif
 #endif
@@ -554,7 +564,10 @@ UA_StatusCode UA_Server_run_startup(UA_Server *server) {
     UA_StatusCode result = UA_STATUSCODE_GOOD;
     UA_StatusCode result = UA_STATUSCODE_GOOD;
     for(size_t i = 0; i < server->config.networkLayersSize; i++) {
     for(size_t i = 0; i < server->config.networkLayersSize; i++) {
         UA_ServerNetworkLayer *nl = &server->config.networkLayers[i];
         UA_ServerNetworkLayer *nl = &server->config.networkLayers[i];
-        result |= nl->start(nl);
+        result |= nl->start(nl, server->config.logger);
+        for(size_t j = 0; j < server->endpointDescriptionsSize; j++) {
+            UA_String_copy(&nl->discoveryUrl, &server->endpointDescriptions[j].endpointUrl);
+        }
     }
     }
 
 
     return result;
     return result;

+ 1 - 1
src/server/ua_services.h

@@ -59,7 +59,7 @@ void Service_OpenSecureChannel(UA_Server *server, UA_Connection *connection,
                                UA_OpenSecureChannelResponse *response);
                                UA_OpenSecureChannelResponse *response);
 
 
 /** Used to terminate a SecureChannel. */
 /** Used to terminate a SecureChannel. */
-void Service_CloseSecureChannel(UA_Server *server, UA_Int32 channelId);
+void Service_CloseSecureChannel(UA_Server *server, UA_UInt32 channelId);
 
 
 /** @} */
 /** @} */
 
 

+ 30 - 27
src/server/ua_services_attribute.c

@@ -9,48 +9,51 @@
 /* Read Attribute */
 /* Read Attribute */
 /******************/
 /******************/
 
 
-static size_t readNumber(UA_Byte *buf, UA_Int32 buflen, UA_UInt32 *number) {
+static size_t
+readNumber(UA_Byte *buf, size_t buflen, UA_UInt32 *number) {
     UA_UInt32 n = 0;
     UA_UInt32 n = 0;
     size_t progress = 0;
     size_t progress = 0;
     /* read numbers until the end or a non-number character appears */
     /* read numbers until the end or a non-number character appears */
     UA_Byte c;
     UA_Byte c;
-    while((UA_Int32)progress < buflen) {
+    while(progress < buflen) {
         c = buf[progress];
         c = buf[progress];
         if('0' > c || '9' < c)
         if('0' > c || '9' < c)
             break;
             break;
-        n = (n*10) + (c-'0');
+        n = (n*10) + (UA_UInt32)(c-'0');
         progress++;
         progress++;
     }
     }
     *number = n;
     *number = n;
     return progress;
     return progress;
 }
 }
 
 
-static size_t readDimension(UA_Byte *buf, UA_Int32 buflen, struct UA_NumericRangeDimension *dim) {
+static size_t
+readDimension(UA_Byte *buf, size_t buflen, struct UA_NumericRangeDimension *dim) {
     size_t progress = readNumber(buf, buflen, &dim->min);
     size_t progress = readNumber(buf, buflen, &dim->min);
     if(progress == 0)
     if(progress == 0)
         return 0;
         return 0;
-    if(buflen <= (UA_Int32)progress || buf[progress] != ':') {
+    if(buflen <= progress || buf[progress] != ':') {
         dim->max = dim->min;
         dim->max = dim->min;
         return progress;
         return progress;
     }
     }
-    size_t progress2 = readNumber(&buf[progress+1], buflen - (progress + 1), &dim->max);
+    progress++;
+    size_t progress2 = readNumber(&buf[progress], buflen - progress, &dim->max);
     if(progress2 == 0)
     if(progress2 == 0)
         return 0;
         return 0;
-    return progress + progress2 + 1;
+    return progress + progress2;
 }
 }
 
 
 #ifndef UA_BUILD_UNIT_TESTS
 #ifndef UA_BUILD_UNIT_TESTS
 static
 static
 #endif
 #endif
 UA_StatusCode parse_numericrange(const UA_String *str, UA_NumericRange *range) {
 UA_StatusCode parse_numericrange(const UA_String *str, UA_NumericRange *range) {
-    UA_Int32 index = 0;
+    size_t idx = 0;
     size_t dimensionsMax = 0;
     size_t dimensionsMax = 0;
     struct UA_NumericRangeDimension *dimensions = NULL;
     struct UA_NumericRangeDimension *dimensions = NULL;
     UA_StatusCode retval = UA_STATUSCODE_GOOD;
     UA_StatusCode retval = UA_STATUSCODE_GOOD;
     size_t pos = 0;
     size_t pos = 0;
     do {
     do {
         /* alloc dimensions */
         /* alloc dimensions */
-        if(index >= (UA_Int32)dimensionsMax) {
+        if(idx >= dimensionsMax) {
             struct UA_NumericRangeDimension *newds;
             struct UA_NumericRangeDimension *newds;
             newds = UA_realloc(dimensions, sizeof(struct UA_NumericRangeDimension) * (dimensionsMax + 2));
             newds = UA_realloc(dimensions, sizeof(struct UA_NumericRangeDimension) * (dimensionsMax + 2));
             if(!newds) {
             if(!newds) {
@@ -62,22 +65,22 @@ UA_StatusCode parse_numericrange(const UA_String *str, UA_NumericRange *range) {
         }
         }
 
 
         /* read the dimension */
         /* read the dimension */
-        size_t progress = readDimension(&str->data[pos], str->length - pos, &dimensions[index]);
+        size_t progress = readDimension(&str->data[pos], str->length - pos, &dimensions[idx]);
         if(progress == 0) {
         if(progress == 0) {
             retval = UA_STATUSCODE_BADINDEXRANGEINVALID;
             retval = UA_STATUSCODE_BADINDEXRANGEINVALID;
             break;
             break;
         }
         }
         pos += progress;
         pos += progress;
-        index++;
+        idx++;
 
 
         /* loop into the next dimension */
         /* loop into the next dimension */
         if(pos >= str->length)
         if(pos >= str->length)
             break;
             break;
     } while(str->data[pos] == ',' && pos++);
     } while(str->data[pos] == ',' && pos++);
 
 
-    if(retval == UA_STATUSCODE_GOOD && index > 0) {
+    if(retval == UA_STATUSCODE_GOOD && idx > 0) {
         range->dimensions = dimensions;
         range->dimensions = dimensions;
-        range->dimensionsSize = index;
+        range->dimensionsSize = idx;
     } else
     } else
         UA_free(dimensions);
         UA_free(dimensions);
 
 
@@ -105,9 +108,9 @@ static void handleSourceTimestamps(UA_TimestampsToReturn timestamps, UA_DataValu
 }
 }
 
 
 /* force cast for zero-copy reading. ensure that the variant is never written into. */
 /* force cast for zero-copy reading. ensure that the variant is never written into. */
-static void forceVariantSetScalar(UA_Variant *v, const void *p, const UA_DataType *type) {
+static void forceVariantSetScalar(UA_Variant *v, const void *p, const UA_DataType *t) {
     UA_Variant_init(v);
     UA_Variant_init(v);
-    v->type = type;
+    v->type = t;
     v->data = (void*)(uintptr_t)p;
     v->data = (void*)(uintptr_t)p;
     v->storageType = UA_VARIANT_DATA_NODELETE;
     v->storageType = UA_VARIANT_DATA_NODELETE;
 }
 }
@@ -503,12 +506,12 @@ enum type_equivalence {
     TYPE_EQUIVALENCE_OPAQUE
     TYPE_EQUIVALENCE_OPAQUE
 };
 };
 
 
-static enum type_equivalence typeEquivalence(const UA_DataType *type) {
-    if(type->membersSize != 1 || !type->members[0].namespaceZero)
+static enum type_equivalence typeEquivalence(const UA_DataType *t) {
+    if(t->membersSize != 1 || !t->members[0].namespaceZero)
         return TYPE_EQUIVALENCE_NONE;
         return TYPE_EQUIVALENCE_NONE;
-    if(type->members[0].memberTypeIndex == UA_TYPES_INT32)
+    if(t->members[0].memberTypeIndex == UA_TYPES_INT32)
         return TYPE_EQUIVALENCE_ENUM;
         return TYPE_EQUIVALENCE_ENUM;
-    if(type->members[0].memberTypeIndex == UA_TYPES_BYTE && type->members[0].isArray)
+    if(t->members[0].memberTypeIndex == UA_TYPES_BYTE && t->members[0].isArray)
         return TYPE_EQUIVALENCE_OPAQUE;
         return TYPE_EQUIVALENCE_OPAQUE;
     return TYPE_EQUIVALENCE_NONE;
     return TYPE_EQUIVALENCE_NONE;
 }
 }
@@ -581,7 +584,7 @@ CopyAttributeIntoNode(UA_Server *server, UA_Session *session,
 
 
     void *value = wvalue->value.value.data;
     void *value = wvalue->value.value.data;
     void *target = NULL;
     void *target = NULL;
-    const UA_DataType *type = NULL;
+    const UA_DataType *attr_type = NULL;
 
 
     UA_StatusCode retval = UA_STATUSCODE_GOOD;
     UA_StatusCode retval = UA_STATUSCODE_GOOD;
 	switch(wvalue->attributeId) {
 	switch(wvalue->attributeId) {
@@ -593,17 +596,17 @@ CopyAttributeIntoNode(UA_Server *server, UA_Session *session,
 	case UA_ATTRIBUTEID_BROWSENAME:
 	case UA_ATTRIBUTEID_BROWSENAME:
 		CHECK_DATATYPE(QUALIFIEDNAME);
 		CHECK_DATATYPE(QUALIFIEDNAME);
         target = &node->browseName;
         target = &node->browseName;
-        type = &UA_TYPES[UA_TYPES_QUALIFIEDNAME];
+        attr_type = &UA_TYPES[UA_TYPES_QUALIFIEDNAME];
 		break;
 		break;
 	case UA_ATTRIBUTEID_DISPLAYNAME:
 	case UA_ATTRIBUTEID_DISPLAYNAME:
 		CHECK_DATATYPE(LOCALIZEDTEXT);
 		CHECK_DATATYPE(LOCALIZEDTEXT);
         target = &node->displayName;
         target = &node->displayName;
-        type = &UA_TYPES[UA_TYPES_LOCALIZEDTEXT];
+        attr_type = &UA_TYPES[UA_TYPES_LOCALIZEDTEXT];
 		break;
 		break;
 	case UA_ATTRIBUTEID_DESCRIPTION:
 	case UA_ATTRIBUTEID_DESCRIPTION:
 		CHECK_DATATYPE(LOCALIZEDTEXT);
 		CHECK_DATATYPE(LOCALIZEDTEXT);
         target = &node->description;
         target = &node->description;
-        type = &UA_TYPES[UA_TYPES_LOCALIZEDTEXT];
+        attr_type = &UA_TYPES[UA_TYPES_LOCALIZEDTEXT];
 		break;
 		break;
 	case UA_ATTRIBUTEID_WRITEMASK:
 	case UA_ATTRIBUTEID_WRITEMASK:
 		CHECK_DATATYPE(UINT32);
 		CHECK_DATATYPE(UINT32);
@@ -628,7 +631,7 @@ CopyAttributeIntoNode(UA_Server *server, UA_Session *session,
 		CHECK_NODECLASS_WRITE(UA_NODECLASS_REFERENCETYPE);
 		CHECK_NODECLASS_WRITE(UA_NODECLASS_REFERENCETYPE);
 		CHECK_DATATYPE(LOCALIZEDTEXT);
 		CHECK_DATATYPE(LOCALIZEDTEXT);
         target = &((UA_ReferenceTypeNode*)node)->inverseName;
         target = &((UA_ReferenceTypeNode*)node)->inverseName;
-        type = &UA_TYPES[UA_TYPES_LOCALIZEDTEXT];
+        attr_type = &UA_TYPES[UA_TYPES_LOCALIZEDTEXT];
 		break;
 		break;
 	case UA_ATTRIBUTEID_CONTAINSNOLOOPS:
 	case UA_ATTRIBUTEID_CONTAINSNOLOOPS:
 		CHECK_NODECLASS_WRITE(UA_NODECLASS_VIEW);
 		CHECK_NODECLASS_WRITE(UA_NODECLASS_VIEW);
@@ -681,9 +684,9 @@ CopyAttributeIntoNode(UA_Server *server, UA_Session *session,
 		retval = UA_STATUSCODE_BADATTRIBUTEIDINVALID;
 		retval = UA_STATUSCODE_BADATTRIBUTEIDINVALID;
 		break;
 		break;
 	}
 	}
-    if(type) {
-        UA_deleteMembers(target, type);
-        retval = UA_copy(value, target, type);
+    if(attr_type) {
+        UA_deleteMembers(target, attr_type);
+        retval = UA_copy(value, target, attr_type);
     }
     }
     return retval;
     return retval;
 }
 }

+ 1 - 1
src/server/ua_services_call.c

@@ -44,7 +44,7 @@ satisfySignature(const UA_Variant *var, const UA_Argument *arg) {
     /* The dimension 1 is implicit in the array length */
     /* The dimension 1 is implicit in the array length */
     UA_UInt32 fakeDims;
     UA_UInt32 fakeDims;
     if(!scalar && !varDims) {
     if(!scalar && !varDims) {
-        fakeDims = var->arrayLength;
+        fakeDims = (UA_UInt32)var->arrayLength;
         varDims = &fakeDims;
         varDims = &fakeDims;
         varDimsSize = 1;
         varDimsSize = 1;
     }
     }

+ 2 - 2
src/server/ua_services_discovery.c

@@ -25,14 +25,14 @@ void Service_FindServers(UA_Server *server, UA_Session *session,
         UA_ApplicationDescription_delete(descr);
         UA_ApplicationDescription_delete(descr);
         return;
         return;
     }
     }
-    size_t index = descr->discoveryUrlsSize;
+    size_t existing = descr->discoveryUrlsSize;
     descr->discoveryUrls = disc;
     descr->discoveryUrls = disc;
     descr->discoveryUrlsSize += server->config.networkLayersSize;
     descr->discoveryUrlsSize += server->config.networkLayersSize;
         
         
     // TODO: Add nl only if discoveryUrl not already present
     // TODO: Add nl only if discoveryUrl not already present
     for(size_t i = 0; i < server->config.networkLayersSize; i++) {
     for(size_t i = 0; i < server->config.networkLayersSize; i++) {
         UA_ServerNetworkLayer *nl = &server->config.networkLayers[i];
         UA_ServerNetworkLayer *nl = &server->config.networkLayers[i];
-        UA_String_copy(&nl->discoveryUrl, &descr->discoveryUrls[index + i]);
+        UA_String_copy(&nl->discoveryUrl, &descr->discoveryUrls[existing + i]);
     }
     }
 
 
     response->servers = descr;
     response->servers = descr;

+ 43 - 45
src/server/ua_services_nodemanagement.c

@@ -209,10 +209,10 @@ static UA_StatusCode
 instantiateObjectNode(UA_Server *server, UA_Session *session,
 instantiateObjectNode(UA_Server *server, UA_Session *session,
                       const UA_NodeId *nodeId, const UA_NodeId *typeId, 
                       const UA_NodeId *nodeId, const UA_NodeId *typeId, 
                       UA_InstantiationCallback *instantiationCallback) {   
                       UA_InstantiationCallback *instantiationCallback) {   
-    const UA_ObjectTypeNode *type = (const UA_ObjectTypeNode*)UA_NodeStore_get(server->nodestore, typeId);
-    if(!type)
+    const UA_ObjectTypeNode *typenode = (const UA_ObjectTypeNode*)UA_NodeStore_get(server->nodestore, typeId);
+    if(!typenode)
       return UA_STATUSCODE_BADNODEIDINVALID;
       return UA_STATUSCODE_BADNODEIDINVALID;
-    if(type->nodeClass != UA_NODECLASS_OBJECTTYPE)
+    if(typenode->nodeClass != UA_NODECLASS_OBJECTTYPE)
       return UA_STATUSCODE_BADNODECLASSINVALID;
       return UA_STATUSCODE_BADNODECLASSINVALID;
     
     
     /* Add all the child nodes */
     /* Add all the child nodes */
@@ -259,7 +259,7 @@ instantiateObjectNode(UA_Server *server, UA_Session *session,
     Service_AddReferences_single(server, session, &addref);
     Service_AddReferences_single(server, session, &addref);
 
 
     /* call the constructor */
     /* call the constructor */
-    const UA_ObjectLifecycleManagement *olm = &type->lifecycleManagement;
+    const UA_ObjectLifecycleManagement *olm = &typenode->lifecycleManagement;
     if(olm->constructor)
     if(olm->constructor)
         UA_Server_editNode(server, session, nodeId,
         UA_Server_editNode(server, session, nodeId,
                            (UA_EditNodeCallback)setObjectInstanceHandle, olm->constructor(*nodeId));
                            (UA_EditNodeCallback)setObjectInstanceHandle, olm->constructor(*nodeId));
@@ -269,10 +269,10 @@ instantiateObjectNode(UA_Server *server, UA_Session *session,
 static UA_StatusCode
 static UA_StatusCode
 instantiateVariableNode(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
 instantiateVariableNode(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
     const UA_NodeId *typeId, UA_InstantiationCallback *instantiationCallback) {
     const UA_NodeId *typeId, UA_InstantiationCallback *instantiationCallback) {
-    const UA_ObjectTypeNode *type = (const UA_ObjectTypeNode*)UA_NodeStore_get(server->nodestore, typeId);
-    if(!type)
+    const UA_ObjectTypeNode *typenode = (const UA_ObjectTypeNode*)UA_NodeStore_get(server->nodestore, typeId);
+    if(!typenode)
         return UA_STATUSCODE_BADNODEIDINVALID;
         return UA_STATUSCODE_BADNODEIDINVALID;
-    if(type->nodeClass != UA_NODECLASS_VARIABLETYPE)
+    if(typenode->nodeClass != UA_NODECLASS_VARIABLETYPE)
         return UA_STATUSCODE_BADNODECLASSINVALID;
         return UA_STATUSCODE_BADNODECLASSINVALID;
     
     
     /* get the references to child properties */
     /* get the references to child properties */
@@ -644,8 +644,8 @@ UA_Server_addMethodNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
                         const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
                         const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
                         const UA_QualifiedName browseName, const UA_MethodAttributes attr,
                         const UA_QualifiedName browseName, const UA_MethodAttributes attr,
                         UA_MethodCallback method, void *handle,
                         UA_MethodCallback method, void *handle,
-                        UA_Int32 inputArgumentsSize, const UA_Argument* inputArguments, 
-                        UA_Int32 outputArgumentsSize, const UA_Argument* outputArguments,
+                        size_t inputArgumentsSize, const UA_Argument* inputArguments, 
+                        size_t outputArgumentsSize, const UA_Argument* outputArguments,
                         UA_NodeId *outNewNodeId) {
                         UA_NodeId *outNewNodeId) {
     UA_AddNodesResult result;
     UA_AddNodesResult result;
     UA_AddNodesResult_init(&result);
     UA_AddNodesResult_init(&result);
@@ -703,42 +703,38 @@ UA_Server_addMethodNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
      *          This is not a production feature and should be fixed on the compiler side! (@ichrispa)
      *          This is not a production feature and should be fixed on the compiler side! (@ichrispa)
      */
      */
     const UA_NodeId hasproperty = UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY);
     const UA_NodeId hasproperty = UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY);
-    if (inputArgumentsSize >= 0) {
-      UA_VariableNode *inputArgumentsVariableNode = UA_NodeStore_newVariableNode();
-      inputArgumentsVariableNode->nodeId.namespaceIndex = result.addedNodeId.namespaceIndex;
-      inputArgumentsVariableNode->browseName = UA_QUALIFIEDNAME_ALLOC(0,"InputArguments");
-      inputArgumentsVariableNode->displayName = UA_LOCALIZEDTEXT_ALLOC("en_US", "InputArguments");
-      inputArgumentsVariableNode->description = UA_LOCALIZEDTEXT_ALLOC("en_US", "InputArguments");
-      inputArgumentsVariableNode->valueRank = 1;
-      UA_Variant_setArrayCopy(&inputArgumentsVariableNode->value.variant.value, inputArguments,
-                              inputArgumentsSize, &UA_TYPES[UA_TYPES_ARGUMENT]);
-      UA_AddNodesResult inputAddRes;
-      UA_Server_addExistingNode(server, &adminSession, (UA_Node*)inputArgumentsVariableNode,
-                                &parent.nodeId, &hasproperty, &inputAddRes);
-      // todo: check if adding succeeded
-      UA_AddNodesResult_deleteMembers(&inputAddRes);
-    }
+    UA_VariableNode *inputArgumentsVariableNode = UA_NodeStore_newVariableNode();
+    inputArgumentsVariableNode->nodeId.namespaceIndex = result.addedNodeId.namespaceIndex;
+    inputArgumentsVariableNode->browseName = UA_QUALIFIEDNAME_ALLOC(0,"InputArguments");
+    inputArgumentsVariableNode->displayName = UA_LOCALIZEDTEXT_ALLOC("en_US", "InputArguments");
+    inputArgumentsVariableNode->description = UA_LOCALIZEDTEXT_ALLOC("en_US", "InputArguments");
+    inputArgumentsVariableNode->valueRank = 1;
+    UA_Variant_setArrayCopy(&inputArgumentsVariableNode->value.variant.value, inputArguments,
+                            inputArgumentsSize, &UA_TYPES[UA_TYPES_ARGUMENT]);
+    UA_AddNodesResult inputAddRes;
+    UA_Server_addExistingNode(server, &adminSession, (UA_Node*)inputArgumentsVariableNode,
+                              &parent.nodeId, &hasproperty, &inputAddRes);
+    // todo: check if adding succeeded
+    UA_AddNodesResult_deleteMembers(&inputAddRes);
     
     
     /* create OutputArguments */
     /* create OutputArguments */
     /* FIXME:   See comment in inputArguments */
     /* FIXME:   See comment in inputArguments */
-    if (outputArgumentsSize >= 0) {
-      UA_VariableNode *outputArgumentsVariableNode  = UA_NodeStore_newVariableNode();
-      outputArgumentsVariableNode->nodeId.namespaceIndex = result.addedNodeId.namespaceIndex;
-      outputArgumentsVariableNode->browseName  = UA_QUALIFIEDNAME_ALLOC(0,"OutputArguments");
-      outputArgumentsVariableNode->displayName = UA_LOCALIZEDTEXT_ALLOC("en_US", "OutputArguments");
-      outputArgumentsVariableNode->description = UA_LOCALIZEDTEXT_ALLOC("en_US", "OutputArguments");
-      outputArgumentsVariableNode->valueRank = 1;
-      UA_Variant_setArrayCopy(&outputArgumentsVariableNode->value.variant.value, outputArguments,
-                              outputArgumentsSize, &UA_TYPES[UA_TYPES_ARGUMENT]);
-      UA_AddNodesResult outputAddRes;
-      UA_Server_addExistingNode(server, &adminSession, (UA_Node*)outputArgumentsVariableNode,
-                                &parent.nodeId, &hasproperty, &outputAddRes);
-      // todo: check if adding succeeded
-      UA_AddNodesResult_deleteMembers(&outputAddRes);
-    }
+    UA_VariableNode *outputArgumentsVariableNode  = UA_NodeStore_newVariableNode();
+    outputArgumentsVariableNode->nodeId.namespaceIndex = result.addedNodeId.namespaceIndex;
+    outputArgumentsVariableNode->browseName  = UA_QUALIFIEDNAME_ALLOC(0,"OutputArguments");
+    outputArgumentsVariableNode->displayName = UA_LOCALIZEDTEXT_ALLOC("en_US", "OutputArguments");
+    outputArgumentsVariableNode->description = UA_LOCALIZEDTEXT_ALLOC("en_US", "OutputArguments");
+    outputArgumentsVariableNode->valueRank = 1;
+    UA_Variant_setArrayCopy(&outputArgumentsVariableNode->value.variant.value, outputArguments,
+                            outputArgumentsSize, &UA_TYPES[UA_TYPES_ARGUMENT]);
+    UA_AddNodesResult outputAddRes;
+    UA_Server_addExistingNode(server, &adminSession, (UA_Node*)outputArgumentsVariableNode,
+                              &parent.nodeId, &hasproperty, &outputAddRes);
+    // todo: check if adding succeeded
+    UA_AddNodesResult_deleteMembers(&outputAddRes);
     
     
     if(outNewNodeId)
     if(outNewNodeId)
-        *outNewNodeId = result.addedNodeId;
+        *outNewNodeId = result.addedNodeId; // don't deleteMember the result
     else
     else
         UA_AddNodesResult_deleteMembers(&result);
         UA_AddNodesResult_deleteMembers(&result);
     return result.statusCode;
     return result.statusCode;
@@ -885,15 +881,15 @@ Service_DeleteNodes_single(UA_Server *server, UA_Session *session, const UA_Node
         for(size_t i = 0; i < result.referencesSize; i++) {
         for(size_t i = 0; i < result.referencesSize; i++) {
             /* call the destructor */
             /* call the destructor */
             UA_ReferenceDescription *rd = &result.references[i];
             UA_ReferenceDescription *rd = &result.references[i];
-            const UA_ObjectTypeNode *type =
+            const UA_ObjectTypeNode *typenode =
                 (const UA_ObjectTypeNode*)UA_NodeStore_get(server->nodestore, &rd->nodeId.nodeId);
                 (const UA_ObjectTypeNode*)UA_NodeStore_get(server->nodestore, &rd->nodeId.nodeId);
-            if(!type)
+            if(!typenode)
                 continue;
                 continue;
-            if(type->nodeClass != UA_NODECLASS_OBJECTTYPE || !type->lifecycleManagement.destructor)
+            if(typenode->nodeClass != UA_NODECLASS_OBJECTTYPE || !typenode->lifecycleManagement.destructor)
                 continue;
                 continue;
 
 
             /* if there are several types with lifecycle management, call all the destructors */
             /* if there are several types with lifecycle management, call all the destructors */
-            type->lifecycleManagement.destructor(*nodeId, ((const UA_ObjectNode*)node)->instanceHandle);
+            typenode->lifecycleManagement.destructor(*nodeId, ((const UA_ObjectNode*)node)->instanceHandle);
         }
         }
         UA_BrowseResult_deleteMembers(&result);
         UA_BrowseResult_deleteMembers(&result);
     }
     }
@@ -928,7 +924,9 @@ static UA_StatusCode
 deleteOneWayReference(UA_Server *server, UA_Session *session, UA_Node *node,
 deleteOneWayReference(UA_Server *server, UA_Session *session, UA_Node *node,
                       const UA_DeleteReferencesItem *item) {
                       const UA_DeleteReferencesItem *item) {
     UA_Boolean edited = UA_FALSE;
     UA_Boolean edited = UA_FALSE;
-    for(UA_Int32 i = node->referencesSize - 1; i >= 0; i--) {
+    for(size_t i = node->referencesSize - 1; ; i--) {
+        if(i > node->referencesSize)
+            break; /* underflow after i == 0 */
         if(!UA_NodeId_equal(&item->targetNodeId.nodeId, &node->references[i].targetId.nodeId))
         if(!UA_NodeId_equal(&item->targetNodeId.nodeId, &node->references[i].targetId.nodeId))
             continue;
             continue;
         if(!UA_NodeId_equal(&item->referenceTypeId, &node->references[i].referenceTypeId))
         if(!UA_NodeId_equal(&item->referenceTypeId, &node->references[i].referenceTypeId))

+ 1 - 1
src/server/ua_services_securechannel.c

@@ -32,7 +32,7 @@ void Service_OpenSecureChannel(UA_Server *server, UA_Connection *connection,
 }
 }
 
 
 /* The server does not send a CloseSecureChannel response */
 /* The server does not send a CloseSecureChannel response */
-void Service_CloseSecureChannel(UA_Server *server, UA_Int32 channelId) {
+void Service_CloseSecureChannel(UA_Server *server, UA_UInt32 channelId) {
     UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
     UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
                  "Closing SecureChannel %i", channelId);
                  "Closing SecureChannel %i", channelId);
     UA_SecureChannelManager_close(&server->secureChannelManager, channelId);
     UA_SecureChannelManager_close(&server->secureChannelManager, channelId);

+ 4 - 4
src/server/ua_services_subscription.c

@@ -25,7 +25,7 @@ void Service_CreateSubscription(UA_Server *server, UA_Session *session,
     /* set the publishing interval */
     /* set the publishing interval */
     UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.globalPublishingInterval,
     UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.globalPublishingInterval,
                                request->requestedPublishingInterval, response->revisedPublishingInterval);
                                request->requestedPublishingInterval, response->revisedPublishingInterval);
-    newSubscription->publishingInterval = (UA_DateTime)response->revisedPublishingInterval;
+    newSubscription->publishingInterval = response->revisedPublishingInterval;
     
     
     /* set the subscription lifetime (deleted when no publish requests arrive within this time) */
     /* set the subscription lifetime (deleted when no publish requests arrive within this time) */
     UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.globalLifeTimeCount,
     UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.globalLifeTimeCount,
@@ -39,7 +39,7 @@ void Service_CreateSubscription(UA_Server *server, UA_Session *session,
        nothin has happened for n publishing intervals */
        nothin has happened for n publishing intervals */
     UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.globalKeepAliveCount,
     UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.globalKeepAliveCount,
                                request->requestedMaxKeepAliveCount, response->revisedMaxKeepAliveCount);
                                request->requestedMaxKeepAliveCount, response->revisedMaxKeepAliveCount);
-    newSubscription->keepAliveCount = (UA_Int32_BoundedValue)  {
+    newSubscription->keepAliveCount = (UA_UInt32_BoundedValue)  {
         .minValue=session->subscriptionManager.globalKeepAliveCount.minValue,
         .minValue=session->subscriptionManager.globalKeepAliveCount.minValue,
         .maxValue=session->subscriptionManager.globalKeepAliveCount.maxValue,
         .maxValue=session->subscriptionManager.globalKeepAliveCount.maxValue,
         .currentValue=response->revisedMaxKeepAliveCount};
         .currentValue=response->revisedMaxKeepAliveCount};
@@ -240,7 +240,7 @@ void Service_ModifySubscription(UA_Server *server, UA_Session *session,
     
     
     UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.globalPublishingInterval,
     UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.globalPublishingInterval,
                                request->requestedPublishingInterval, response->revisedPublishingInterval);
                                request->requestedPublishingInterval, response->revisedPublishingInterval);
-    sub->publishingInterval = (UA_DateTime)response->revisedPublishingInterval;
+    sub->publishingInterval = response->revisedPublishingInterval;
     
     
     UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.globalLifeTimeCount,
     UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.globalLifeTimeCount,
                                request->requestedLifetimeCount, response->revisedLifetimeCount);
                                request->requestedLifetimeCount, response->revisedLifetimeCount);
@@ -251,7 +251,7 @@ void Service_ModifySubscription(UA_Server *server, UA_Session *session,
         
         
     UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.globalKeepAliveCount,
     UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.globalKeepAliveCount,
                                 request->requestedMaxKeepAliveCount, response->revisedMaxKeepAliveCount);
                                 request->requestedMaxKeepAliveCount, response->revisedMaxKeepAliveCount);
-    sub->keepAliveCount = (UA_Int32_BoundedValue)  {
+    sub->keepAliveCount = (UA_UInt32_BoundedValue)  {
         .minValue=session->subscriptionManager.globalKeepAliveCount.minValue,
         .minValue=session->subscriptionManager.globalKeepAliveCount.minValue,
         .maxValue=session->subscriptionManager.globalKeepAliveCount.maxValue,
         .maxValue=session->subscriptionManager.globalKeepAliveCount.maxValue,
         .currentValue=response->revisedMaxKeepAliveCount};
         .currentValue=response->revisedMaxKeepAliveCount};

+ 6 - 6
src/server/ua_services_view.c

@@ -153,10 +153,10 @@ findSubTypes(UA_NodeStore *ns, const UA_NodeId *root, UA_NodeId **reftypes, size
         return retval;
         return retval;
     }
     }
         
         
-    size_t index = 0; // where are we currently in the array?
+    size_t idx = 0; // where are we currently in the array?
     size_t last = 0; // where is the last element in the array?
     size_t last = 0; // where is the last element in the array?
     do {
     do {
-        node = UA_NodeStore_get(ns, &results[index]);
+        node = UA_NodeStore_get(ns, &results[idx]);
         if(!node || node->nodeClass != UA_NODECLASS_REFERENCETYPE)
         if(!node || node->nodeClass != UA_NODECLASS_REFERENCETYPE)
             continue;
             continue;
         for(size_t i = 0; i < node->referencesSize; i++) {
         for(size_t i = 0; i < node->referencesSize; i++) {
@@ -180,7 +180,7 @@ findSubTypes(UA_NodeStore *ns, const UA_NodeId *root, UA_NodeId **reftypes, size
                 break;
                 break;
             }
             }
         }
         }
-    } while(++index <= last && retval == UA_STATUSCODE_GOOD);
+    } while(++idx <= last && retval == UA_STATUSCODE_GOOD);
 
 
     if(retval != UA_STATUSCODE_GOOD) {
     if(retval != UA_STATUSCODE_GOOD) {
         UA_Array_delete(results, last, &UA_TYPES[UA_TYPES_NODEID]);
         UA_Array_delete(results, last, &UA_TYPES[UA_TYPES_NODEID]);
@@ -270,7 +270,7 @@ Service_Browse_single(UA_Server *server, UA_Session *session, struct Continuatio
     }
     }
 
 
     /* how many references can we return at most? */
     /* how many references can we return at most? */
-    UA_UInt32 real_maxrefs = maxrefs;
+    size_t real_maxrefs = maxrefs;
     if(real_maxrefs == 0)
     if(real_maxrefs == 0)
         real_maxrefs = node->referencesSize;
         real_maxrefs = node->referencesSize;
     if(node->referencesSize <= 0)
     if(node->referencesSize <= 0)
@@ -336,7 +336,7 @@ Service_Browse_single(UA_Server *server, UA_Session *session, struct Continuatio
             removeCp(cp, session);
             removeCp(cp, session);
         } else {
         } else {
             /* update the cp and return the cp identifier */
             /* update the cp and return the cp identifier */
-            cp->continuationIndex += referencesCount;
+            cp->continuationIndex += (UA_UInt32)referencesCount;
             UA_ByteString_copy(&cp->identifier, &result->continuationPoint);
             UA_ByteString_copy(&cp->identifier, &result->continuationPoint);
         }
         }
     } else if(maxrefs != 0 && referencesCount >= maxrefs) {
     } else if(maxrefs != 0 && referencesCount >= maxrefs) {
@@ -348,7 +348,7 @@ Service_Browse_single(UA_Server *server, UA_Session *session, struct Continuatio
         }
         }
         UA_BrowseDescription_copy(descr, &cp->browseDescription);
         UA_BrowseDescription_copy(descr, &cp->browseDescription);
         cp->maxReferences = maxrefs;
         cp->maxReferences = maxrefs;
-        cp->continuationIndex = referencesCount;
+        cp->continuationIndex = (UA_UInt32)referencesCount;
         UA_Guid *ident = UA_Guid_new();
         UA_Guid *ident = UA_Guid_new();
         *ident = UA_Guid_random();
         *ident = UA_Guid_random();
         cp->identifier.data = (UA_Byte*)ident;
         cp->identifier.data = (UA_Byte*)ident;

+ 4 - 4
src/server/ua_session_manager.h

@@ -13,10 +13,10 @@ typedef struct session_list_entry {
 
 
 typedef struct UA_SessionManager {
 typedef struct UA_SessionManager {
     LIST_HEAD(session_list, session_list_entry) sessions; // doubly-linked list of sessions
     LIST_HEAD(session_list, session_list_entry) sessions; // doubly-linked list of sessions
-    UA_UInt32    maxSessionCount;
-    UA_Int32     lastSessionId;
-    UA_UInt32    currentSessionCount;
-    UA_DateTime  maxSessionLifeTime;    // time in [ms]
+    UA_UInt32 maxSessionCount;
+    UA_UInt32 lastSessionId;
+    UA_UInt32 currentSessionCount;
+    UA_UInt32 maxSessionLifeTime;    // time in [ms]
 } UA_SessionManager;
 } UA_SessionManager;
 
 
 UA_StatusCode
 UA_StatusCode

+ 7 - 5
src/server/ua_subscription.c

@@ -6,7 +6,7 @@
 /* Subscription */
 /* Subscription */
 /****************/
 /****************/
 
 
-UA_Subscription *UA_Subscription_new(UA_Int32 subscriptionID) {
+UA_Subscription *UA_Subscription_new(UA_UInt32 subscriptionID) {
     UA_Subscription *new = UA_malloc(sizeof(UA_Subscription));
     UA_Subscription *new = UA_malloc(sizeof(UA_Subscription));
     if(!new)
     if(!new)
         return NULL;
         return NULL;
@@ -68,7 +68,8 @@ void Subscription_updateNotifications(UA_Subscription *subscription) {
     UA_unpublishedNotification *msg;
     UA_unpublishedNotification *msg;
     UA_UInt32 monItemsChangeT = 0, monItemsStatusT = 0, monItemsEventT = 0;
     UA_UInt32 monItemsChangeT = 0, monItemsStatusT = 0, monItemsEventT = 0;
     
     
-    if(!subscription || subscription->lastPublished + subscription->publishingInterval > UA_DateTime_now())
+    if(!subscription || subscription->lastPublished +
+       (UA_UInt32)(subscription->publishingInterval * UA_MSEC_TO_DATETIME) > UA_DateTime_now())
         return;
         return;
     
     
     // Make sure there is data to be published and establish which message types
     // Make sure there is data to be published and establish which message types
@@ -238,7 +239,8 @@ UA_StatusCode Subscription_registerUpdateJob(UA_Server *server, UA_Subscription
     
     
     /* Practically enough, the client sends a uint32 in ms, which we store as
     /* Practically enough, the client sends a uint32 in ms, which we store as
        datetime, which here is required in as uint32 in ms as the interval */
        datetime, which here is required in as uint32 in ms as the interval */
-    UA_StatusCode retval = UA_Server_addRepeatedJob(server, *sub->timedUpdateJob, sub->publishingInterval,
+    UA_StatusCode retval = UA_Server_addRepeatedJob(server, *sub->timedUpdateJob,
+                                                    (UA_UInt32)sub->publishingInterval,
                                                     &sub->timedUpdateJobGuid);
                                                     &sub->timedUpdateJobGuid);
     if(retval == UA_STATUSCODE_GOOD)
     if(retval == UA_STATUSCODE_GOOD)
         sub->timedUpdateIsRegistered = UA_TRUE;
         sub->timedUpdateIsRegistered = UA_TRUE;
@@ -280,9 +282,9 @@ void MonitoredItem_delete(UA_MonitoredItem *monitoredItem) {
     UA_free(monitoredItem);
     UA_free(monitoredItem);
 }
 }
 
 
-int MonitoredItem_QueueToDataChangeNotifications(UA_MonitoredItemNotification *dst,
+UA_UInt32 MonitoredItem_QueueToDataChangeNotifications(UA_MonitoredItemNotification *dst,
                                                  UA_MonitoredItem *monitoredItem) {
                                                  UA_MonitoredItem *monitoredItem) {
-    int queueSize = 0;
+    UA_UInt32 queueSize = 0;
     MonitoredItem_queuedValue *queueItem;
     MonitoredItem_queuedValue *queueItem;
   
   
     // Count instead of relying on the items currentValue
     // Count instead of relying on the items currentValue

+ 7 - 7
src/server/ua_subscription.h

@@ -58,8 +58,8 @@ void MonitoredItem_QueuePushDataValue(UA_Server *server, UA_MonitoredItem *monit
 void MonitoredItem_ClearQueue(UA_MonitoredItem *monitoredItem);
 void MonitoredItem_ClearQueue(UA_MonitoredItem *monitoredItem);
 UA_Boolean MonitoredItem_CopyMonitoredValueToVariant(UA_UInt32 attributeID, const UA_Node *src,
 UA_Boolean MonitoredItem_CopyMonitoredValueToVariant(UA_UInt32 attributeID, const UA_Node *src,
                                                      UA_DataValue *dst);
                                                      UA_DataValue *dst);
-int MonitoredItem_QueueToDataChangeNotifications(UA_MonitoredItemNotification *dst,
-                                                 UA_MonitoredItem *monitoredItem);
+UA_UInt32 MonitoredItem_QueueToDataChangeNotifications(UA_MonitoredItemNotification *dst,
+                                                       UA_MonitoredItem *monitoredItem);
 
 
 /****************/
 /****************/
 /* Subscription */
 /* Subscription */
@@ -74,11 +74,11 @@ typedef struct UA_unpublishedNotification {
 typedef struct UA_Subscription {
 typedef struct UA_Subscription {
     LIST_ENTRY(UA_Subscription) listEntry;
     LIST_ENTRY(UA_Subscription) listEntry;
     UA_UInt32_BoundedValue lifeTime;
     UA_UInt32_BoundedValue lifeTime;
-    UA_Int32_BoundedValue keepAliveCount;
-    UA_DateTime publishingInterval;     // [ms] may be UA_Int32
+    UA_UInt32_BoundedValue keepAliveCount;
+    UA_Double publishingInterval;     // [ms] 
     UA_DateTime lastPublished;
     UA_DateTime lastPublished;
-    UA_Int32 subscriptionID;
-    UA_Int32 notificationsPerPublish;
+    UA_UInt32 subscriptionID;
+    UA_UInt32 notificationsPerPublish;
     UA_Boolean publishingMode;
     UA_Boolean publishingMode;
     UA_UInt32 priority;
     UA_UInt32 priority;
     UA_UInt32 sequenceNumber;
     UA_UInt32 sequenceNumber;
@@ -90,7 +90,7 @@ typedef struct UA_Subscription {
     LIST_HEAD(UA_ListOfUAMonitoredItems, UA_MonitoredItem) MonitoredItems;
     LIST_HEAD(UA_ListOfUAMonitoredItems, UA_MonitoredItem) MonitoredItems;
 } UA_Subscription;
 } UA_Subscription;
 
 
-UA_Subscription *UA_Subscription_new(UA_Int32 subscriptionID);
+UA_Subscription *UA_Subscription_new(UA_UInt32 subscriptionID);
 void UA_Subscription_deleteMembers(UA_Subscription *subscription, UA_Server *server);
 void UA_Subscription_deleteMembers(UA_Subscription *subscription, UA_Server *server);
 void Subscription_updateNotifications(UA_Subscription *subscription);
 void Subscription_updateNotifications(UA_Subscription *subscription);
 UA_UInt32 *Subscription_getAvailableSequenceNumbers(UA_Subscription *sub);
 UA_UInt32 *Subscription_getAvailableSequenceNumbers(UA_Subscription *sub);

+ 11 - 8
src/server/ua_subscription_manager.c

@@ -8,10 +8,10 @@ void SubscriptionManager_init(UA_Session *session) {
 
 
     /* FIXME: These init values are empirical. Maybe they should be part
     /* FIXME: These init values are empirical. Maybe they should be part
      *        of the server config? */
      *        of the server config? */
-    manager->globalPublishingInterval = (UA_Int32_BoundedValue) { .maxValue = 10000, .minValue = 0, .currentValue=0 };
+    manager->globalPublishingInterval = (UA_UInt32_BoundedValue) { .maxValue = 10000, .minValue = 0, .currentValue=0 };
     manager->globalLifeTimeCount = (UA_UInt32_BoundedValue) { .maxValue = 15000, .minValue = 0, .currentValue=0 };
     manager->globalLifeTimeCount = (UA_UInt32_BoundedValue) { .maxValue = 15000, .minValue = 0, .currentValue=0 };
     manager->globalKeepAliveCount = (UA_UInt32_BoundedValue) { .maxValue = 100, .minValue = 0, .currentValue=0 };
     manager->globalKeepAliveCount = (UA_UInt32_BoundedValue) { .maxValue = 100, .minValue = 0, .currentValue=0 };
-    manager->globalNotificationsPerPublish = (UA_Int32_BoundedValue)  { .maxValue = 1000, .minValue = 1, .currentValue=0 };
+    manager->globalNotificationsPerPublish = (UA_UInt32_BoundedValue)  { .maxValue = 1000, .minValue = 1, .currentValue=0 };
     manager->globalSamplingInterval = (UA_UInt32_BoundedValue) { .maxValue = 1000, .minValue = 5, .currentValue=0 };
     manager->globalSamplingInterval = (UA_UInt32_BoundedValue) { .maxValue = 1000, .minValue = 5, .currentValue=0 };
     manager->globalQueueSize = (UA_UInt32_BoundedValue) { .maxValue = 100, .minValue = 0, .currentValue=0 };
     manager->globalQueueSize = (UA_UInt32_BoundedValue) { .maxValue = 100, .minValue = 0, .currentValue=0 };
     LIST_INIT(&manager->serverSubscriptions);
     LIST_INIT(&manager->serverSubscriptions);
@@ -33,8 +33,8 @@ void SubscriptionManager_addSubscription(UA_SubscriptionManager *manager, UA_Sub
     LIST_INSERT_HEAD(&manager->serverSubscriptions, newSubscription, listEntry);
     LIST_INSERT_HEAD(&manager->serverSubscriptions, newSubscription, listEntry);
 }
 }
 
 
-UA_Subscription *SubscriptionManager_getSubscriptionByID(UA_SubscriptionManager *manager,
-                                                         UA_Int32 subscriptionID) {
+UA_Subscription *
+SubscriptionManager_getSubscriptionByID(UA_SubscriptionManager *manager, UA_UInt32 subscriptionID) {
     UA_Subscription *sub;
     UA_Subscription *sub;
     LIST_FOREACH(sub, &manager->serverSubscriptions, listEntry) {
     LIST_FOREACH(sub, &manager->serverSubscriptions, listEntry) {
         if(sub->subscriptionID == subscriptionID)
         if(sub->subscriptionID == subscriptionID)
@@ -43,15 +43,16 @@ UA_Subscription *SubscriptionManager_getSubscriptionByID(UA_SubscriptionManager
     return sub;
     return sub;
 }
 }
 
 
-UA_Int32 SubscriptionManager_deleteMonitoredItem(UA_SubscriptionManager *manager, UA_Int32 subscriptionID,
-                                                 UA_UInt32 monitoredItemID) {
+UA_StatusCode
+SubscriptionManager_deleteMonitoredItem(UA_SubscriptionManager *manager, UA_UInt32 subscriptionID,
+                                        UA_UInt32 monitoredItemID) {
     UA_Subscription *sub = SubscriptionManager_getSubscriptionByID(manager, subscriptionID);
     UA_Subscription *sub = SubscriptionManager_getSubscriptionByID(manager, subscriptionID);
     if(!sub)
     if(!sub)
         return UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
         return UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
     
     
     UA_MonitoredItem *mon, *tmp_mon;
     UA_MonitoredItem *mon, *tmp_mon;
     LIST_FOREACH_SAFE(mon, &sub->MonitoredItems, listEntry, tmp_mon) {
     LIST_FOREACH_SAFE(mon, &sub->MonitoredItems, listEntry, tmp_mon) {
-        if (mon->itemId == monitoredItemID) {
+        if(mon->itemId == monitoredItemID) {
             LIST_REMOVE(mon, listEntry);
             LIST_REMOVE(mon, listEntry);
             MonitoredItem_delete(mon);
             MonitoredItem_delete(mon);
             return UA_STATUSCODE_GOOD;
             return UA_STATUSCODE_GOOD;
@@ -60,7 +61,9 @@ UA_Int32 SubscriptionManager_deleteMonitoredItem(UA_SubscriptionManager *manager
     return UA_STATUSCODE_BADMONITOREDITEMIDINVALID;
     return UA_STATUSCODE_BADMONITOREDITEMIDINVALID;
 }
 }
 
 
-UA_Int32 SubscriptionManager_deleteSubscription(UA_Server *server, UA_SubscriptionManager *manager, UA_Int32 subscriptionID) {
+UA_StatusCode
+SubscriptionManager_deleteSubscription(UA_Server *server, UA_SubscriptionManager *manager,
+                                       UA_UInt32 subscriptionID) {
     UA_Subscription *sub = SubscriptionManager_getSubscriptionByID(manager, subscriptionID);    
     UA_Subscription *sub = SubscriptionManager_getSubscriptionByID(manager, subscriptionID);    
     if(!sub)
     if(!sub)
         return UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
         return UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;

+ 11 - 8
src/server/ua_subscription_manager.h

@@ -8,13 +8,13 @@
 #include "ua_subscription.h"
 #include "ua_subscription.h"
 
 
 typedef struct UA_SubscriptionManager {
 typedef struct UA_SubscriptionManager {
-    UA_Int32_BoundedValue globalPublishingInterval;
+    UA_UInt32_BoundedValue globalPublishingInterval;
     UA_UInt32_BoundedValue globalLifeTimeCount;
     UA_UInt32_BoundedValue globalLifeTimeCount;
     UA_UInt32_BoundedValue globalKeepAliveCount;
     UA_UInt32_BoundedValue globalKeepAliveCount;
-    UA_Int32_BoundedValue globalNotificationsPerPublish;
+    UA_UInt32_BoundedValue globalNotificationsPerPublish;
     UA_UInt32_BoundedValue globalSamplingInterval;
     UA_UInt32_BoundedValue globalSamplingInterval;
     UA_UInt32_BoundedValue globalQueueSize;
     UA_UInt32_BoundedValue globalQueueSize;
-    UA_Int32 lastSessionID;
+    UA_UInt32 lastSessionID;
     UA_Guid lastJobGuid;
     UA_Guid lastJobGuid;
     LIST_HEAD(UA_ListOfUASubscriptions, UA_Subscription) serverSubscriptions;
     LIST_HEAD(UA_ListOfUASubscriptions, UA_Subscription) serverSubscriptions;
 } UA_SubscriptionManager;
 } UA_SubscriptionManager;
@@ -22,11 +22,14 @@ typedef struct UA_SubscriptionManager {
 void SubscriptionManager_init(UA_Session *session);
 void SubscriptionManager_init(UA_Session *session);
 void SubscriptionManager_deleteMembers(UA_Session *session, UA_Server *server);
 void SubscriptionManager_deleteMembers(UA_Session *session, UA_Server *server);
 void SubscriptionManager_addSubscription(UA_SubscriptionManager *manager, UA_Subscription *subscription);
 void SubscriptionManager_addSubscription(UA_SubscriptionManager *manager, UA_Subscription *subscription);
-UA_Subscription *SubscriptionManager_getSubscriptionByID(UA_SubscriptionManager *manager,
-                                                         UA_Int32 subscriptionID);
-UA_Int32 SubscriptionManager_deleteSubscription(UA_Server *server, UA_SubscriptionManager *manager, UA_Int32 subscriptionID);
-UA_Int32 SubscriptionManager_deleteMonitoredItem(UA_SubscriptionManager *manager, UA_Int32 subscriptionID,
-                                                 UA_UInt32 monitoredItemID);
+UA_Subscription *
+SubscriptionManager_getSubscriptionByID(UA_SubscriptionManager *manager, UA_UInt32 subscriptionID);
+UA_StatusCode
+SubscriptionManager_deleteSubscription(UA_Server *server, UA_SubscriptionManager *manager,
+                                       UA_UInt32 subscriptionID);
+UA_StatusCode
+SubscriptionManager_deleteMonitoredItem(UA_SubscriptionManager *manager, UA_UInt32 subscriptionID,
+                                        UA_UInt32 monitoredItemID);
 
 
 UA_UInt32 SubscriptionManager_getUniqueUIntID(UA_SubscriptionManager *manager);
 UA_UInt32 SubscriptionManager_getUniqueUIntID(UA_SubscriptionManager *manager);
 UA_Guid SubscriptionManager_getUniqueGUID(UA_SubscriptionManager *manager);
 UA_Guid SubscriptionManager_getUniqueGUID(UA_SubscriptionManager *manager);

+ 18 - 5
src/ua_connection.c

@@ -57,7 +57,9 @@ UA_Connection_completeMessages(UA_Connection *connection, UA_ByteString * UA_RES
     size_t pos = 0;
     size_t pos = 0;
     size_t delete_at = current->length-1; // garbled message after this point
     size_t delete_at = current->length-1; // garbled message after this point
     while(current->length - pos >= 16) {
     while(current->length - pos >= 16) {
-        UA_UInt32 msgtype = current->data[pos] + (current->data[pos+1] << 8) + (current->data[pos+2] << 16);
+        UA_UInt32 msgtype = (UA_UInt32)current->data[pos] +
+            ((UA_UInt32)current->data[pos+1] << 8) +
+            ((UA_UInt32)current->data[pos+2] << 16);
         if(msgtype != ('M' + ('S' << 8) + ('G' << 16)) &&
         if(msgtype != ('M' + ('S' << 8) + ('G' << 16)) &&
            msgtype != ('O' + ('P' << 8) + ('N' << 16)) &&
            msgtype != ('O' + ('P' << 8) + ('N' << 16)) &&
            msgtype != ('H' + ('E' << 8) + ('L' << 16)) &&
            msgtype != ('H' + ('E' << 8) + ('L' << 16)) &&
@@ -67,10 +69,10 @@ UA_Connection_completeMessages(UA_Connection *connection, UA_ByteString * UA_RES
             delete_at = pos; // throw the remaining message away
             delete_at = pos; // throw the remaining message away
             break;
             break;
         }
         }
-        UA_Int32 length = 0;
+        UA_UInt32 length = 0;
         size_t length_pos = pos + 4;
         size_t length_pos = pos + 4;
-        UA_StatusCode retval = UA_Int32_decodeBinary(current, &length_pos, &length);
-        if(retval != UA_STATUSCODE_GOOD || length < 16 || length > (UA_Int32)connection->localConf.maxMessageSize) {
+        UA_StatusCode retval = UA_UInt32_decodeBinary(current, &length_pos, &length);
+        if(retval != UA_STATUSCODE_GOOD || length < 16 || length > connection->localConf.maxMessageSize) {
             /* the message size is not allowed. throw the remaining bytestring away */
             /* the message size is not allowed. throw the remaining bytestring away */
             delete_at = pos;
             delete_at = pos;
             break;
             break;
@@ -129,6 +131,13 @@ UA_Connection_completeMessages(UA_Connection *connection, UA_ByteString * UA_RES
     return UA_STATUSCODE_GOOD;
     return UA_STATUSCODE_GOOD;
 }
 }
 
 
+#if (__GNUC__ <= 4 && __GNUC_MINOR__ <= 6)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wextra"
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#pragma GCC diagnostic ignored "-Wunused-value"
+#endif
+
 void UA_Connection_detachSecureChannel(UA_Connection *connection) {
 void UA_Connection_detachSecureChannel(UA_Connection *connection) {
 #ifdef UA_ENABLE_MULTITHREADING
 #ifdef UA_ENABLE_MULTITHREADING
     UA_SecureChannel *channel = connection->channel;
     UA_SecureChannel *channel = connection->channel;
@@ -145,7 +154,7 @@ void UA_Connection_detachSecureChannel(UA_Connection *connection) {
 void UA_Connection_attachSecureChannel(UA_Connection *connection, UA_SecureChannel *channel) {
 void UA_Connection_attachSecureChannel(UA_Connection *connection, UA_SecureChannel *channel) {
 #ifdef UA_ENABLE_MULTITHREADING
 #ifdef UA_ENABLE_MULTITHREADING
     if(uatomic_cmpxchg(&channel->connection, NULL, connection) == NULL)
     if(uatomic_cmpxchg(&channel->connection, NULL, connection) == NULL)
-        uatomic_set(&connection->channel, channel);
+        uatomic_set((void**)&connection->channel, (void*)channel);
 #else
 #else
     if(channel->connection != NULL)
     if(channel->connection != NULL)
         return;
         return;
@@ -153,3 +162,7 @@ void UA_Connection_attachSecureChannel(UA_Connection *connection, UA_SecureChann
     connection->channel = channel;
     connection->channel = channel;
 #endif
 #endif
 }
 }
+
+#if (__GNUC__ <= 4 && __GNUC_MINOR__ <= 6)
+#pragma GCC diagnostic pop
+#endif

+ 12 - 1
src/ua_securechannel.c

@@ -50,6 +50,13 @@ UA_StatusCode UA_SecureChannel_generateNonce(UA_ByteString *nonce) {
     return UA_STATUSCODE_GOOD;
     return UA_STATUSCODE_GOOD;
 }
 }
 
 
+#if (__GNUC__ <= 4 && __GNUC_MINOR__ <= 6)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wextra"
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#pragma GCC diagnostic ignored "-Wunused-value"
+#endif
+
 void UA_SecureChannel_attachSession(UA_SecureChannel *channel, UA_Session *session) {
 void UA_SecureChannel_attachSession(UA_SecureChannel *channel, UA_Session *session) {
     struct SessionEntry *se = UA_malloc(sizeof(struct SessionEntry));
     struct SessionEntry *se = UA_malloc(sizeof(struct SessionEntry));
     if(!se)
     if(!se)
@@ -70,6 +77,10 @@ void UA_SecureChannel_attachSession(UA_SecureChannel *channel, UA_Session *sessi
     LIST_INSERT_HEAD(&channel->sessions, se, pointers);
     LIST_INSERT_HEAD(&channel->sessions, se, pointers);
 }
 }
 
 
+#if (__GNUC__ <= 4 && __GNUC_MINOR__ <= 6)
+#pragma GCC diagnostic pop
+#endif
+
 void UA_SecureChannel_detachSession(UA_SecureChannel *channel, UA_Session *session) {
 void UA_SecureChannel_detachSession(UA_SecureChannel *channel, UA_Session *session) {
     if(session)
     if(session)
         session->channel = NULL;
         session->channel = NULL;
@@ -143,7 +154,7 @@ UA_StatusCode UA_SecureChannel_sendBinaryMessage(UA_SecureChannel *channel, UA_U
     }
     }
 
 
     /* now write the header with the size */
     /* now write the header with the size */
-    respHeader.messageHeader.messageSize = messagePos;
+    respHeader.messageHeader.messageSize = (UA_UInt32)messagePos;
 #ifndef UA_ENABLE_MULTITHREADING
 #ifndef UA_ENABLE_MULTITHREADING
     seqHeader.sequenceNumber = ++channel->sequenceNumber;
     seqHeader.sequenceNumber = ++channel->sequenceNumber;
 #else
 #else

+ 0 - 14
src/ua_session.c

@@ -2,20 +2,6 @@
 #include "ua_session.h"
 #include "ua_session.h"
 #include "ua_statuscodes.h"
 #include "ua_statuscodes.h"
 
 
-UA_Session anonymousSession = {
-    .clientDescription =  {.applicationUri = {0, NULL}, .productUri = {0, NULL},
-                           .applicationName = {.locale = {0, NULL}, .text = {0, NULL}},
-                           .applicationType = UA_APPLICATIONTYPE_CLIENT,
-                           .gatewayServerUri = {0, NULL}, .discoveryProfileUri = {0, NULL},
-                           .discoveryUrlsSize = 0, .discoveryUrls = NULL},
-    .sessionName = {sizeof("Anonymous Session")-1, (UA_Byte*)"Anonymous Session"},
-    .authenticationToken = {.namespaceIndex = 0, .identifierType = UA_NODEIDTYPE_NUMERIC,
-                            .identifier.numeric = 0}, 
-    .sessionId = {.namespaceIndex = 0, .identifierType = UA_NODEIDTYPE_NUMERIC, .identifier.numeric = 0},
-    .maxRequestMessageSize = UA_UINT32_MAX, .maxResponseMessageSize = UA_UINT32_MAX,
-    .timeout = UA_INT64_MAX, .validTill = UA_INT64_MAX, .channel = NULL,
-    .continuationPoints = {NULL}};
-
 UA_Session adminSession = {
 UA_Session adminSession = {
     .clientDescription =  {.applicationUri = {0, NULL}, .productUri = {0, NULL},
     .clientDescription =  {.applicationUri = {0, NULL}, .productUri = {0, NULL},
                            .applicationName = {.locale = {0, NULL}, .text = {0, NULL}},
                            .applicationName = {.locale = {0, NULL}, .text = {0, NULL}},

+ 1 - 2
src/ua_session.h

@@ -22,7 +22,7 @@ struct ContinuationPointEntry {
     LIST_ENTRY(ContinuationPointEntry) pointers;
     LIST_ENTRY(ContinuationPointEntry) pointers;
     UA_ByteString        identifier;
     UA_ByteString        identifier;
     UA_BrowseDescription browseDescription;
     UA_BrowseDescription browseDescription;
-    UA_Int32            continuationIndex;
+    UA_UInt32            continuationIndex;
     UA_UInt32            maxReferences;
     UA_UInt32            maxReferences;
 };
 };
 
 
@@ -44,7 +44,6 @@ struct UA_Session {
     LIST_HEAD(ContinuationPointList, ContinuationPointEntry) continuationPoints;
     LIST_HEAD(ContinuationPointList, ContinuationPointEntry) continuationPoints;
 };
 };
 
 
-extern UA_Session anonymousSession; ///< If anonymous access is allowed, this session is used internally (Session ID: 0)
 extern UA_Session adminSession; ///< Local access to the services (for startup and maintenance) uses this Session with all possible access rights (Session ID: 1)
 extern UA_Session adminSession; ///< Local access to the services (for startup and maintenance) uses this Session with all possible access rights (Session ID: 1)
 
 
 void UA_Session_init(UA_Session *session);
 void UA_Session_init(UA_Session *session);

+ 15 - 11
src/ua_types.c

@@ -20,7 +20,7 @@ UA_EXPORT const UA_ExpandedNodeId UA_EXPANDEDNODEID_NULL = {
 static UA_THREAD_LOCAL pcg32_random_t UA_rng = PCG32_INITIALIZER;
 static UA_THREAD_LOCAL pcg32_random_t UA_rng = PCG32_INITIALIZER;
 
 
 UA_EXPORT void UA_random_seed(UA_UInt64 seed) {
 UA_EXPORT void UA_random_seed(UA_UInt64 seed) {
-    pcg32_srandom_r(&UA_rng, seed, UA_DateTime_now());
+    pcg32_srandom_r(&UA_rng, seed, (uint64_t)UA_DateTime_now());
 }
 }
 
 
 /*****************/
 /*****************/
@@ -93,15 +93,15 @@ UA_DateTime UA_DateTime_nowMonotonic(void) {
 #endif
 #endif
 }
 }
 
 
-UA_DateTimeStruct UA_DateTime_toStruct(UA_DateTime atime) {
+UA_DateTimeStruct UA_DateTime_toStruct(UA_DateTime t) {
     /* Calculating the the milli-, micro- and nanoseconds */
     /* Calculating the the milli-, micro- and nanoseconds */
     UA_DateTimeStruct dateTimeStruct;
     UA_DateTimeStruct dateTimeStruct;
-    dateTimeStruct.nanoSec  = (UA_UInt16)((atime % 10) * 100);
-    dateTimeStruct.microSec = (UA_UInt16)((atime % 10000) / 10);
-    dateTimeStruct.milliSec = (UA_UInt16)((atime % 10000000) / 10000);
+    dateTimeStruct.nanoSec  = (UA_UInt16)((t % 10) * 100);
+    dateTimeStruct.microSec = (UA_UInt16)((t % 10000) / 10);
+    dateTimeStruct.milliSec = (UA_UInt16)((t % 10000000) / 10000);
 
 
     /* Calculating the unix time with #include <time.h> */
     /* Calculating the unix time with #include <time.h> */
-    time_t secSinceUnixEpoch = (atime - UA_DATETIME_UNIX_EPOCH) / UA_SEC_TO_DATETIME;
+    time_t secSinceUnixEpoch = (time_t)((t - UA_DATETIME_UNIX_EPOCH) / UA_SEC_TO_DATETIME);
     struct tm ts = *gmtime(&secSinceUnixEpoch);
     struct tm ts = *gmtime(&secSinceUnixEpoch);
     dateTimeStruct.sec    = (UA_UInt16)ts.tm_sec;
     dateTimeStruct.sec    = (UA_UInt16)ts.tm_sec;
     dateTimeStruct.min    = (UA_UInt16)ts.tm_min;
     dateTimeStruct.min    = (UA_UInt16)ts.tm_min;
@@ -114,18 +114,18 @@ UA_DateTimeStruct UA_DateTime_toStruct(UA_DateTime atime) {
 
 
 static void printNumber(UA_UInt16 n, UA_Byte *pos, size_t digits) {
 static void printNumber(UA_UInt16 n, UA_Byte *pos, size_t digits) {
     for(size_t i = digits; i > 0; i--) {
     for(size_t i = digits; i > 0; i--) {
-        pos[i-1] = (n % 10) + '0';
+        pos[i-1] = (UA_Byte)((n % 10) + '0');
         n = n / 10;
         n = n / 10;
     }
     }
 }
 }
 
 
-UA_String UA_DateTime_toString(UA_DateTime time) {
+UA_String UA_DateTime_toString(UA_DateTime t) {
     UA_String str = UA_STRING_NULL;
     UA_String str = UA_STRING_NULL;
     // length of the string is 31 (plus \0 at the end)
     // length of the string is 31 (plus \0 at the end)
     if(!(str.data = UA_malloc(32)))
     if(!(str.data = UA_malloc(32)))
         return str;
         return str;
     str.length = 31;
     str.length = 31;
-    UA_DateTimeStruct tSt = UA_DateTime_toStruct(time);
+    UA_DateTimeStruct tSt = UA_DateTime_toStruct(t);
     printNumber(tSt.month, str.data, 2);
     printNumber(tSt.month, str.data, 2);
     str.data[2] = '/';
     str.data[2] = '/';
     printNumber(tSt.day, &str.data[3], 2);
     printNumber(tSt.day, &str.data[3], 2);
@@ -352,9 +352,13 @@ static UA_StatusCode
 processRangeDefinition(const UA_Variant *v, const UA_NumericRange range, size_t *total,
 processRangeDefinition(const UA_Variant *v, const UA_NumericRange range, size_t *total,
                        size_t *block, size_t *stride, size_t *first) {
                        size_t *block, size_t *stride, size_t *first) {
     /* Test the integrity of the source variant dimensions */
     /* Test the integrity of the source variant dimensions */
-    UA_UInt32 dims_count = 1;
+    size_t dims_count = 1;
     UA_UInt32 elements = 1;
     UA_UInt32 elements = 1;
-    UA_UInt32 arrayLength = v->arrayLength;
+#if(MAX_SIZE > 0xffffffff) /* 64bit only */
+    if(v->arrayLength > UA_UINT32_MAX)
+        return UA_STATUSCODE_BADINTERNALERROR;
+#endif
+    UA_UInt32 arrayLength = (UA_UInt32)v->arrayLength;
     const UA_UInt32 *dims = &arrayLength;
     const UA_UInt32 *dims = &arrayLength;
     if(v->arrayDimensionsSize > 0) {
     if(v->arrayDimensionsSize > 0) {
         dims_count = v->arrayDimensionsSize;
         dims_count = v->arrayDimensionsSize;

+ 42 - 33
src/ua_types_encoding_binary.c

@@ -269,8 +269,10 @@ Double_encodeBinary(UA_Double const *src, bufpos pos, bufend end) {
 static UA_StatusCode
 static UA_StatusCode
 Array_encodeBinary(const void *src, size_t length, const UA_DataType *contenttype, bufpos pos, bufend end) {
 Array_encodeBinary(const void *src, size_t length, const UA_DataType *contenttype, bufpos pos, bufend end) {
     UA_Int32 signed_length = -1;
     UA_Int32 signed_length = -1;
+    if(length > UA_INT32_MAX)
+        return UA_STATUSCODE_BADINTERNALERROR;
     if(length > 0)
     if(length > 0)
-        signed_length = length;
+        signed_length = (UA_Int32)length;
     else if(src == UA_EMPTY_ARRAY_SENTINEL)
     else if(src == UA_EMPTY_ARRAY_SENTINEL)
         signed_length = 0;
         signed_length = 0;
     UA_StatusCode retval = Int32_encodeBinary(&signed_length, pos, end);
     UA_StatusCode retval = Int32_encodeBinary(&signed_length, pos, end);
@@ -300,7 +302,6 @@ Array_encodeBinary(const void *src, size_t length, const UA_DataType *contenttyp
 static UA_StatusCode
 static UA_StatusCode
 Array_decodeBinary(bufpos pos, bufend end, UA_Int32 signed_length, void *UA_RESTRICT *UA_RESTRICT dst,
 Array_decodeBinary(bufpos pos, bufend end, UA_Int32 signed_length, void *UA_RESTRICT *UA_RESTRICT dst,
                    size_t *out_length, const UA_DataType *contenttype) {
                    size_t *out_length, const UA_DataType *contenttype) {
-    size_t length = signed_length;
     *out_length = 0;
     *out_length = 0;
     if(signed_length <= 0) {
     if(signed_length <= 0) {
         *dst = NULL;
         *dst = NULL;
@@ -308,6 +309,7 @@ Array_decodeBinary(bufpos pos, bufend end, UA_Int32 signed_length, void *UA_REST
             *dst = UA_EMPTY_ARRAY_SENTINEL;
             *dst = UA_EMPTY_ARRAY_SENTINEL;
         return UA_STATUSCODE_GOOD;
         return UA_STATUSCODE_GOOD;
     }
     }
+    size_t length = (size_t)signed_length;
         
         
     if(contenttype->memSize * length > MAX_ARRAY_SIZE)
     if(contenttype->memSize * length > MAX_ARRAY_SIZE)
         return UA_STATUSCODE_BADOUTOFMEMORY;
         return UA_STATUSCODE_BADOUTOFMEMORY;
@@ -356,6 +358,8 @@ static UA_StatusCode
 String_encodeBinary(UA_String const *src, bufpos pos, bufend end) {
 String_encodeBinary(UA_String const *src, bufpos pos, bufend end) {
     if(*pos + sizeof(UA_Int32) + src->length > end)
     if(*pos + sizeof(UA_Int32) + src->length > end)
         return UA_STATUSCODE_BADENCODINGERROR;
         return UA_STATUSCODE_BADENCODINGERROR;
+    if(src->length > UA_INT32_MAX)
+        return UA_STATUSCODE_BADINTERNALERROR;
     UA_StatusCode retval;
     UA_StatusCode retval;
     if((void*)src->data <= UA_EMPTY_ARRAY_SENTINEL) {
     if((void*)src->data <= UA_EMPTY_ARRAY_SENTINEL) {
         UA_Int32 signed_length = -1;
         UA_Int32 signed_length = -1;
@@ -363,10 +367,10 @@ String_encodeBinary(UA_String const *src, bufpos pos, bufend end) {
             signed_length = 0;
             signed_length = 0;
         retval = Int32_encodeBinary(&signed_length, pos, end);
         retval = Int32_encodeBinary(&signed_length, pos, end);
     } else {
     } else {
-        UA_Int32 signed_length = src->length;
+        UA_Int32 signed_length = (UA_Int32)src->length;
         retval = Int32_encodeBinary(&signed_length, pos, end);
         retval = Int32_encodeBinary(&signed_length, pos, end);
         memcpy(*pos, src->data, src->length);
         memcpy(*pos, src->data, src->length);
-        (*pos) += src->length;
+        *pos += src->length;
     }
     }
     return retval;
     return retval;
 }
 }
@@ -389,13 +393,15 @@ String_decodeBinary(bufpos pos, bufend end, UA_String *dst) {
             dst->data = NULL;
             dst->data = NULL;
         return UA_STATUSCODE_GOOD;
         return UA_STATUSCODE_GOOD;
     }
     }
-    if(*pos + (size_t)signed_length > end)
+    size_t length = (size_t)signed_length;
+    if(*pos + length > end)
         return UA_STATUSCODE_BADDECODINGERROR;
         return UA_STATUSCODE_BADDECODINGERROR;
-    if(!(dst->data = UA_malloc(signed_length)))
+    dst->data = UA_malloc(length);
+    if(!dst->data)
         return UA_STATUSCODE_BADOUTOFMEMORY;
         return UA_STATUSCODE_BADOUTOFMEMORY;
-    memcpy(dst->data, *pos, signed_length);
-    dst->length = signed_length;
-    (*pos) += signed_length;
+    memcpy(dst->data, *pos, length);
+    dst->length = length;
+    *pos += length;
     return UA_STATUSCODE_GOOD;
     return UA_STATUSCODE_GOOD;
 }
 }
 
 
@@ -451,13 +457,13 @@ NodeId_encodeBinary(UA_NodeId const *src, bufpos pos, bufend end) {
             srcByte = UA_NODEIDTYPE_NUMERIC_FOURBYTE;
             srcByte = UA_NODEIDTYPE_NUMERIC_FOURBYTE;
             retval |= Byte_encodeBinary(&srcByte, pos, end);
             retval |= Byte_encodeBinary(&srcByte, pos, end);
             srcByte = (UA_Byte)src->namespaceIndex;
             srcByte = (UA_Byte)src->namespaceIndex;
-            srcUInt16 = src->identifier.numeric;
+            srcUInt16 = (UA_UInt16)src->identifier.numeric;
             retval |= Byte_encodeBinary(&srcByte, pos, end);
             retval |= Byte_encodeBinary(&srcByte, pos, end);
             retval |= UInt16_encodeBinary(&srcUInt16, pos, end);
             retval |= UInt16_encodeBinary(&srcUInt16, pos, end);
         } else {
         } else {
             srcByte = UA_NODEIDTYPE_NUMERIC_TWOBYTE;
             srcByte = UA_NODEIDTYPE_NUMERIC_TWOBYTE;
             retval |= Byte_encodeBinary(&srcByte, pos, end);
             retval |= Byte_encodeBinary(&srcByte, pos, end);
-            srcByte = src->identifier.numeric;
+            srcByte = (UA_Byte)src->identifier.numeric;
             retval |= Byte_encodeBinary(&srcByte, pos, end);
             retval |= Byte_encodeBinary(&srcByte, pos, end);
         }
         }
         break;
         break;
@@ -559,7 +565,7 @@ ExpandedNodeId_decodeBinary(bufpos pos, bufend end, UA_ExpandedNodeId *dst) {
     if(*pos >= end)
     if(*pos >= end)
         return UA_STATUSCODE_BADDECODINGERROR;
         return UA_STATUSCODE_BADDECODINGERROR;
     UA_Byte encodingByte = **pos;
     UA_Byte encodingByte = **pos;
-    **pos = encodingByte & ~(UA_EXPANDEDNODEID_NAMESPACEURI_FLAG | UA_EXPANDEDNODEID_SERVERINDEX_FLAG);
+    **pos = encodingByte & (UA_Byte)~(UA_EXPANDEDNODEID_NAMESPACEURI_FLAG | UA_EXPANDEDNODEID_SERVERINDEX_FLAG);
     UA_StatusCode retval = NodeId_decodeBinary(pos, end, &dst->nodeId);
     UA_StatusCode retval = NodeId_decodeBinary(pos, end, &dst->nodeId);
     if(encodingByte & UA_EXPANDEDNODEID_NAMESPACEURI_FLAG) {
     if(encodingByte & UA_EXPANDEDNODEID_NAMESPACEURI_FLAG) {
         dst->nodeId.namespaceIndex = 0;
         dst->nodeId.namespaceIndex = 0;
@@ -624,7 +630,7 @@ ExtensionObject_encodeBinary(UA_ExtensionObject const *src, bufpos pos, bufend e
         type = src->content.decoded.type;
         type = src->content.decoded.type;
         size_t encode_index = type->builtin ? type->typeIndex : UA_BUILTIN_TYPES_COUNT;
         size_t encode_index = type->builtin ? type->typeIndex : UA_BUILTIN_TYPES_COUNT;
         retval |= encodeBinaryJumpTable[encode_index](src->content.decoded.data, pos, end);
         retval |= encodeBinaryJumpTable[encode_index](src->content.decoded.data, pos, end);
-        UA_Int32 length = (*pos - old_pos - 4) / sizeof(UA_Byte);
+        UA_Int32 length = (UA_Int32)(((uintptr_t)*pos - (uintptr_t)old_pos) / sizeof(UA_Byte)) - 4;
         retval |= Int32_encodeBinary(&length, &old_pos, end);
         retval |= Int32_encodeBinary(&length, &old_pos, end);
     } else {
     } else {
         retval = NodeId_encodeBinary(&src->content.encoded.typeId, pos, end);
         retval = NodeId_encodeBinary(&src->content.encoded.typeId, pos, end);
@@ -643,10 +649,10 @@ ExtensionObject_encodeBinary(UA_ExtensionObject const *src, bufpos pos, bufend e
     return retval;
     return retval;
 }
 }
 
 
-static UA_StatusCode findDataType(const UA_NodeId *typeId, const UA_DataType **type) {
+static UA_StatusCode findDataType(const UA_NodeId *typeId, const UA_DataType **findtype) {
     for(size_t i = 0; i < UA_TYPES_COUNT; i++) {
     for(size_t i = 0; i < UA_TYPES_COUNT; i++) {
         if(UA_NodeId_equal(typeId, &UA_TYPES[i].typeId)) {
         if(UA_NodeId_equal(typeId, &UA_TYPES[i].typeId)) {
-            *type = &UA_TYPES[i];
+            *findtype = &UA_TYPES[i];
             return UA_STATUSCODE_GOOD;
             return UA_STATUSCODE_GOOD;
         }
         }
     }
     }
@@ -718,9 +724,9 @@ static UA_StatusCode
 Variant_encodeBinary(UA_Variant const *src, bufpos pos, bufend end) {
 Variant_encodeBinary(UA_Variant const *src, bufpos pos, bufend end) {
     if(!src->type)
     if(!src->type)
         return UA_STATUSCODE_BADINTERNALERROR;
         return UA_STATUSCODE_BADINTERNALERROR;
-    UA_Boolean isArray = src->arrayLength > 0 || src->data <= UA_EMPTY_ARRAY_SENTINEL;
-    UA_Boolean hasDimensions = isArray && src->arrayDimensionsSize > 0;
-    UA_Boolean isBuiltin = src->type->builtin;
+    const UA_Boolean isArray = src->arrayLength > 0 || src->data <= UA_EMPTY_ARRAY_SENTINEL;
+    const UA_Boolean hasDimensions = isArray && src->arrayDimensionsSize > 0;
+    const UA_Boolean isBuiltin = src->type->builtin;
     UA_Byte encodingByte = 0;
     UA_Byte encodingByte = 0;
     if(isArray) {
     if(isArray) {
         encodingByte |= UA_VARIANT_ENCODINGMASKTYPE_ARRAY;
         encodingByte |= UA_VARIANT_ENCODINGMASKTYPE_ARRAY;
@@ -744,21 +750,24 @@ Variant_encodeBinary(UA_Variant const *src, bufpos pos, bufend end) {
             return UA_STATUSCODE_BADINTERNALERROR;
             return UA_STATUSCODE_BADINTERNALERROR;
         typeId.identifier.numeric += UA_ENCODINGOFFSET_BINARY;
         typeId.identifier.numeric += UA_ENCODINGOFFSET_BINARY;
     }
     }
+    UA_StatusCode retval = Byte_encodeBinary(&encodingByte, pos, end);
 
 
     size_t length = src->arrayLength;
     size_t length = src->arrayLength;
-    UA_StatusCode retval = Byte_encodeBinary(&encodingByte, pos, end);
-    if(isArray) {
+    if(!isArray) {
+        length = 1;
+    } else {
+        if(src->arrayDimensionsSize > UA_INT32_MAX)
+            return UA_STATUSCODE_BADINTERNALERROR;
         UA_Int32 encodeLength = -1;
         UA_Int32 encodeLength = -1;
         if(src->arrayLength > 0)
         if(src->arrayLength > 0)
-            encodeLength = src->arrayLength;
+            encodeLength = (UA_Int32)src->arrayLength;
         else if(src->data == UA_EMPTY_ARRAY_SENTINEL)
         else if(src->data == UA_EMPTY_ARRAY_SENTINEL)
             encodeLength = 0;
             encodeLength = 0;
         retval |= Int32_encodeBinary(&encodeLength, pos, end);
         retval |= Int32_encodeBinary(&encodeLength, pos, end);
-    } else
-        length = 1;
+    }
 
 
     uintptr_t ptr = (uintptr_t)src->data;
     uintptr_t ptr = (uintptr_t)src->data;
-    ptrdiff_t memSize = src->type->memSize;
+    const UA_UInt16 memSize = src->type->memSize;
     for(size_t i = 0; i < length; i++) {
     for(size_t i = 0; i < length; i++) {
         UA_Byte *old_pos; // before encoding the actual content
         UA_Byte *old_pos; // before encoding the actual content
         if(!isBuiltin) {
         if(!isBuiltin) {
@@ -773,7 +782,7 @@ Variant_encodeBinary(UA_Variant const *src, bufpos pos, bufend end) {
         retval |= encodeBinaryJumpTable[encode_index]((const void*)ptr, pos, end);
         retval |= encodeBinaryJumpTable[encode_index]((const void*)ptr, pos, end);
         if(!isBuiltin) {
         if(!isBuiltin) {
             /* Jump back and print the length of the extension object */
             /* Jump back and print the length of the extension object */
-            UA_Int32 encodingLength = (uintptr_t)(*pos - *old_pos) / sizeof(UA_Byte);
+            UA_Int32 encodingLength = (UA_Int32)(((uintptr_t)*pos - (uintptr_t)old_pos) / sizeof(UA_Byte));
             old_pos -= 4;
             old_pos -= 4;
             retval |= Int32_encodeBinary(&encodingLength, &old_pos, end);
             retval |= Int32_encodeBinary(&encodingLength, &old_pos, end);
         }
         }
@@ -794,8 +803,8 @@ Variant_decodeBinary(bufpos pos, bufend end, UA_Variant *dst) {
     if(retval != UA_STATUSCODE_GOOD)
     if(retval != UA_STATUSCODE_GOOD)
         return retval;
         return retval;
     UA_Boolean isArray = encodingByte & UA_VARIANT_ENCODINGMASKTYPE_ARRAY;
     UA_Boolean isArray = encodingByte & UA_VARIANT_ENCODINGMASKTYPE_ARRAY;
-    size_t typeIndex = (encodingByte & UA_VARIANT_ENCODINGMASKTYPE_TYPEID_MASK) - 1;
-    if(typeIndex > 24) /* must be builtin */
+    size_t typeIndex = (size_t)((encodingByte & UA_VARIANT_ENCODINGMASKTYPE_TYPEID_MASK) - 1);
+    if(typeIndex > 24) /* the type must be builtin (maybe wrapped in an extensionobject) */
         return UA_STATUSCODE_BADDECODINGERROR;
         return UA_STATUSCODE_BADDECODINGERROR;
 
 
     if(isArray) {
     if(isArray) {
@@ -1027,7 +1036,7 @@ UA_StatusCode UA_encodeBinary(const void *src, const UA_DataType *localtype, UA_
     UA_Byte *end = &dst->data[dst->length];
     UA_Byte *end = &dst->data[dst->length];
     type = localtype;
     type = localtype;
     UA_StatusCode retval = UA_encodeBinaryInternal(src, &pos, end);
     UA_StatusCode retval = UA_encodeBinaryInternal(src, &pos, end);
-    *offset = (pos - dst->data) / sizeof(UA_Byte);
+    *offset = (size_t)(pos - dst->data) / sizeof(UA_Byte);
     return retval;
     return retval;
 }
 }
 
 
@@ -1098,7 +1107,7 @@ UA_decodeBinary(const UA_ByteString *src, size_t *offset, void *dst, const UA_Da
     UA_Byte *end = &src->data[src->length];
     UA_Byte *end = &src->data[src->length];
     type = localtype;
     type = localtype;
     UA_StatusCode retval = UA_decodeBinaryInternal(&pos, end, dst);
     UA_StatusCode retval = UA_decodeBinaryInternal(&pos, end, dst);
-    *offset = (pos - src->data) / sizeof(UA_Byte);
+    *offset = (size_t)(pos - src->data) / sizeof(UA_Byte);
     return retval;
     return retval;
 }
 }
 
 
@@ -1122,8 +1131,8 @@ Array_calcSizeBinary(const void *src, size_t length, const UA_DataType *contentt
     return s;
     return s;
 }
 }
 
 
-static size_t calcSizeBinaryMemSize(const void *UA_RESTRICT p, const UA_DataType *type) {
-    return type->memSize;
+static size_t calcSizeBinaryMemSize(const void *UA_RESTRICT p, const UA_DataType *datatype) {
+    return datatype->memSize;
 }
 }
 
 
 static size_t String_calcSizeBinary(const UA_String *UA_RESTRICT p, const UA_DataType *_) {
 static size_t String_calcSizeBinary(const UA_String *UA_RESTRICT p, const UA_DataType *_) {
@@ -1172,7 +1181,7 @@ ExpandedNodeId_calcSizeBinary(const UA_ExpandedNodeId *src, const UA_DataType *_
 }
 }
 
 
 static size_t
 static size_t
-LocalizedText_calcSizeBinary(const UA_LocalizedText *src, UA_DataType *type) {
+LocalizedText_calcSizeBinary(const UA_LocalizedText *src, UA_DataType *_) {
     size_t s = 1; // encoding byte
     size_t s = 1; // encoding byte
     if(src->locale.data)
     if(src->locale.data)
         s += String_calcSizeBinary(&src->locale, NULL);
         s += String_calcSizeBinary(&src->locale, NULL);
@@ -1236,7 +1245,7 @@ Variant_calcSizeBinary(UA_Variant const *src, UA_DataType *_) {
         length = 1;
         length = 1;
 
 
     uintptr_t ptr = (uintptr_t)src->data;
     uintptr_t ptr = (uintptr_t)src->data;
-    ptrdiff_t memSize = src->type->memSize;
+    size_t memSize = src->type->memSize;
     for(size_t i = 0; i < length; i++) {
     for(size_t i = 0; i < length; i++) {
         if(!isBuiltin) {
         if(!isBuiltin) {
             /* The type is wrapped inside an extensionobject */
             /* The type is wrapped inside an extensionobject */

+ 4 - 4
src_extra/logger_stdout.c

@@ -6,7 +6,7 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdarg.h>
 #include "logger_stdout.h"
 #include "logger_stdout.h"
-#include "ua_types_generated_encoding_binary.h"
+#include "ua_types_generated.h"
 
 
 const char *LogLevelNames[6] = {"trace", "debug", "info", "warning", "error", "fatal"};
 const char *LogLevelNames[6] = {"trace", "debug", "info", "warning", "error", "fatal"};
 const char *LogCategoryNames[6] = {"network", "channel", "session", "server", "client", "userland"};
 const char *LogCategoryNames[6] = {"network", "channel", "session", "server", "client", "userland"};
@@ -17,9 +17,9 @@ const char *LogCategoryNames[6] = {"network", "channel", "session", "server", "c
 #endif
 #endif
 
 
 void Logger_Stdout(UA_LogLevel level, UA_LogCategory category, const char *msg, ...) {
 void Logger_Stdout(UA_LogLevel level, UA_LogCategory category, const char *msg, ...) {
-	UA_String time = UA_DateTime_toString(UA_DateTime_now());
-    printf("[%.23s] %s/%s\t", time.data, LogLevelNames[level], LogCategoryNames[category]);
-	UA_ByteString_deleteMembers(&time);
+	UA_String t = UA_DateTime_toString(UA_DateTime_now());
+    printf("[%.23s] %s/%s\t", t.data, LogLevelNames[level], LogCategoryNames[category]);
+	UA_ByteString_deleteMembers(&t);
     va_list ap;
     va_list ap;
     va_start(ap, msg);
     va_start(ap, msg);
     vprintf(msg, ap);
     vprintf(msg, ap);

+ 56 - 40
src_extra/networklayer_tcp.c

@@ -15,23 +15,39 @@
 # include <winsock2.h>
 # include <winsock2.h>
 # include <ws2tcpip.h>
 # include <ws2tcpip.h>
 # define CLOSESOCKET(S) closesocket(S)
 # define CLOSESOCKET(S) closesocket(S)
+# define ssize_t long
 #else
 #else
 # include <fcntl.h>
 # include <fcntl.h>
 # include <sys/select.h>
 # include <sys/select.h>
 # include <netinet/in.h>
 # include <netinet/in.h>
-#ifndef __CYGWIN__
-    # include <netinet/tcp.h>
-#endif
+# ifndef __CYGWIN__
+#  include <netinet/tcp.h>
+# endif
 # include <sys/ioctl.h>
 # include <sys/ioctl.h>
 # include <netdb.h> //gethostbyname for the client
 # include <netdb.h> //gethostbyname for the client
 # include <unistd.h> // read, write, close
 # include <unistd.h> // read, write, close
 # include <arpa/inet.h>
 # include <arpa/inet.h>
-#ifdef __QNX__
-#include <sys/socket.h>
-#endif
+# ifdef __QNX__
+#  include <sys/socket.h>
+# endif
 # define CLOSESOCKET(S) close(S)
 # define CLOSESOCKET(S) close(S)
 #endif
 #endif
 
 
+/* workaround a glibc bug where an integer conversion is required */
+#if !defined(_WIN32)
+# include <features.h>
+# if defined(__GNU_LIBRARY__) && (__GNU_LIBRARY__ >= 6) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 16)
+#  define fd_set(fd, fds) FD_SET(fd, fds)
+#  define fd_isset(fd, fds) FD_ISSET(fd, fds)
+# else
+#  define fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
+#  define fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)
+# endif
+#else
+# define fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
+# define fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)
+#endif
+
 #ifdef UA_ENABLE_MULTITHREADING
 #ifdef UA_ENABLE_MULTITHREADING
 # include <urcu/uatomic.h>
 # include <urcu/uatomic.h>
 #endif
 #endif
@@ -55,7 +71,7 @@ static UA_StatusCode
 socket_write(UA_Connection *connection, UA_ByteString *buf) {
 socket_write(UA_Connection *connection, UA_ByteString *buf) {
     size_t nWritten = 0;
     size_t nWritten = 0;
     while(buf->length > 0 && nWritten < (size_t)buf->length) {
     while(buf->length > 0 && nWritten < (size_t)buf->length) {
-        UA_Int32 n = 0;
+        ssize_t n = 0;
         do {
         do {
 #ifdef _WIN32
 #ifdef _WIN32
             n = send((SOCKET)connection->sockfd, (const char*)buf->data, (size_t)buf->length, 0);
             n = send((SOCKET)connection->sockfd, (const char*)buf->data, (size_t)buf->length, 0);
@@ -75,8 +91,8 @@ socket_write(UA_Connection *connection, UA_ByteString *buf) {
                 return UA_STATUSCODE_BADCONNECTIONCLOSED;
                 return UA_STATUSCODE_BADCONNECTIONCLOSED;
             }
             }
 #endif
 #endif
-        } while (n == -1L);
-        nWritten += n;
+        } while(n == -1L);
+        nWritten += (size_t)n;
     }
     }
     UA_ByteString_deleteMembers(buf);
     UA_ByteString_deleteMembers(buf);
     return UA_STATUSCODE_GOOD;
     return UA_STATUSCODE_GOOD;
@@ -93,8 +109,8 @@ socket_recv(UA_Connection *connection, UA_ByteString *response, UA_UInt32 timeou
     if(timeout > 0) {
     if(timeout > 0) {
         /* currently, only the client uses timeouts */
         /* currently, only the client uses timeouts */
 #ifndef _WIN32
 #ifndef _WIN32
-        int timeout_usec = timeout * 1000;
-        struct timeval tmptv = {timeout_usec / 1000000, timeout_usec % 1000000};
+        UA_UInt32 timeout_usec = timeout * 1000;
+        struct timeval tmptv = {(long int)(timeout_usec / 1000000), (long int)(timeout_usec % 1000000)};
         int ret = setsockopt(connection->sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tmptv, sizeof(struct timeval));
         int ret = setsockopt(connection->sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tmptv, sizeof(struct timeval));
 #else
 #else
         DWORD timeout_dw = timeout;
         DWORD timeout_dw = timeout;
@@ -107,7 +123,7 @@ socket_recv(UA_Connection *connection, UA_ByteString *response, UA_UInt32 timeou
         }
         }
     }
     }
 
 
-    int ret = recv(connection->sockfd, (char*)response->data, connection->localConf.recvBufferSize, 0);
+    ssize_t ret = recv(connection->sockfd, (char*)response->data, connection->localConf.recvBufferSize, 0);
 	if(ret == 0) {
 	if(ret == 0) {
         /* server has closed the connection */
         /* server has closed the connection */
         UA_ByteString_deleteMembers(response);
         UA_ByteString_deleteMembers(response);
@@ -128,7 +144,7 @@ socket_recv(UA_Connection *connection, UA_ByteString *response, UA_UInt32 timeou
             return UA_STATUSCODE_BADCONNECTIONCLOSED;
             return UA_STATUSCODE_BADCONNECTIONCLOSED;
         }
         }
     }
     }
-    response->length = ret;
+    response->length = (size_t)ret;
     return UA_STATUSCODE_GOOD;
     return UA_STATUSCODE_GOOD;
 }
 }
 
 
@@ -188,7 +204,7 @@ static void FreeConnectionCallback(UA_Server *server, void *ptr) {
 
 
 typedef struct {
 typedef struct {
     UA_ConnectionConfig conf;
     UA_ConnectionConfig conf;
-    UA_UInt32 port;
+    UA_UInt16 port;
     UA_Logger logger; // Set during start
     UA_Logger logger; // Set during start
     
     
     /* open sockets and connections */
     /* open sockets and connections */
@@ -221,10 +237,10 @@ ServerNetworkLayerReleaseRecvBuffer(UA_Connection *connection, UA_ByteString *bu
 static UA_Int32
 static UA_Int32
 setFDSet(ServerNetworkLayerTCP *layer, fd_set *fdset) {
 setFDSet(ServerNetworkLayerTCP *layer, fd_set *fdset) {
     FD_ZERO(fdset);
     FD_ZERO(fdset);
-    FD_SET((UA_UInt32)layer->serversockfd, fdset);
+    fd_set(layer->serversockfd, fdset);
     UA_Int32 highestfd = layer->serversockfd;
     UA_Int32 highestfd = layer->serversockfd;
     for(size_t i = 0; i < layer->mappingsSize; i++) {
     for(size_t i = 0; i < layer->mappingsSize; i++) {
-        FD_SET((UA_UInt32)layer->mappings[i].sockfd, fdset);
+        fd_set(layer->mappings[i].sockfd, fdset);
         if(layer->mappings[i].sockfd > highestfd)
         if(layer->mappings[i].sockfd > highestfd)
             highestfd = layer->mappings[i].sockfd;
             highestfd = layer->mappings[i].sockfd;
     }
     }
@@ -286,8 +302,25 @@ ServerNetworkLayerTCP_add(ServerNetworkLayerTCP *layer, UA_Int32 newsockfd) {
 }
 }
 
 
 static UA_StatusCode
 static UA_StatusCode
-ServerNetworkLayerTCP_start(UA_ServerNetworkLayer *nl) {
+ServerNetworkLayerTCP_start(UA_ServerNetworkLayer *nl, UA_Logger logger) {
     ServerNetworkLayerTCP *layer = nl->handle;
     ServerNetworkLayerTCP *layer = nl->handle;
+    layer->logger = logger;
+
+    /* get the discovery url from the hostname */
+    UA_String du = UA_STRING_NULL;
+    char hostname[256];
+    if(gethostname(hostname, 255) == 0) {
+        char discoveryUrl[256];
+#ifndef _MSC_VER
+        du.length = (size_t)snprintf(discoveryUrl, 255, "opc.tcp://%s:%d", hostname, layer->port);
+#else
+        du.length = (size_t)_snprintf_s(discoveryUrl, 255, _TRUNCATE, "opc.tcp://%s:%d", hostname, layer->port);
+#endif
+        du.data = (UA_Byte*)discoveryUrl;
+    }
+    UA_String_copy(&du, &nl->discoveryUrl);
+    
+    /* open the server socket */
 #ifdef _WIN32
 #ifdef _WIN32
     if((layer->serversockfd = socket(PF_INET, SOCK_STREAM,0)) == (UA_Int32)INVALID_SOCKET) {
     if((layer->serversockfd = socket(PF_INET, SOCK_STREAM,0)) == (UA_Int32)INVALID_SOCKET) {
         UA_LOG_WARNING(layer->logger, UA_LOGCATEGORY_NETWORK, "Error opening socket, code: %d",
         UA_LOG_WARNING(layer->logger, UA_LOGCATEGORY_NETWORK, "Error opening socket, code: %d",
@@ -338,7 +371,7 @@ ServerNetworkLayerTCP_getJobs(UA_ServerNetworkLayer *nl, UA_Job **jobs, UA_UInt1
     }
     }
 
 
     /* accept new connections (can only be a single one) */
     /* accept new connections (can only be a single one) */
-    if(FD_ISSET(layer->serversockfd, &fdset)) {
+    if(fd_isset(layer->serversockfd, &fdset)) {
         resultsize--;
         resultsize--;
         struct sockaddr_in cli_addr;
         struct sockaddr_in cli_addr;
         socklen_t cli_len = sizeof(cli_addr);
         socklen_t cli_len = sizeof(cli_addr);
@@ -354,7 +387,7 @@ ServerNetworkLayerTCP_getJobs(UA_ServerNetworkLayer *nl, UA_Job **jobs, UA_UInt1
     /* alloc enough space for a cleanup-connection and free-connection job per resulted socket */
     /* alloc enough space for a cleanup-connection and free-connection job per resulted socket */
     if(resultsize == 0)
     if(resultsize == 0)
         return 0;
         return 0;
-    UA_Job *js = malloc(sizeof(UA_Job) * resultsize * 2);
+    UA_Job *js = malloc(sizeof(UA_Job) * (size_t)resultsize * 2);
     if(!js)
     if(!js)
         return 0;
         return 0;
 
 
@@ -362,7 +395,7 @@ ServerNetworkLayerTCP_getJobs(UA_ServerNetworkLayer *nl, UA_Job **jobs, UA_UInt1
     size_t j = 0;
     size_t j = 0;
     UA_ByteString buf = UA_BYTESTRING_NULL;
     UA_ByteString buf = UA_BYTESTRING_NULL;
     for(size_t i = 0; i < layer->mappingsSize && j < (size_t)resultsize; i++) {
     for(size_t i = 0; i < layer->mappingsSize && j < (size_t)resultsize; i++) {
-        if(!(FD_ISSET(layer->mappings[i].sockfd, &fdset)))
+        if(!fd_isset(layer->mappings[i].sockfd, &fdset))
             continue;
             continue;
         UA_StatusCode retval = socket_recv(layer->mappings[i].connection, &buf, 0);
         UA_StatusCode retval = socket_recv(layer->mappings[i].connection, &buf, 0);
         if(retval == UA_STATUSCODE_GOOD) {
         if(retval == UA_STATUSCODE_GOOD) {
@@ -435,7 +468,7 @@ static void ServerNetworkLayerTCP_deleteMembers(UA_ServerNetworkLayer *nl) {
 }
 }
 
 
 UA_ServerNetworkLayer
 UA_ServerNetworkLayer
-UA_ServerNetworkLayerTCP(UA_ConnectionConfig conf, UA_UInt32 port, UA_Logger logger) {
+UA_ServerNetworkLayerTCP(UA_ConnectionConfig conf, UA_UInt16 port) {
 #ifdef _WIN32
 #ifdef _WIN32
     WORD wVersionRequested;
     WORD wVersionRequested;
     WSADATA wsaData;
     WSADATA wsaData;
@@ -445,31 +478,14 @@ UA_ServerNetworkLayerTCP(UA_ConnectionConfig conf, UA_UInt32 port, UA_Logger log
 
 
     UA_ServerNetworkLayer nl;
     UA_ServerNetworkLayer nl;
     memset(&nl, 0, sizeof(UA_ServerNetworkLayer));
     memset(&nl, 0, sizeof(UA_ServerNetworkLayer));
-    ServerNetworkLayerTCP *layer = malloc(sizeof(ServerNetworkLayerTCP));
+    ServerNetworkLayerTCP *layer = calloc(1,sizeof(ServerNetworkLayerTCP));
     if(!layer)
     if(!layer)
         return nl;
         return nl;
     
     
     layer->conf = conf;
     layer->conf = conf;
     layer->port = port;
     layer->port = port;
-    layer->logger = logger;
-    layer->mappingsSize = 0;
-    layer->mappings = NULL;
-
-    /* get the discovery url from the hostname */
-    UA_String du = UA_STRING_NULL;
-    char hostname[256];
-    if(gethostname(hostname, 255) == 0) {
-        char discoveryUrl[256];
-#ifndef _MSC_VER
-        du.length = snprintf(discoveryUrl, 255, "opc.tcp://%s:%d", hostname, port);
-#else
-        du.length = _snprintf_s(discoveryUrl, 255, _TRUNCATE, "opc.tcp://%s:%d", hostname, port);
-#endif
-        du.data = (UA_Byte*)discoveryUrl;
-    }
 
 
     nl.handle = layer;
     nl.handle = layer;
-    UA_String_copy(&du, &nl.discoveryUrl);
     nl.start = ServerNetworkLayerTCP_start;
     nl.start = ServerNetworkLayerTCP_start;
     nl.getJobs = ServerNetworkLayerTCP_getJobs;
     nl.getJobs = ServerNetworkLayerTCP_getJobs;
     nl.stop = ServerNetworkLayerTCP_stop;
     nl.stop = ServerNetworkLayerTCP_stop;
@@ -572,7 +588,7 @@ UA_ClientConnectionTCP(UA_ConnectionConfig localConf, const char *endpointUrl, U
     }
     }
     struct sockaddr_in server_addr;
     struct sockaddr_in server_addr;
     memset(&server_addr, 0, sizeof(server_addr));
     memset(&server_addr, 0, sizeof(server_addr));
-    memcpy((char *)&server_addr.sin_addr.s_addr, (char *)server->h_addr_list[0], server->h_length);
+    memcpy((char *)&server_addr.sin_addr.s_addr, (char *)server->h_addr_list[0], (size_t)server->h_length);
     server_addr.sin_family = AF_INET;
     server_addr.sin_family = AF_INET;
     server_addr.sin_port = htons(port);
     server_addr.sin_port = htons(port);
     connection.state = UA_CONNECTION_OPENING;
     connection.state = UA_CONNECTION_OPENING;

+ 1 - 1
src_extra/networklayer_tcp.h

@@ -15,7 +15,7 @@ extern "C" {
 
 
 /** @brief Create the TCP networklayer and listen to the specified port */
 /** @brief Create the TCP networklayer and listen to the specified port */
 UA_ServerNetworkLayer UA_EXPORT
 UA_ServerNetworkLayer UA_EXPORT
-UA_ServerNetworkLayerTCP(UA_ConnectionConfig conf, UA_UInt32 port, UA_Logger logger);
+UA_ServerNetworkLayerTCP(UA_ConnectionConfig conf, UA_UInt16 port);
 
 
 UA_Connection UA_EXPORT
 UA_Connection UA_EXPORT
 UA_ClientConnectionTCP(UA_ConnectionConfig conf, const char *endpointUrl, UA_Logger logger);
 UA_ClientConnectionTCP(UA_ConnectionConfig conf, const char *endpointUrl, UA_Logger logger);

+ 2 - 0
tests/CMakeLists.txt

@@ -19,6 +19,8 @@ if(UA_ENABLE_MULTITHREADING)
     list(APPEND LIBS urcu-cds urcu urcu-common)
     list(APPEND LIBS urcu-cds urcu urcu-common)
 endif()
 endif()
 
 
+add_definitions(-Wno-sign-conversion)
+
 # the unit test are built directly on the open62541 object files. so they can
 # the unit test are built directly on the open62541 object files. so they can
 # access symbols that are hidden/not exported to the shared library
 # access symbols that are hidden/not exported to the shared library
 
 

+ 8 - 5
tests/check_builtin.c

@@ -396,14 +396,14 @@ END_TEST
 START_TEST(UA_Variant_decodeWithOutArrayFlagSetShallSetVTAndAllocateMemoryForArray) {
 START_TEST(UA_Variant_decodeWithOutArrayFlagSetShallSetVTAndAllocateMemoryForArray) {
     // given
     // given
     size_t pos = 0;
     size_t pos = 0;
-    UA_Byte data[] = { UA_TYPES[UA_TYPES_INT32].typeId.identifier.numeric, 0xFF, 0x00, 0x00, 0x00 };
+    UA_Byte data[] = { (UA_Byte)UA_TYPES[UA_TYPES_INT32].typeId.identifier.numeric, 0xFF, 0x00, 0x00, 0x00 };
     UA_ByteString src = { 5, data };
     UA_ByteString src = { 5, data };
     UA_Variant dst;
     UA_Variant dst;
     // when
     // when
     UA_StatusCode retval = UA_Variant_decodeBinary(&src, &pos, &dst);
     UA_StatusCode retval = UA_Variant_decodeBinary(&src, &pos, &dst);
     // then
     // then
     ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
     ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
-    ck_assert_int_eq(pos, 5);
+    ck_assert_uint_eq(pos, 5);
     ck_assert_uint_eq(pos, UA_calcSizeBinary(&dst, &UA_TYPES[UA_TYPES_VARIANT]));
     ck_assert_uint_eq(pos, UA_calcSizeBinary(&dst, &UA_TYPES[UA_TYPES_VARIANT]));
     //ck_assert_ptr_eq((const void *)dst.type, (const void *)&UA_TYPES[UA_TYPES_INT32]); //does not compile in gcc 4.6
     //ck_assert_ptr_eq((const void *)dst.type, (const void *)&UA_TYPES[UA_TYPES_INT32]); //does not compile in gcc 4.6
     ck_assert_int_eq((uintptr_t)dst.type, (uintptr_t)&UA_TYPES[UA_TYPES_INT32]); 
     ck_assert_int_eq((uintptr_t)dst.type, (uintptr_t)&UA_TYPES[UA_TYPES_INT32]); 
@@ -418,7 +418,8 @@ END_TEST
 START_TEST(UA_Variant_decodeWithArrayFlagSetShallSetVTAndAllocateMemoryForArray) {
 START_TEST(UA_Variant_decodeWithArrayFlagSetShallSetVTAndAllocateMemoryForArray) {
     // given
     // given
     size_t pos = 0;
     size_t pos = 0;
-    UA_Byte data[] = { UA_TYPES[UA_TYPES_INT32].typeId.identifier.numeric | UA_VARIANT_ENCODINGMASKTYPE_ARRAY,
+    UA_Byte data[] = { (UA_Byte)(UA_TYPES[UA_TYPES_INT32].typeId.identifier.numeric |
+                                 UA_VARIANT_ENCODINGMASKTYPE_ARRAY),
                        0x02, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF,
                        0x02, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF,
                        0xFF, 0xFF };
                        0xFF, 0xFF };
     UA_ByteString src = { 13, data };
     UA_ByteString src = { 13, data };
@@ -498,7 +499,8 @@ END_TEST
 START_TEST(UA_Variant_decodeWithOutDeleteMembersShallFailInCheckMem) {
 START_TEST(UA_Variant_decodeWithOutDeleteMembersShallFailInCheckMem) {
     // given
     // given
     size_t pos = 0;
     size_t pos = 0;
-    UA_Byte data[] = { UA_TYPES[UA_TYPES_INT32].typeId.identifier.numeric | UA_VARIANT_ENCODINGMASKTYPE_ARRAY,
+    UA_Byte data[] = { (UA_Byte)(UA_TYPES[UA_TYPES_INT32].typeId.identifier.numeric |
+                                 UA_VARIANT_ENCODINGMASKTYPE_ARRAY),
                        0x02, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF };
                        0x02, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF };
     UA_ByteString src = { 13, data };
     UA_ByteString src = { 13, data };
     UA_Variant dst;
     UA_Variant dst;
@@ -514,7 +516,8 @@ END_TEST
 START_TEST(UA_Variant_decodeWithTooSmallSourceShallReturnWithError) {
 START_TEST(UA_Variant_decodeWithTooSmallSourceShallReturnWithError) {
     // given
     // given
     size_t pos = 0;
     size_t pos = 0;
-    UA_Byte data[] = { UA_TYPES[UA_TYPES_INT32].typeId.identifier.numeric | UA_VARIANT_ENCODINGMASKTYPE_ARRAY,
+    UA_Byte data[] = { (UA_Byte)(UA_TYPES[UA_TYPES_INT32].typeId.identifier.numeric |
+                                 UA_VARIANT_ENCODINGMASKTYPE_ARRAY),
                        0x02, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF };
                        0x02, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF };
     UA_ByteString src = { 4, data };
     UA_ByteString src = { 4, data };
 
 

+ 1 - 1
tools/pyUANamespace/open62541_MacroHelper.py

@@ -141,7 +141,7 @@ class open62541_MacroHelper():
     else:
     else:
       # FIXME:  Semantic of inputArgumentSize = -1 is used to signal the suppression of argument creation.
       # FIXME:  Semantic of inputArgumentSize = -1 is used to signal the suppression of argument creation.
       #         This should be replaced with a properly generated struct for the arguments.
       #         This should be replaced with a properly generated struct for the arguments.
-      code.append("       , attr, (UA_MethodCallback) NULL, NULL, -1, NULL, -1, NULL, NULL);")
+      code.append("       , attr, (UA_MethodCallback) NULL, NULL, 0, NULL, 0, NULL, NULL);")
     return code
     return code
     
     
   def getCreateNodeBootstrap(self, node):
   def getCreateNodeBootstrap(self, node):