StalderT лет назад: 7
Родитель
Сommit
7e30f66b0b

+ 4 - 4
examples/client.c

@@ -37,7 +37,7 @@ int main(int argc, char *argv[]) {
         return (int)retval;
     }
     printf("%i endpoints found\n", (int)endpointArraySize);
-    for(size_t i=0;i<endpointArraySize;i++){
+    for(size_t i=0;i<endpointArraySize;i++) {
         printf("URL of endpoint %i is %.*s\n", (int)i,
                (int)endpointArray[i].endpointUrl.length,
                endpointArray[i].endpointUrl.data);
@@ -63,8 +63,8 @@ int main(int argc, char *argv[]) {
     bReq.nodesToBrowse[0].resultMask = UA_BROWSERESULTMASK_ALL; /* return everything */
     UA_BrowseResponse bResp = UA_Client_Service_browse(client, bReq);
     printf("%-9s %-16s %-16s %-16s\n", "NAMESPACE", "NODEID", "BROWSE NAME", "DISPLAY NAME");
-    for (size_t i = 0; i < bResp.resultsSize; ++i) {
-        for (size_t j = 0; j < bResp.results[i].referencesSize; ++j) {
+    for(size_t i = 0; i < bResp.resultsSize; ++i) {
+        for(size_t j = 0; j < bResp.results[i].referencesSize; ++j) {
             UA_ReferenceDescription *ref = &(bResp.results[i].references[j]);
             if(ref->nodeId.nodeId.identifierType == UA_NODEIDTYPE_NUMERIC) {
                 printf("%-9d %-16d %-16.*s %-16.*s\n", ref->nodeId.nodeId.namespaceIndex,
@@ -102,7 +102,7 @@ int main(int argc, char *argv[]) {
     UA_UInt32 monId = 0;
     UA_Client_Subscriptions_addMonitoredItem(client, subId, monitorThis, UA_ATTRIBUTEID_VALUE,
                                              &handler_TheAnswerChanged, NULL, &monId, 250);
-    if (monId)
+    if(monId)
         printf("Monitoring 'the.answer', id %u\n", subId);
     /* The first publish request should return the initial value of the variable */
     UA_Client_Subscriptions_manuallySendPublishRequest(client);

+ 5 - 5
examples/client_connect_loop.c

@@ -56,12 +56,12 @@ int main(void) {
     UA_Variant_init(&value);
 
     /* Endless loop reading the server time */
-    while (running) {
+    while(running) {
         /* if already connected, this will return GOOD and do nothing */
         /* if the connection is closed/errored, the connection will be reset and then reconnected */
         /* Alternatively you can also use UA_Client_getState to get the current state */
         UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
-        if (retval != UA_STATUSCODE_GOOD) {
+        if(retval != UA_STATUSCODE_GOOD) {
             UA_LOG_ERROR(logger, UA_LOGCATEGORY_CLIENT, "Not connected. Retrying to connect in 1 second");
             /* The connect may timeout after 1 second (see above) or it may fail immediately on network errors */
             /* E.g. name resolution errors or unreachable network. Thus there should be a small sleep here */
@@ -74,12 +74,12 @@ int main(void) {
                 UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_CURRENTTIME);
 
         retval = UA_Client_readValueAttribute(client, nodeId, &value);
-        if (retval == UA_STATUSCODE_BADCONNECTIONCLOSED) {
+        if(retval == UA_STATUSCODE_BADCONNECTIONCLOSED) {
             UA_LOG_ERROR(logger, UA_LOGCATEGORY_CLIENT, "Connection was closed. Reconnecting ...");
             continue;
         }
-        if (retval == UA_STATUSCODE_GOOD &&
-            UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_DATETIME])) {
+        if(retval == UA_STATUSCODE_GOOD &&
+           UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_DATETIME])) {
             UA_DateTime raw_date = *(UA_DateTime *) value.data;
             UA_DateTimeStruct dts = UA_DateTime_toStruct(raw_date);
             UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "date is: %02u-%02u-%04u %02u:%02u:%02u.%03u",

+ 6 - 6
examples/client_subscription_loop.c

@@ -45,7 +45,7 @@ static void stopHandler(int sign) {
 static void
 handler_currentTimeChanged(UA_UInt32 monId, UA_DataValue *value, void *context) {
     UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "currentTime has changed!");
-    if (UA_Variant_hasScalarType(&value->value, &UA_TYPES[UA_TYPES_DATETIME])) {
+    if(UA_Variant_hasScalarType(&value->value, &UA_TYPES[UA_TYPES_DATETIME])) {
         UA_DateTime raw_date = *(UA_DateTime *) value->value.data;
         UA_DateTimeStruct dts = UA_DateTime_toStruct(raw_date);
         UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "date is: %02u-%02u-%04u %02u:%02u:%02u.%03u",
@@ -54,9 +54,9 @@ handler_currentTimeChanged(UA_UInt32 monId, UA_DataValue *value, void *context)
 }
 
 static void
-stateCallback (UA_Client *client, UA_ClientState clientState){
+stateCallback (UA_Client *client, UA_ClientState clientState) {
 
-    switch (clientState){
+    switch(clientState) {
         case UA_CLIENTSTATE_DISCONNECTED:
             UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "The client is disconnected");
         break; 
@@ -82,7 +82,7 @@ stateCallback (UA_Client *client, UA_ClientState clientState){
             UA_NodeId monitorThis = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_CURRENTTIME);
             UA_Client_Subscriptions_addMonitoredItem(client, subId, monitorThis, UA_ATTRIBUTEID_VALUE,
                                                      &handler_currentTimeChanged, NULL, &monId, 250);
-            if (monId)
+            if(monId)
                 UA_LOG_INFO(logger, UA_LOGCATEGORY_USERLAND, "Monitoring UA_NS0ID_SERVER_SERVERSTATUS_CURRENTTIME', id %u", subId);
         }
         break; 
@@ -103,12 +103,12 @@ int main(void) {
     UA_Client *client = UA_Client_new(config);
 
     /* Endless loop SendPublishRequest */
-    while (running) {
+    while(running) {
         /* if already connected, this will return GOOD and do nothing */
         /* if the connection is closed/errored, the connection will be reset and then reconnected */
         /* Alternatively you can also use UA_Client_getState to get the current state */
         UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
-        if (retval != UA_STATUSCODE_GOOD) {
+        if(retval != UA_STATUSCODE_GOOD) {
             UA_LOG_ERROR(logger, UA_LOGCATEGORY_USERLAND, "Not connected. Retrying to connect in 1 second");
             /* The connect may timeout after 1 second (see above) or it may fail immediately on network errors */
             /* E.g. name resolution errors or unreachable network. Thus there should be a small sleep here */

+ 2 - 2
examples/custom_datatype/client_types_custom.c

@@ -16,7 +16,7 @@ int main(void) {
 
     UA_Client *client = UA_Client_new(config);
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
-    if (retval != UA_STATUSCODE_GOOD) {
+    if(retval != UA_STATUSCODE_GOOD) {
         UA_Client_delete(client);
         return (int)retval;
     }
@@ -29,7 +29,7 @@ int main(void) {
 
     retval = UA_Client_readValueAttribute(client, nodeId, &value);
             
-    if (retval == UA_STATUSCODE_GOOD) {
+    if(retval == UA_STATUSCODE_GOOD) {
         Point *p = (Point *)value.data;
         printf("Point = %f, %f, %f \n", p->x, p->y, p->z);
     }

+ 12 - 12
examples/discovery/client_find_servers.c

@@ -26,7 +26,7 @@ int main(void) {
         UA_Client *client = UA_Client_new(UA_ClientConfig_default);
         UA_StatusCode retval = UA_Client_findServersOnNetwork(client, DISCOVERY_SERVER_ENDPOINT, 0, 0,
                                                               0, NULL, &serverOnNetworkSize, &serverOnNetwork);
-        if (retval != UA_STATUSCODE_GOOD) {
+        if(retval != UA_STATUSCODE_GOOD) {
             UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER,
                          "Could not call FindServersOnNetwork service. "
                          "Is the discovery server started? StatusCode %s",
@@ -36,7 +36,7 @@ int main(void) {
         }
 
         // output all the returned/registered servers
-        for (size_t i = 0; i < serverOnNetworkSize; i++) {
+        for(size_t i = 0; i < serverOnNetworkSize; i++) {
             UA_ServerOnNetwork *server = &serverOnNetwork[i];
             printf("Server[%lu]: %.*s", (unsigned long) i,
                    (int) server->serverName.length, server->serverName.data);
@@ -44,7 +44,7 @@ int main(void) {
             printf("\n\tDiscovery URL: %.*s", (int) server->discoveryUrl.length,
                    server->discoveryUrl.data);
             printf("\n\tCapabilities: ");
-            for (size_t j = 0; j < server->serverCapabilitiesSize; j++) {
+            for(size_t j = 0; j < server->serverCapabilitiesSize; j++) {
                 printf("%.*s,", (int) server->serverCapabilities[j].length,
                        server->serverCapabilities[j].data);
             }
@@ -66,14 +66,14 @@ int main(void) {
                                        &applicationDescriptionArraySize, &applicationDescriptionArray);
         UA_Client_delete(client);
     }
-    if (retval != UA_STATUSCODE_GOOD) {
+    if(retval != UA_STATUSCODE_GOOD) {
         UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER, "Could not call FindServers service. "
                 "Is the discovery server started? StatusCode %s", UA_StatusCode_name(retval));
         return (int) retval;
     }
 
     // output all the returned/registered servers
-    for (size_t i = 0; i < applicationDescriptionArraySize; i++) {
+    for(size_t i = 0; i < applicationDescriptionArraySize; i++) {
         UA_ApplicationDescription *description = &applicationDescriptionArray[i];
         printf("Server[%lu]: %.*s", (unsigned long) i, (int) description->applicationUri.length,
                description->applicationUri.data);
@@ -84,7 +84,7 @@ int main(void) {
         printf("\n\tProduct URI: %.*s", (int) description->productUri.length,
                description->productUri.data);
         printf("\n\tType: ");
-        switch (description->applicationType) {
+        switch(description->applicationType) {
             case UA_APPLICATIONTYPE_SERVER:
                 printf("Server");
                 break;
@@ -101,7 +101,7 @@ int main(void) {
                 printf("Unknown");
         }
         printf("\n\tDiscovery URLs:");
-        for (size_t j = 0; j < description->discoveryUrlsSize; j++) {
+        for(size_t j = 0; j < description->discoveryUrlsSize; j++) {
             printf("\n\t\t[%lu]: %.*s", (unsigned long) j,
                    (int) description->discoveryUrls[j].length,
                    description->discoveryUrls[j].data);
@@ -116,9 +116,9 @@ int main(void) {
 
     printf("-------- Server Endpoints --------\n");
 
-    for (size_t i = 0; i < applicationDescriptionArraySize; i++) {
+    for(size_t i = 0; i < applicationDescriptionArraySize; i++) {
         UA_ApplicationDescription *description = &applicationDescriptionArray[i];
-        if (description->discoveryUrlsSize == 0) {
+        if(description->discoveryUrlsSize == 0) {
             UA_LOG_INFO(logger, UA_LOGCATEGORY_CLIENT,
                         "[GetEndpoints] Server %.*s did not provide any discovery urls. Skipping.",
                         (int)description->applicationUri.length, description->applicationUri.data);
@@ -138,20 +138,20 @@ int main(void) {
         size_t endpointArraySize = 0;
         retval = UA_Client_getEndpoints(client, discoveryUrl, &endpointArraySize, &endpointArray);
         UA_free(discoveryUrl);
-        if (retval != UA_STATUSCODE_GOOD) {
+        if(retval != UA_STATUSCODE_GOOD) {
             UA_Client_disconnect(client);
             UA_Client_delete(client);
             break;
         }
 
-        for (size_t j = 0; j < endpointArraySize; j++) {
+        for(size_t j = 0; j < endpointArraySize; j++) {
             UA_EndpointDescription *endpoint = &endpointArray[j];
             printf("\n\tEndpoint[%lu]:", (unsigned long) j);
             printf("\n\t\tEndpoint URL: %.*s", (int) endpoint->endpointUrl.length, endpoint->endpointUrl.data);
             printf("\n\t\tTransport profile URI: %.*s", (int) endpoint->transportProfileUri.length,
                    endpoint->transportProfileUri.data);
             printf("\n\t\tSecurity Mode: ");
-            switch (endpoint->securityMode) {
+            switch(endpoint->securityMode) {
             case UA_MESSAGESECURITYMODE_INVALID:
                 printf("Invalid");
                 break;

+ 7 - 7
examples/discovery/server_multicast.c

@@ -64,19 +64,19 @@ static void
 serverOnNetworkCallback(const UA_ServerOnNetwork *serverOnNetwork, UA_Boolean isServerAnnounce,
                         UA_Boolean isTxtReceived, void *data) {
 
-    if (discovery_url != NULL || !isServerAnnounce) {
+    if(discovery_url != NULL || !isServerAnnounce) {
         UA_LOG_DEBUG(logger, UA_LOGCATEGORY_SERVER,
                      "serverOnNetworkCallback called, but discovery URL "
                      "already initialized or is not announcing. Ignoring.");
         return; // we already have everything we need or we only want server announces
     }
 
-    if (self_discovery_url != NULL && UA_String_equal(&serverOnNetwork->discoveryUrl, self_discovery_url)) {
+    if(self_discovery_url != NULL && UA_String_equal(&serverOnNetwork->discoveryUrl, self_discovery_url)) {
         // skip self
         return;
     }
 
-    if (!isTxtReceived)
+    if(!isTxtReceived)
         return; // we wait until the corresponding TXT record is announced.
                 // Problem: how to handle if a Server does not announce the
                 // optional TXT?
@@ -87,7 +87,7 @@ serverOnNetworkCallback(const UA_ServerOnNetwork *serverOnNetwork, UA_Boolean is
     UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER, "Another server announced itself on %.*s",
                 (int)serverOnNetwork->discoveryUrl.length, serverOnNetwork->discoveryUrl.data);
 
-    if (discovery_url != NULL)
+    if(discovery_url != NULL)
         UA_free(discovery_url);
     discovery_url = (char*)UA_malloc(serverOnNetwork->discoveryUrl.length + 1);
     memcpy(discovery_url, serverOnNetwork->discoveryUrl.data, serverOnNetwork->discoveryUrl.length);
@@ -134,7 +134,7 @@ int main(int argc, char **argv) {
 
     // Start the server and call iterate to wait for the multicast discovery of the LDS
     UA_StatusCode retval = UA_Server_run_startup(server);
-    if (retval != UA_STATUSCODE_GOOD) {
+    if(retval != UA_STATUSCODE_GOOD) {
         UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER,
                      "Could not start the server. StatusCode %s",
                      UA_StatusCode_name(retval));
@@ -147,7 +147,7 @@ int main(int argc, char **argv) {
                 "Server started. Waiting for announce of LDS Server.");
     while (running && discovery_url == NULL)
         UA_Server_run_iterate(server, true);
-    if (!running) {
+    if(!running) {
         UA_Server_delete(server);
         UA_ServerConfig_delete(config);
         UA_free(discovery_url);
@@ -158,7 +158,7 @@ int main(int argc, char **argv) {
     // periodic server register after 10 Minutes, delay first register for 500ms
     retval = UA_Server_addPeriodicServerRegisterCallback(server, discovery_url,
                                                          10 * 60 * 1000, 500, NULL);
-    if (retval != UA_STATUSCODE_GOOD) {
+    if(retval != UA_STATUSCODE_GOOD) {
         UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER,
                      "Could not create periodic job for server register. StatusCode %s",
                      UA_StatusCode_name(retval));

+ 2 - 2
examples/discovery/server_register.c

@@ -98,7 +98,7 @@ int main(int argc, char **argv) {
                                                     10 * 60 * 1000, 500, NULL);
     // UA_StatusCode retval = UA_Server_addPeriodicServerRegisterJob(server,
     // "opc.tcp://localhost:4840", 10*60*1000, 500, NULL);
-    if (retval != UA_STATUSCODE_GOOD) {
+    if(retval != UA_STATUSCODE_GOOD) {
         UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER,
                      "Could not create periodic job for server register. StatusCode %s",
                      UA_StatusCode_name(retval));
@@ -108,7 +108,7 @@ int main(int argc, char **argv) {
     }
 
     retval = UA_Server_run(server, &running);
-    if (retval != UA_STATUSCODE_GOOD) {
+    if(retval != UA_STATUSCODE_GOOD) {
         UA_LOG_ERROR(logger, UA_LOGCATEGORY_SERVER,
                      "Could not start the server. StatusCode %s",
                      UA_StatusCode_name(retval));

+ 1 - 1
examples/server_certificate.c

@@ -27,7 +27,7 @@ static UA_ByteString loadCertificate(void) {
     fseek(fp, 0, SEEK_END);
     certificate.length = (size_t)ftell(fp);
     certificate.data = (UA_Byte *)UA_malloc(certificate.length*sizeof(UA_Byte));
-    if(!certificate.data){
+    if(!certificate.data) {
         fclose(fp);
         return UA_STRING_NULL;
     }

+ 1 - 1
examples/tutorial_client_events.c

@@ -22,7 +22,7 @@ handler_events(const UA_UInt32 monId, const size_t nEventFields,
     UA_assert(*(UA_UInt32*)context == monId);
 
     for(size_t i = 0; i < nEventFields; ++i) {
-        if (UA_Variant_hasScalarType(&eventFields[i], &UA_TYPES[UA_TYPES_UINT16])) {
+        if(UA_Variant_hasScalarType(&eventFields[i], &UA_TYPES[UA_TYPES_UINT16])) {
             UA_UInt16 severity = *(UA_UInt16 *)eventFields[i].data;
             UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Severity: %u", severity);
         } else if (UA_Variant_hasScalarType(&eventFields[i], &UA_TYPES[UA_TYPES_LOCALIZEDTEXT])) {

+ 2 - 2
examples/tutorial_client_firststeps.c

@@ -28,8 +28,8 @@ int main(void) {
     const UA_NodeId nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_CURRENTTIME);
     retval = UA_Client_readValueAttribute(client, nodeId, &value);
 
-    if (retval == UA_STATUSCODE_GOOD &&
-        UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_DATETIME])) {
+    if(retval == UA_STATUSCODE_GOOD &&
+       UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_DATETIME])) {
         UA_DateTime raw_date = *(UA_DateTime *) value.data;
         UA_DateTimeStruct dts = UA_DateTime_toStruct(raw_date);
         UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "date is: %u-%u-%u %u:%u:%u.%03u\n",

+ 3 - 3
src/client/ua_client.c

@@ -22,7 +22,7 @@ UA_Client_init(UA_Client* client, UA_ClientConfig config) {
     client->channel.securityPolicy = &client->securityPolicy;
     client->channel.securityMode = UA_MESSAGESECURITYMODE_NONE;
     client->config = config;
-    if (client->config.stateCallback)
+    if(client->config.stateCallback)
         client->config.stateCallback(client, client->state);
 }
 
@@ -285,7 +285,7 @@ receiveServiceResponse(UA_Client *client, void *response, const UA_DataType *res
             return UA_STATUSCODE_GOODNONCRITICALTIMEOUT;
 
         /* round always to upper value to avoid timeout to be set to 0
-         * if (maxDate - now) < (UA_DATETIME_MSEC/2) */
+         * if(maxDate - now) < (UA_DATETIME_MSEC/2) */
         UA_UInt32 timeout = (UA_UInt32)(((maxDate - now) + (UA_DATETIME_MSEC - 1)) / UA_DATETIME_MSEC);
 
         retval = UA_Connection_receiveChunksBlocking(&client->connection, &rd, client_processChunk, timeout);
@@ -323,7 +323,7 @@ __UA_Client_Service(UA_Client *client, const void *request,
     UA_DateTime maxDate = UA_DateTime_nowMonotonic() +
         (client->config.timeout * UA_DATETIME_MSEC);
     retval = receiveServiceResponse(client, response, responseType, maxDate, &requestId);
-    if (retval == UA_STATUSCODE_GOODNONCRITICALTIMEOUT){
+    if(retval == UA_STATUSCODE_GOODNONCRITICALTIMEOUT) {
         /* In synchronous service, if we have don't have a reply we need to close the connection */
         UA_Client_close(client);
         retval = UA_STATUSCODE_BADCONNECTIONCLOSED;

+ 8 - 8
src/client/ua_client_connect.c

@@ -19,9 +19,9 @@
 static void
 setClientState(UA_Client *client, UA_ClientState state)
 {
-    if (client->state != state){
+    if(client->state != state) {
         client->state = state;
-        if (client->config.stateCallback)
+        if(client->config.stateCallback)
             client->config.stateCallback(client, client->state);
     }
 }
@@ -110,7 +110,7 @@ HelAckHandshake(UA_Client *client) {
     /* Loop until we have a complete chunk */
     retval = UA_Connection_receiveChunksBlocking(conn, client, processACKResponse,
                                                  client->config.timeout);
-    if(retval != UA_STATUSCODE_GOOD){
+    if(retval != UA_STATUSCODE_GOOD) {
         UA_LOG_INFO(client->config.logger, UA_LOGCATEGORY_NETWORK,
                     "Receiving ACK message failed");
         if(retval == UA_STATUSCODE_BADCONNECTIONCLOSED)
@@ -418,13 +418,13 @@ UA_Client_connectInternal(UA_Client *client, const char *endpointUrl,
         if(retval == UA_STATUSCODE_BADSESSIONIDINVALID) {
             /* Could not recover an old session. Remove authenticationToken */
             UA_NodeId_deleteMembers(&client->authenticationToken);
-        }else{
+        } else {
             if(retval != UA_STATUSCODE_GOOD)
                 goto cleanup;
             setClientState(client, UA_CLIENTSTATE_SESSION_RENEWED);
             return retval;
         }
-    }else{
+    } else {
         UA_NodeId_deleteMembers(&client->authenticationToken);
     }
 
@@ -518,7 +518,7 @@ sendCloseSecureChannel(UA_Client *client) {
 UA_StatusCode
 UA_Client_disconnect(UA_Client *client) {
     /* Is a session established? */
-    if(client->state >= UA_CLIENTSTATE_SESSION){
+    if(client->state >= UA_CLIENTSTATE_SESSION) {
         client->state = UA_CLIENTSTATE_SECURECHANNEL;
         sendCloseSession(client);
     }
@@ -526,7 +526,7 @@ UA_Client_disconnect(UA_Client *client) {
     client->requestHandle = 0;
 
     /* Is a secure channel established? */
-    if(client->state >= UA_CLIENTSTATE_SECURECHANNEL){
+    if(client->state >= UA_CLIENTSTATE_SECURECHANNEL) {
         client->state = UA_CLIENTSTATE_CONNECTED;
         sendCloseSecureChannel(client);
     }
@@ -543,7 +543,7 @@ UA_StatusCode
 UA_Client_close(UA_Client *client) {
     client->requestHandle = 0;
 
-    if (client->state >= UA_CLIENTSTATE_SECURECHANNEL)
+    if(client->state >= UA_CLIENTSTATE_SECURECHANNEL)
         UA_SecureChannel_deleteMembersCleanup(&client->channel);
 
     /* Close the TCP connection */

+ 1 - 1
src/client/ua_client_highlevel.c

@@ -35,7 +35,7 @@ UA_Client_NamespaceGetIndex(UA_Client *client, UA_String *namespaceUri,
 
     retval = UA_STATUSCODE_BADNOTFOUND;
     UA_String *ns = (UA_String *)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])) {
             *namespaceIndex = (UA_UInt16)i;
             retval = UA_STATUSCODE_GOOD;

+ 5 - 5
src/client/ua_client_highlevel_subscriptions.c

@@ -320,7 +320,7 @@ UA_Client_Subscriptions_removeMonitoredItems(UA_Client *client, UA_UInt32 subscr
         }
         UA_Client_MonitoredItem *mon;
         LIST_FOREACH(mon, &sub->monitoredItems, listEntry) {
-            if(mon->monitoredItemId == monitoredItemId[i]){
+            if(mon->monitoredItemId == monitoredItemId[i]) {
                 LIST_REMOVE(mon, listEntry);
                 UA_NodeId_deleteMembers(&mon->monitoredNodeId);
                 UA_free(mon);
@@ -424,7 +424,7 @@ UA_Client_processPublishResponse(UA_Client *client, UA_PublishRequest *request,
         if(msg->notificationData[k].content.decoded.type == &UA_TYPES[UA_TYPES_EVENTNOTIFICATIONLIST]) {
             UA_EventNotificationList *eventNotificationList =
                 (UA_EventNotificationList *)msg->notificationData[k].content.decoded.data;
-            for (size_t j = 0; j < eventNotificationList->eventsSize; ++j) {
+            for(size_t j = 0; j < eventNotificationList->eventsSize; ++j) {
                 UA_EventFieldList *eventFieldList = &eventNotificationList->events[j];
 
                 /* Find the MonitoredItem */
@@ -505,10 +505,10 @@ UA_Client_Subscriptions_manuallySendPublishRequest(UA_Client *client) {
         UA_Client_processPublishResponse(client, &request, &response);
         
         now = UA_DateTime_nowMonotonic();
-        if (now > maxDate){
+        if(now > maxDate) {
             moreNotifications = UA_FALSE;
             retval = UA_STATUSCODE_GOODNONCRITICALTIMEOUT;
-        }else{
+        } else {
             moreNotifications = response.moreNotifications;
         }
         
@@ -523,7 +523,7 @@ UA_Client_Subscriptions_manuallySendPublishRequest(UA_Client *client) {
 }
 
 void
-UA_Client_Subscriptions_clean(UA_Client *client){
+UA_Client_Subscriptions_clean(UA_Client *client) {
     UA_Client_NotificationsAckNumber *n, *tmp;
     LIST_FOREACH_SAFE(n, &client->pendingNotificationsAcks, listEntry, tmp) {
         LIST_REMOVE(n, listEntry);

+ 14 - 14
src/server/ua_mdns.c

@@ -78,14 +78,14 @@ mdns_record_add_or_get(UA_Server *server, const char *record, const char *server
     int hashIdx = mdns_hash_record(record) % SERVER_ON_NETWORK_HASH_PRIME;
     struct serverOnNetwork_hash_entry *hash_entry = server->serverOnNetworkHash[hashIdx];
 
-    while (hash_entry) {
+    while(hash_entry) {
         size_t maxLen;
-        if (serverNameLen > hash_entry->entry->serverOnNetwork.serverName.length)
+        if(serverNameLen > hash_entry->entry->serverOnNetwork.serverName.length)
             maxLen = hash_entry->entry->serverOnNetwork.serverName.length;
         else
             maxLen = serverNameLen;
 
-        if (strncmp((char *) hash_entry->entry->serverOnNetwork.serverName.data, serverName, maxLen) == 0)
+        if(strncmp((char *) hash_entry->entry->serverOnNetwork.serverName.data, serverName, maxLen) == 0)
             return hash_entry->entry;
         hash_entry = hash_entry->next;
     }
@@ -108,7 +108,7 @@ mdns_record_add_or_get(UA_Server *server, const char *record, const char *server
     listEntry->serverOnNetwork.serverName.data = (UA_Byte*)UA_malloc(serverNameLen);
     memcpy(listEntry->serverOnNetwork.serverName.data, serverName, serverNameLen);
     server->serverOnNetworkRecordIdCounter = UA_atomic_add(&server->serverOnNetworkRecordIdCounter, 1);
-    if (server->serverOnNetworkRecordIdCounter == 0)
+    if(server->serverOnNetworkRecordIdCounter == 0)
         server->serverOnNetworkRecordIdLastReset = UA_DateTime_now();
 
     // add to hash
@@ -190,7 +190,7 @@ setTxt(const struct resource *r,
     char *caps = (char *) xht_get(x, "caps");
 
     if(path && strlen(path) > 1) {
-        if (!entry->srvSet) {
+        if(!entry->srvSet) {
             /* txt arrived before SRV, thus cache path entry */
             // todo: malloc in strdup may fail: return a statuscode
             entry->pathTmp = UA_STRDUP(path);
@@ -220,7 +220,7 @@ setTxt(const struct resource *r,
             // todo: malloc may fail: return a statuscode
             entry->serverOnNetwork.serverCapabilities[i].data = (UA_Byte*)UA_malloc(len);
             memcpy(entry->serverOnNetwork.serverCapabilities[i].data, caps, len);
-            if (nextStr)
+            if(nextStr)
                 caps = nextStr + 1;
             else
                 break;
@@ -324,11 +324,11 @@ void mdns_create_txt(UA_Server *server, const char *fullServiceDomain, const cha
                                     600, conflict, server);
     xht_t *h = xht_new(11);
     char *allocPath = NULL;
-    if (!path || strlen(path) == 0) {
+    if(!path || strlen(path) == 0) {
         xht_set(h, "path", "/");
     } else {
         // path does not contain slash, so add it here
-        if (path[0] == '/')
+        if(path[0] == '/')
             // todo: malloc in strdup may fail: return a statuscode
             allocPath = UA_STRDUP(path);
         else {
@@ -343,7 +343,7 @@ void mdns_create_txt(UA_Server *server, const char *fullServiceDomain, const cha
 
     // calculate max string length:
     size_t capsLen = 0;
-    for (size_t i = 0; i < *capabilitiesSize; i++) {
+    for(size_t i = 0; i < *capabilitiesSize; i++) {
         // add comma or last \0
         capsLen += capabilites[i].length + 1;
     }
@@ -354,7 +354,7 @@ void mdns_create_txt(UA_Server *server, const char *fullServiceDomain, const cha
         // todo: malloc may fail: return a statuscode
         caps = (char*)UA_malloc(sizeof(char) * capsLen);
         size_t idx = 0;
-        for (size_t i = 0; i < *capabilitiesSize; i++) {
+        for(size_t i = 0; i < *capabilitiesSize; i++) {
             memcpy(caps + idx, (const char *) capabilites[i].data, capabilites[i].length);
             idx += capabilites[i].length + 1;
             caps[idx - 1] = ',';
@@ -421,7 +421,7 @@ getInterfaces(UA_Server *server) {
     for(size_t attempts = 0; attempts != 3; ++attempts) {
         // todo: malloc may fail: return a statuscode
         adapter_addresses = (IP_ADAPTER_ADDRESSES*)UA_malloc(adapter_addresses_buffer_size);
-        if (!adapter_addresses) {
+        if(!adapter_addresses) {
             UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
                          "GetAdaptersAddresses out of memory");
             adapter_addresses = NULL;
@@ -457,7 +457,7 @@ getInterfaces(UA_Server *server) {
 void mdns_set_address_record(UA_Server *server, const char *fullServiceDomain,
                              const char *localDomain) {
     IP_ADAPTER_ADDRESSES* adapter_addresses = getInterfaces(server);
-    if (!adapter_addresses)
+    if(!adapter_addresses)
         return;
 
     /* Iterate through all of the adapters */
@@ -476,7 +476,7 @@ void mdns_set_address_record(UA_Server *server, const char *fullServiceDomain,
                 mdns_set_address_record_if(server, fullServiceDomain, localDomain,
                                            (char *)&ipv4->sin_addr, 4);
             }
-            /*else if (AF_INET6 == family) {
+            /*else if(AF_INET6 == family) {
             // IPv6
             SOCKADDR_IN6* ipv6 = (SOCKADDR_IN6*)(address->Address.lpSockaddr);
 
@@ -491,7 +491,7 @@ void mdns_set_address_record(UA_Server *server, const char *fullServiceDomain,
 
             if(0 == ipv6_str.find("fe")) {
             char c = ipv6_str[2];
-            if (c == '8' || c == '9' || c == 'a' || c == 'b')
+            if(c == '8' || c == '9' || c == 'a' || c == 'b')
             is_link_local = true;
             } else if (0 == ipv6_str.find("2001:0:")) {
             is_special_use = true;

+ 7 - 7
src/server/ua_nodes.c

@@ -254,7 +254,7 @@ UA_Node_copy_alloc(const UA_Node *src) {
     dst->nodeClass = src->nodeClass;
 
     UA_StatusCode retval = UA_Node_copy(src, dst);
-    if (retval != UA_STATUSCODE_GOOD){
+    if(retval != UA_STATUSCODE_GOOD) {
         UA_free(dst);
         return NULL;
     }
@@ -296,24 +296,24 @@ copyCommonVariableAttributes(UA_VariableNode *node,
     /* if we have an extension object which is still encoded (e.g. from the nodeset compiler)
      * we need to decode it and set the decoded value instead of the encoded object */
     UA_Boolean valueSet = false;
-    if (attr->value.type != NULL && UA_NodeId_equal(&attr->value.type->typeId, &extensionObject)) {
+    if(attr->value.type != NULL && UA_NodeId_equal(&attr->value.type->typeId, &extensionObject)) {
         const UA_ExtensionObject *obj = (const UA_ExtensionObject *)attr->value.data;
-        if (obj && obj->encoding == UA_EXTENSIONOBJECT_ENCODED_BYTESTRING) {
+        if(obj && obj->encoding == UA_EXTENSIONOBJECT_ENCODED_BYTESTRING) {
 
             /* TODO: Once we generate type description in the nodeset compiler,
              * UA_findDatatypeByBinary can be made internal to the decoding
              * layer. */
             const UA_DataType *type = UA_findDataTypeByBinary(&obj->content.encoded.typeId);
 
-            if (type) {
+            if(type) {
                 void *dst = UA_Array_new(attr->value.arrayLength, type);
                 uint8_t *tmpPos = (uint8_t *)dst;
 
-                for (size_t i=0; i<attr->value.arrayLength; i++) {
+                for(size_t i=0; i<attr->value.arrayLength; i++) {
                     size_t offset =0;
                     const UA_ExtensionObject *curr = &((const UA_ExtensionObject *)attr->value.data)[i];
                     UA_StatusCode ret = UA_decodeBinary(&curr->content.encoded.body, &offset, tmpPos, type, 0, NULL);
-                    if (ret != UA_STATUSCODE_GOOD) {
+                    if(ret != UA_STATUSCODE_GOOD) {
                         return ret;
                     }
                     tmpPos += type->memSize;
@@ -325,7 +325,7 @@ copyCommonVariableAttributes(UA_VariableNode *node,
         }
     }
 
-    if (!valueSet)
+    if(!valueSet)
         retval |= UA_Variant_copy(&attr->value, &node->value.data.value.value);
 
     node->value.data.value.hasValue = true;

+ 1 - 1
src/server/ua_server.c

@@ -70,7 +70,7 @@ UA_Server_forEachChildNodeCall(UA_Server *server, UA_NodeId parentNodeId,
     UA_StatusCode retval = UA_STATUSCODE_GOOD;
     for(size_t i = parentCopy->referencesSize; i > 0; --i) {
         UA_NodeReferenceKind *ref = &parentCopy->references[i - 1];
-        for (size_t j = 0; j<ref->targetIdsSize; j++)
+        for(size_t j = 0; j<ref->targetIdsSize; j++)
             retval |= callback(ref->targetIds[j].nodeId, ref->isInverse,
                                ref->referenceTypeId, handle);
     }

+ 1 - 1
src/server/ua_server_binary.c

@@ -442,7 +442,7 @@ processMSG(UA_Server *server, UA_SecureChannel *channel,
 
     #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
     // set the authenticationToken from the create session request to help fuzzing cover more lines
-    if (!UA_NodeId_isNull(&unsafe_fuzz_authenticationToken))
+    if(!UA_NodeId_isNull(&unsafe_fuzz_authenticationToken))
         UA_NodeId_copy(&unsafe_fuzz_authenticationToken, &requestHeader->authenticationToken);
     #endif
 

+ 1 - 1
src/server/ua_server_discovery.c

@@ -67,7 +67,7 @@ register_server_with_discovery_server(UA_Server *server,
     size_t nl_discurls = server->config.networkLayersSize;
     size_t total_discurls = config_discurls + nl_discurls;
     request.server.discoveryUrls = (UA_String*)UA_alloca(sizeof(UA_String) * total_discurls);
-    if (!request.server.discoveryUrls) {
+    if(!request.server.discoveryUrls) {
         UA_Client_disconnect(client);
         UA_Client_delete(client);
         return UA_STATUSCODE_BADOUTOFMEMORY;

+ 4 - 4
src/server/ua_server_ns0.c

@@ -299,7 +299,7 @@ UA_Server_createNS0_base(UA_Server *server) {
     ret |= addObjectNode(server, "Views", UA_NS0ID_VIEWSFOLDER, UA_NS0ID_ROOTFOLDER,
                   UA_NS0ID_ORGANIZES, UA_NS0ID_FOLDERTYPE);
 
-    if (ret != UA_STATUSCODE_GOOD)
+    if(ret != UA_STATUSCODE_GOOD)
         return UA_STATUSCODE_BADINTERNALERROR;
     return UA_STATUSCODE_GOOD;
 }
@@ -534,14 +534,14 @@ UA_Server_initNS0(UA_Server *server) {
     server->bootstrapNS0 = true;
     UA_StatusCode retVal = UA_Server_createNS0_base(server);
     server->bootstrapNS0 = false;
-    if (retVal != UA_STATUSCODE_GOOD)
+    if(retVal != UA_STATUSCODE_GOOD)
         return retVal;
 
     /* Load nodes and references generated from the XML ns0 definition */
     server->bootstrapNS0 = true;
     retVal = ua_namespace0(server);
     server->bootstrapNS0 = false;
-    if (retVal != UA_STATUSCODE_GOOD)
+    if(retVal != UA_STATUSCODE_GOOD)
         return retVal;
 
     /* NamespaceArray */
@@ -582,7 +582,7 @@ UA_Server_initNS0(UA_Server *server) {
 
     retVal |= writeNs0VariableArray(server, UA_NS0ID_SERVER_SERVERCAPABILITIES_SERVERPROFILEARRAY,
                                     profileArray, profileArraySize, &UA_TYPES[UA_TYPES_STRING]);
-    for (int i=0; i<profileArraySize; i++) {
+    for(int i=0; i<profileArraySize; i++) {
         UA_String_deleteMembers(&profileArray[i]);
     }
 

+ 4 - 4
src/server/ua_server_utils.c

@@ -128,18 +128,18 @@ isNodeInTreeNoCircular(UA_Nodestore *ns, const UA_NodeId *leafNode, const UA_Nod
             struct ref_history *tmp = visitedRefs;
             struct ref_history *last = visitedRefs;
             UA_Boolean skip = UA_FALSE;
-            while (!skip && tmp) {
-                if (UA_NodeId_equal(tmp->id, &refs->targetIds[j].nodeId))
+            while(!skip && tmp) {
+                if(UA_NodeId_equal(tmp->id, &refs->targetIds[j].nodeId))
                     skip = UA_TRUE;
                 last = tmp;
                 tmp = tmp->parent;
             }
 
-            if (skip)
+            if(skip)
                 continue;
 
             last->parent = (struct ref_history*)UA_malloc(sizeof(struct ref_history));
-            if (!last->parent) {
+            if(!last->parent) {
                 return false;
             }
             last = last->parent;

+ 1 - 1
src/server/ua_server_worker.c

@@ -328,7 +328,7 @@ UA_Server_run_iterate(UA_Server *server, UA_Boolean waitInternal) {
     UA_UInt16 timeout = 0;
 
     /* round always to upper value to avoid timeout to be set to 0
-    * if (nextRepeated - now) < (UA_DATETIME_MSEC/2) */
+    * if(nextRepeated - now) < (UA_DATETIME_MSEC/2) */
     if(waitInternal)
         timeout = (UA_UInt16)(((nextRepeated - now) + (UA_DATETIME_MSEC - 1)) / UA_DATETIME_MSEC);
 

+ 2 - 2
src/server/ua_services_attribute.c

@@ -970,8 +970,8 @@ writeValueAttribute(UA_Server *server, UA_Session *session,
          * extension object we check if the current node value is also an
          * extension object. */
         UA_Boolean compatible;
-        if (value->value.type->typeId.identifierType == UA_NODEIDTYPE_NUMERIC &&
-            value->value.type->typeId.identifier.numeric == UA_NS0ID_STRUCTURE) {
+        if(value->value.type->typeId.identifierType == UA_NODEIDTYPE_NUMERIC &&
+           value->value.type->typeId.identifier.numeric == UA_NS0ID_STRUCTURE) {
             const UA_NodeId nodeDataType = UA_NODEID_NUMERIC(0, UA_NS0ID_STRUCTURE);
             compatible = compatibleValue(server, &nodeDataType, node->valueRank,
                                     node->arrayDimensionsSize, node->arrayDimensions,

+ 23 - 23
src/server/ua_services_discovery.c

@@ -28,11 +28,11 @@ setApplicationDescriptionFromRegisteredServer(const UA_FindServersRequest *reque
     retval |= UA_String_copy(&registeredServer->productUri, &target->productUri);
 
     // if the client requests a specific locale, select the corresponding server name
-    if (request->localeIdsSize) {
+    if(request->localeIdsSize) {
         UA_Boolean appNameFound = UA_FALSE;
-        for (size_t i =0; i<request->localeIdsSize && !appNameFound; i++) {
-            for (size_t j =0; j<registeredServer->serverNamesSize; j++) {
-                if (UA_String_equal(&request->localeIds[i], &registeredServer->serverNames[j].locale)) {
+        for(size_t i =0; i<request->localeIdsSize && !appNameFound; i++) {
+            for(size_t j =0; j<registeredServer->serverNamesSize; j++) {
+                if(UA_String_equal(&request->localeIds[i], &registeredServer->serverNames[j].locale)) {
                     retval |= UA_LocalizedText_copy(&registeredServer->serverNames[j],
                                                     &target->applicationName);
                     appNameFound = UA_TRUE;
@@ -46,7 +46,7 @@ setApplicationDescriptionFromRegisteredServer(const UA_FindServersRequest *reque
         if(!appNameFound && registeredServer->serverNamesSize)
             retval |= UA_LocalizedText_copy(&registeredServer->serverNames[0],
                                             &target->applicationName);
-    } else if (registeredServer->serverNamesSize) {
+    } else if(registeredServer->serverNamesSize) {
         // just take the first name
         retval |= UA_LocalizedText_copy(&registeredServer->serverNames[0], &target->applicationName);
     }
@@ -80,7 +80,7 @@ setApplicationDescriptionFromServer(UA_ApplicationDescription *target, const UA_
     }
     // UaExpert does not list DiscoveryServer, thus set it to Server
     // See http://forum.unified-automation.com/topic1987.html
-    if (target->applicationType == UA_APPLICATIONTYPE_DISCOVERYSERVER)
+    if(target->applicationType == UA_APPLICATIONTYPE_DISCOVERYSERVER)
         target->applicationType = UA_APPLICATIONTYPE_SERVER;
 
     /* add the discoveryUrls from the networklayers */
@@ -94,7 +94,7 @@ setApplicationDescriptionFromServer(UA_ApplicationDescription *target, const UA_
     target->discoveryUrlsSize += server->config.networkLayersSize;
 
     // 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_String_copy(&nl->discoveryUrl, &target->discoveryUrls[existing + i]);
     }
@@ -117,7 +117,7 @@ void Service_FindServers(UA_Server *server, UA_Session *session,
 
 #ifdef UA_ENABLE_DISCOVERY
     // check if client only requested a specific set of servers
-    if (request->serverUrisSize) {
+    if(request->serverUrisSize) {
         size_t fsfpSize = sizeof(UA_RegisteredServer*) * server->registeredServersSize;
         foundServerFilteredPointer = (UA_RegisteredServer **)UA_malloc(fsfpSize);
         if(!foundServerFilteredPointer) {
@@ -135,13 +135,13 @@ void Service_FindServers(UA_Server *server, UA_Session *session,
                     if(UA_String_equal(&current->registeredServer.serverUri, &request->serverUris[i])) {
                         // check if entry already in list:
                         UA_Boolean existing = false;
-                        for (size_t j=0; j<foundServersSize; j++) {
-                            if (UA_String_equal(&foundServerFilteredPointer[j]->serverUri, &request->serverUris[i])) {
+                        for(size_t j=0; j<foundServersSize; j++) {
+                            if(UA_String_equal(&foundServerFilteredPointer[j]->serverUri, &request->serverUris[i])) {
                                 existing = true;
                                 break;
                             }
                         }
-                        if (!existing)
+                        if(!existing)
                             foundServerFilteredPointer[foundServersSize++] = &current->registeredServer;
                         break;
                     }
@@ -188,7 +188,7 @@ void Service_FindServers(UA_Server *server, UA_Session *session,
                 setApplicationDescriptionFromServer(&foundServers[0], server);
             if(response->responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
                 UA_free(foundServers);
-                if (foundServerFilteredPointer)
+                if(foundServerFilteredPointer)
                     UA_free(foundServerFilteredPointer);
                 return;
             }
@@ -196,20 +196,20 @@ void Service_FindServers(UA_Server *server, UA_Session *session,
 
 #ifdef UA_ENABLE_DISCOVERY
         size_t currentIndex = 0;
-        if (addSelf)
+        if(addSelf)
             currentIndex++;
 
         // add all the registered servers to the list
 
-        if (foundServerFilteredPointer) {
+        if(foundServerFilteredPointer) {
             // use filtered list because client only requested specific uris
             // -1 because foundServersSize also includes this self server
             size_t iterCount = addSelf ? foundServersSize - 1 : foundServersSize;
-            for (size_t i = 0; i < iterCount; i++) {
+            for(size_t i = 0; i < iterCount; i++) {
                 response->responseHeader.serviceResult =
                         setApplicationDescriptionFromRegisteredServer(request, &foundServers[currentIndex++],
                                                                       foundServerFilteredPointer[i]);
-                if (response->responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
+                if(response->responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
                     UA_free(foundServers);
                     UA_free(foundServerFilteredPointer);
                     return;
@@ -223,7 +223,7 @@ void Service_FindServers(UA_Server *server, UA_Session *session,
                 response->responseHeader.serviceResult =
                         setApplicationDescriptionFromRegisteredServer(request, &foundServers[currentIndex++],
                                                                       &current->registeredServer);
-                if (response->responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
+                if(response->responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
                     UA_free(foundServers);
                     return;
                 }
@@ -232,7 +232,7 @@ void Service_FindServers(UA_Server *server, UA_Session *session,
 #endif
     }
 
-    if (foundServerFilteredPointer)
+    if(foundServerFilteredPointer)
         UA_free(foundServerFilteredPointer);
 
     response->servers = foundServers;
@@ -347,7 +347,7 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
     registeredServer_list_entry* current;
     registeredServer_list_entry *registeredServer_entry = NULL;
     LIST_FOREACH(current, &server->registeredServers, pointers) {
-        if (UA_String_equal(&current->registeredServer.serverUri, &requestServer->serverUri)) {
+        if(UA_String_equal(&current->registeredServer.serverUri, &requestServer->serverUri)) {
             registeredServer_entry = current;
             break;
         }
@@ -397,7 +397,7 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
 #ifdef UA_ENABLE_DISCOVERY_SEMAPHORE
         char* filePath = (char*)
             UA_malloc(sizeof(char)*requestServer->semaphoreFilePath.length+1);
-        if (!filePath) {
+        if(!filePath) {
             UA_LOG_ERROR_SESSION(server->config.logger, session,
                                    "Cannot allocate memory for semaphore path. Out of memory.");
             responseHeader->serviceResult = UA_STATUSCODE_BADOUTOFMEMORY;
@@ -460,7 +460,7 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
     }
 
     UA_StatusCode retval = UA_STATUSCODE_GOOD;
-    if (!registeredServer_entry) {
+    if(!registeredServer_entry) {
         // server not yet registered, register it by adding it to the list
         UA_LOG_DEBUG_SESSION(server->config.logger, session, "Registering new server: %.*s",
                              (int)requestServer->serverUri.length, requestServer->serverUri.data);
@@ -532,7 +532,7 @@ void UA_Discovery_cleanupTimedOut(UA_Server *server, UA_DateTime nowMonotonic) {
             size_t fpSize = sizeof(char)*current->registeredServer.semaphoreFilePath.length+1;
             // todo: malloc may fail: return a statuscode
             char* filePath = (char *)UA_malloc(fpSize);
-            if (filePath) {
+            if(filePath) {
                 memcpy(filePath, current->registeredServer.semaphoreFilePath.data,
                        current->registeredServer.semaphoreFilePath.length );
                 filePath[current->registeredServer.semaphoreFilePath.length] = '\0';
@@ -676,7 +676,7 @@ UA_Server_addPeriodicServerRegisterCallback(UA_Server *server,
     {
         periodicServerRegisterCallback_entry *rs, *rs_tmp;
         LIST_FOREACH_SAFE(rs, &server->periodicServerRegisterCallbacks, pointers, rs_tmp) {
-            if (strcmp(rs->callback->discovery_server_url, discoveryServerUrl) == 0) {
+            if(strcmp(rs->callback->discovery_server_url, discoveryServerUrl) == 0) {
                 UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
                             "There is already a register callback for '%s' in place. Removing the older one.", discoveryServerUrl);
                 UA_Server_removeRepeatedCallback(server, rs->callback->id);

+ 8 - 8
src/server/ua_services_discovery_multicast.c

@@ -61,7 +61,7 @@ multicastWorkerLoop(UA_Server *server) {
         unsigned short retVal =
             mdnsd_step(server->mdnsDaemon, server->mdnsSocket,
                        FD_ISSET(server->mdnsSocket, &fds), true, &next_sleep);
-        if (retVal == 1) {
+        if(retVal == 1) {
             UA_LOG_SOCKET_ERRNO_WRAP(
                 UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_SERVER,
                           "Multicast error: Can not read from socket. %s", errno_str));
@@ -307,10 +307,10 @@ discovery_createMulticastSocket(void) {
     in.sin_addr.s_addr = 0;
 
 #ifdef _WIN32
-    if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET)
+    if((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET)
         return INVALID_SOCKET;
 #else
-    if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+    if((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
         return -1;
 #endif
 
@@ -318,7 +318,7 @@ discovery_createMulticastSocket(void) {
     setsockopt(s, SOL_SOCKET, SO_REUSEPORT, (char *)&flag, sizeof(flag));
 #endif
     setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, sizeof(flag));
-    if (bind(s, (struct sockaddr *)&in, sizeof(in))) {
+    if(bind(s, (struct sockaddr *)&in, sizeof(in))) {
         CLOSESOCKET(s);
 #ifdef _WIN32
         return INVALID_SOCKET;
@@ -366,9 +366,9 @@ void destroyMulticastDiscoveryServer(UA_Server* server) {
     mdnsd_shutdown(server->mdnsDaemon);
     mdnsd_free(server->mdnsDaemon);
 #ifdef _WIN32
-    if (server->mdnsSocket != INVALID_SOCKET) {
+    if(server->mdnsSocket != INVALID_SOCKET) {
 #else
-    if (server->mdnsSocket >= 0) {
+    if(server->mdnsSocket >= 0) {
 #endif
         CLOSESOCKET(server->mdnsSocket);
 #ifdef _WIN32
@@ -429,9 +429,9 @@ UA_Discovery_recordExists(UA_Server* server, const char* fullServiceDomain,
                           unsigned short port, const UA_DiscoveryProtocol protocol) {
     // [servername]-[hostname]._opcua-tcp._tcp.local. 86400 IN SRV 0 5 port [hostname].
     mdns_record_t *r  = mdnsd_get_published(server->mdnsDaemon, fullServiceDomain);
-    while (r) {
+    while(r) {
         const mdns_answer_t *data = mdnsd_record_data(r);
-        if (data->type == QTYPE_SRV && (port == 0 || data->srv.port == port))
+        if(data->type == QTYPE_SRV && (port == 0 || data->srv.port == port))
             return UA_TRUE;
         r = mdnsd_record_next(r);
     }

+ 17 - 17
src/server/ua_services_nodemanagement.c

@@ -342,7 +342,7 @@ addReference(UA_Server *server, UA_Session *session,
  * Could be used to e.g. delete all the references, except 'HASMODELINGRULE'
  */
 static void deleteReferencesSubset(UA_Node *node, size_t referencesSkipSize, UA_NodeId* referencesSkip) {
-    if (referencesSkipSize == 0) {
+    if(referencesSkipSize == 0) {
         UA_Node_deleteReferences(node);
         return;
     }
@@ -351,13 +351,13 @@ static void deleteReferencesSubset(UA_Node *node, size_t referencesSkipSize, UA_
      * It's faster */
     size_t newSize = 0;
     for(size_t i = 0; i < node->referencesSize; ++i) {
-        for (size_t j = 0; j < referencesSkipSize; j++) {
-            if (UA_NodeId_equal(&node->references[i].referenceTypeId, &referencesSkip[j])) {
+        for(size_t j = 0; j < referencesSkipSize; j++) {
+            if(UA_NodeId_equal(&node->references[i].referenceTypeId, &referencesSkip[j])) {
                 newSize++;
             }
         }
     }
-    if (newSize == 0){
+    if(newSize == 0) {
         UA_Node_deleteReferences(node);
         return;
     }
@@ -367,8 +367,8 @@ static void deleteReferencesSubset(UA_Node *node, size_t referencesSkipSize, UA_
     size_t curr = 0;
     UA_StatusCode retval = UA_STATUSCODE_GOOD;
     for(size_t i = 0; i < node->referencesSize && retval == UA_STATUSCODE_GOOD; ++i) {
-        for (size_t j = 0; j < referencesSkipSize; j++) {
-            if (!UA_NodeId_equal(&node->references[i].referenceTypeId, &referencesSkip[j]))
+        for(size_t j = 0; j < referencesSkipSize; j++) {
+            if(!UA_NodeId_equal(&node->references[i].referenceTypeId, &referencesSkip[j]))
                 continue;
 
             // copy the reference
@@ -386,8 +386,8 @@ static void deleteReferencesSubset(UA_Node *node, size_t referencesSkipSize, UA_
             drefs->targetIdsSize = srefs->targetIdsSize;
             break;
         }
-        if (retval != UA_STATUSCODE_GOOD) {
-            for (size_t k=0; k<i; k++) {
+        if(retval != UA_STATUSCODE_GOOD) {
+            for(size_t k=0; k<i; k++) {
                 UA_NodeReferenceKind *refs = &newReferences[i];
                 for(size_t j = 0; j < refs->targetIdsSize; ++j)
                     UA_ExpandedNodeId_deleteMembers(&refs->targetIds[j]);
@@ -398,7 +398,7 @@ static void deleteReferencesSubset(UA_Node *node, size_t referencesSkipSize, UA_
     }
 
     UA_Node_deleteReferences(node);
-    if (retval == UA_STATUSCODE_GOOD) {
+    if(retval == UA_STATUSCODE_GOOD) {
         node->references = newReferences;
         node->referencesSize = newSize;
     } else {
@@ -725,11 +725,11 @@ Operation_addNode_finish(UA_Server *server, UA_Session *session, const UA_NodeId
        node->nodeClass == UA_NODECLASS_OBJECTTYPE ||
        node->nodeClass == UA_NODECLASS_REFERENCETYPE ||
        node->nodeClass == UA_NODECLASS_DATATYPE) {
-        if (UA_NodeId_equal(referenceTypeId, &UA_NODEID_NULL))
+        if(UA_NodeId_equal(referenceTypeId, &UA_NODEID_NULL))
             referenceTypeId = &hasSubtype;
         const UA_Node *parentNode = UA_Nodestore_get(server, parentNodeId);
-        if (parentNode) {
-            if (parentNode->nodeClass == node->nodeClass)
+        if(parentNode) {
+            if(parentNode->nodeClass == node->nodeClass)
                 typeDefinitionId = parentNodeId;
             UA_Nodestore_release(server, parentNode);
         }
@@ -776,7 +776,7 @@ Operation_addNode_finish(UA_Server *server, UA_Session *session, const UA_NodeId
         }
 
         UA_Boolean  typeOk = UA_FALSE;
-        switch (node->nodeClass) {
+        switch(node->nodeClass) {
             case UA_NODECLASS_DATATYPE:
                 typeOk = type->nodeClass == UA_NODECLASS_DATATYPE;
                 break;
@@ -804,7 +804,7 @@ Operation_addNode_finish(UA_Server *server, UA_Session *session, const UA_NodeId
             default:
                 typeOk = UA_FALSE;
         }
-        if (!typeOk) {
+        if(!typeOk) {
             UA_LOG_INFO_SESSION(server->config.logger, session,
                                 "AddNodes: Type does not match node class");
             retval = UA_STATUSCODE_BADTYPEDEFINITIONINVALID;
@@ -874,7 +874,7 @@ Operation_addNode_finish(UA_Server *server, UA_Session *session, const UA_NodeId
        node->nodeClass == UA_NODECLASS_OBJECT) {
         UA_assert(type != NULL); /* see above */
         /* Add (mandatory) child nodes from the type definition */
-        if (!server->bootstrapNS0) {
+        if(!server->bootstrapNS0) {
             retval = addChildren(server, session, node, type);
             if(retval != UA_STATUSCODE_GOOD) {
                 UA_LOG_INFO_SESSION(server->config.logger, session,
@@ -897,7 +897,7 @@ Operation_addNode_finish(UA_Server *server, UA_Session *session, const UA_NodeId
 
     /* Add reference to the parent */
     if(!UA_NodeId_isNull(parentNodeId)) {
-        if (UA_NodeId_isNull(referenceTypeId)) {
+        if(UA_NodeId_isNull(referenceTypeId)) {
             UA_LOG_INFO_SESSION(server->config.logger, session,
                                 "AddNodes: Reference to parent cannot be null");
             retval = UA_STATUSCODE_BADTYPEDEFINITIONINVALID;
@@ -1134,7 +1134,7 @@ removeChildren(UA_Server *server, UA_Session *session,
     for(size_t i = 0; i < br.referencesSize; ++i) {
         UA_ReferenceDescription *rd = &br.references[i];
         // check for self-reference to avoid endless loop
-        if (UA_NodeId_equal(&node->nodeId, &rd->nodeId.nodeId))
+        if(UA_NodeId_equal(&node->nodeId, &rd->nodeId.nodeId))
             continue;
         item.nodeId = rd->nodeId.nodeId;
         UA_StatusCode retval;

+ 7 - 7
src/server/ua_services_subscription.c

@@ -460,7 +460,7 @@ Service_Publish(UA_Server *server, UA_Session *session,
      * resources for the new publish request. If the limit has been reached the
      * oldest publish request shall be responded */
     if((server->config.maxPublishReqPerSession != 0 ) &&
-       (UA_Session_getNumPublishReq(session) >= server->config.maxPublishReqPerSession)){
+       (UA_Session_getNumPublishReq(session) >= server->config.maxPublishReqPerSession)) {
         if(!UA_Subscription_reachedPublishReqLimit(server,session)) {
             subscriptionSendError(session->header.channel, requestId,
                                   request->requestHeader.requestHandle,
@@ -522,7 +522,7 @@ Service_Publish(UA_Server *server, UA_Session *session,
     UA_Boolean found = true; 
     int loopCount = 1;
 
-    if (session->lastSeenSubscriptionId > 0){
+    if(session->lastSeenSubscriptionId > 0) {
         /* If we found anything one the first loop or if there are LATE 
          * in the list before lastSeenSubscriptionId and not LATE after 
          * lastSeenSubscriptionId we need a second loop.
@@ -532,13 +532,13 @@ Service_Publish(UA_Server *server, UA_Session *session,
         found = false;
     }
 
-    for(int i=0; i<loopCount; i++){
+    for(int i=0; i<loopCount; i++) {
        LIST_FOREACH(immediate, &session->serverSubscriptions, listEntry) {
-            if (!found){
-                if (session->lastSeenSubscriptionId == immediate->subscriptionId){
+            if(!found) {
+                if(session->lastSeenSubscriptionId == immediate->subscriptionId) {
                     found = true; 
                 }     
-            }else{
+            } else {
                 if(immediate->state == UA_SUBSCRIPTIONSTATE_LATE) {
                     session->lastSeenSubscriptionId = immediate->subscriptionId;
                     UA_LOG_DEBUG_SESSION(server->config.logger, session, "Subscription %u | "
@@ -634,7 +634,7 @@ void Service_Republish(UA_Server *server, UA_Session *session,
 
     /* Get the subscription */
     UA_Subscription *sub = UA_Session_getSubscriptionById(session, request->subscriptionId);
-    if (!sub) {
+    if(!sub) {
         response->responseHeader.serviceResult = UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
         return;
     }

+ 2 - 2
src/server/ua_session.c

@@ -149,7 +149,7 @@ UA_Session_getPublishReq(UA_Session *session) {
 }
 
 void
-UA_Session_removePublishReq( UA_Session *session, UA_PublishResponseEntry* entry){
+UA_Session_removePublishReq( UA_Session *session, UA_PublishResponseEntry* entry) {
     UA_PublishResponseEntry* firstEntry;
     firstEntry = SIMPLEQ_FIRST(&session->responseQueue);
 
@@ -160,7 +160,7 @@ UA_Session_removePublishReq( UA_Session *session, UA_PublishResponseEntry* entry
     }
 }
 
-void UA_Session_addPublishReq( UA_Session *session, UA_PublishResponseEntry* entry){
+void UA_Session_addPublishReq( UA_Session *session, UA_PublishResponseEntry* entry) {
     SIMPLEQ_INSERT_TAIL(&session->responseQueue, entry, listEntry);
     session->numPublishReq++;
 }

+ 1 - 1
src/server/ua_subscription_datachange.c

@@ -67,7 +67,7 @@ ensureSpaceInMonitoredItemQueue(UA_MonitoredItem *mon, MonitoredItem_queuedValue
     UA_free(queueItem);
     --mon->currentQueueSize;
 
-    if(mon->maxQueueSize > 1){
+    if(mon->maxQueueSize > 1) {
         newQueueItem->value.hasStatus = true;
         newQueueItem->value.status = UA_STATUSCODE_INFOTYPE_DATAVALUE | UA_STATUSCODE_INFOBITS_OVERFLOW;
     }

+ 1 - 1
src/ua_connection.c

@@ -219,7 +219,7 @@ UA_Connection_receiveChunksBlocking(UA_Connection *connection, void *application
             return UA_STATUSCODE_GOODNONCRITICALTIMEOUT;
 
         /* round always to upper value to avoid timeout to be set to 0
-         * if (maxDate - now) < (UA_DATETIME_MSEC/2) */
+         * if(maxDate - now) < (UA_DATETIME_MSEC/2) */
         timeout = (UA_UInt32)(((maxDate - now) + (UA_DATETIME_MSEC - 1)) / UA_DATETIME_MSEC);
     }
     return retval;

+ 1 - 1
src/ua_types.c

@@ -565,7 +565,7 @@ copySubString(const UA_String *src, UA_String *dst,
 UA_StatusCode
 UA_Variant_copyRange(const UA_Variant *src, UA_Variant *dst,
                      const UA_NumericRange range) {
-    if (!src->type)
+    if(!src->type)
         return UA_STATUSCODE_BADINVALIDARGUMENT;
     bool isScalar = UA_Variant_isScalar(src);
     bool stringLike = isStringLike(src->type);

+ 5 - 5
src/ua_types_encoding_binary.c

@@ -314,7 +314,7 @@ pack754(long double f, unsigned bits, unsigned expbits) {
     unsigned significandbits = bits - expbits - 1;
     long double fnorm;
     long long sign;
-    if (f < 0) { sign = 1; fnorm = -f; }
+    if(f < 0) { sign = 1; fnorm = -f; }
     else { sign = 0; fnorm = f; }
     int shift = 0;
     while(fnorm >= 2.0) { fnorm /= 2.0; ++shift; }
@@ -662,7 +662,7 @@ DECODE_BINARY(NodeId) {
                           UA_EXPANDEDNODEID_NAMESPACEURI_FLAG);
 
     /* Decode the namespace and identifier */
-    switch (encodingByte) {
+    switch(encodingByte) {
     case UA_NODEIDTYPE_NUMERIC_TWOBYTE:
         dst->identifierType = UA_NODEIDTYPE_NUMERIC;
         ret = DECODE_DIRECT(&dstByte, Byte);
@@ -839,7 +839,7 @@ ENCODE_BINARY(ExtensionObject) {
         ret = ENCODE_WITHEXCHANGE(&encoding, Byte);
         if(ret != UA_STATUSCODE_GOOD)
             return ret;
-        switch (src->encoding) {
+        switch(src->encoding) {
         case UA_EXTENSIONOBJECT_ENCODED_NOBODY:
             break;
         case UA_EXTENSIONOBJECT_ENCODED_BYTESTRING:
@@ -1522,7 +1522,7 @@ CALCSIZE_BINARY(Guid) {
 
 CALCSIZE_BINARY(NodeId) {
     size_t s = 1; /* encoding byte */
-    switch (src->identifierType) {
+    switch(src->identifierType) {
     case UA_NODEIDTYPE_NUMERIC:
         if(src->identifier.numeric > UA_UINT16_MAX || src->namespaceIndex > UA_BYTE_MAX) {
             s += 6;
@@ -1578,7 +1578,7 @@ CALCSIZE_BINARY(ExtensionObject) {
         s += calcSizeBinaryJumpTable[encode_index](src->content.decoded.data, type);
     } else {
         s += NodeId_calcSizeBinary(&src->content.encoded.typeId, NULL);
-        switch (src->encoding) {
+        switch(src->encoding) {
         case UA_EXTENSIONOBJECT_ENCODED_NOBODY:
             break;
         case UA_EXTENSIONOBJECT_ENCODED_BYTESTRING: