Просмотр исходного кода

Fix cpplint issues

Signed-off-by: Martin Melik Merkumians <martin.melik@gmail.com>
Martin Melik Merkumians 3 недель назад
Родитель
Сommit
1fc238d922

+ 22 - 19
source/src/enet_encap/encap.c

@@ -27,7 +27,8 @@
 /// Supported Encapsulation protocol version
 const EipUint16 kSupportedProtocolVersion = 1;
 
-/// Mask of which options are supported as of the current CIP specs no other option value as 0 should be supported.
+/// Mask of which options are supported as of the current CIP specs no other
+/// option value as 0 should be supported.
 const CipUdint kEncapsulationHeaderOptionsFlag = 0x00;
 
 /// the position of the session handle within the encapsulation header
@@ -45,18 +46,19 @@ typedef enum {
 } SessionStatus;
 
 const int kSenderContextSize =
-  8; ///< size of sender context in encapsulation header
+  8;  ///< size of sender context in encapsulation header
 
 /// @brief definition of known encapsulation commands
 typedef enum {
-  kEncapsulationCommandNoOperation = 0x0000,  ///< only allowed for TCP
+  kEncapsulationCommandNoOperation  = 0x0000,  ///< only allowed for TCP
   kEncapsulationCommandListServices = 0x0004,  ///< allowed for both UDP and TCP
   kEncapsulationCommandListIdentity = 0x0063,  ///< allowed for both UDP and TCP
-  kEncapsulationCommandListInterfaces = 0x0064,  ///< optional, allowed for both UDP and TCP
-  kEncapsulationCommandRegisterSession   = 0x0065,  ///< only allowed for TCP
-  kEncapsulationCommandUnregisterSession = 0x0066,  ///< only allowed for TCP
+  kEncapsulationCommandListInterfaces =
+    0x0064,  ///< optional, allowed for both UDP and TCP
+  kEncapsulationCommandRegisterSession      = 0x0065,  ///< only allowed for TCP
+  kEncapsulationCommandUnregisterSession    = 0x0066,  ///< only allowed for TCP
   kEncapsulationCommandSendRequestReplyData = 0x006F,  ///< only allowed for TCP
-  kEncapsulationCommandSendUnitData = 0x0070  ///< only allowed for TCP
+  kEncapsulationCommandSendUnitData         = 0x0070   ///< only allowed for TCP
 } EncapsulationCommand;
 
 /// @brief definition of capability flags
@@ -65,7 +67,8 @@ typedef enum {
   kCapabilityFlagsCipUdpClass0or1 = 0x0100U
 } CapabilityFlags;
 
-/// According to EIP spec at least 2 delayed message requests should be supported
+/// According to EIP spec at least 2 delayed message requests should be
+/// supported
 #define ENCAP_NUMBER_OF_SUPPORTED_DELAYED_ENCAP_MESSAGES 2U
 
 /* Encapsulation layer data  */
@@ -174,7 +177,8 @@ EipStatus HandleReceivedExplictTcpData(int socket,
   if (kEncapsulationHeaderOptionsFlag == encapsulation_data.options) {
     // TODO(MartinMelikMerkumians) generate appropriate error response
     if (*number_of_remaining_bytes >= 0) {
-      /// check if the message is corrupt: header size + claimed payload size > than what we actually received
+      /// check if the message is corrupt: header size + claimed payload size >
+      /// than what we actually received
       // full package or more received
       encapsulation_data.status = kEncapsulationProtocolSuccess;
       return_value              = kEipStatusOkSend;
@@ -266,8 +270,8 @@ EipStatus HandleReceivedExplictUdpData(const int socket,
   if (kEncapsulationHeaderOptionsFlag == encapsulation_data.options) {
     // TODO(MartinMelikMerkumians) generate appropriate error response
     if (*number_of_remaining_bytes >= 0) {
-      // check if the message is corrupt: header size + claimed payload size > than what we actually received
-      // full package or more received
+      // check if the message is corrupt: header size + claimed payload size >
+      // than what we actually received full package or more received
       encapsulation_data.status = kEncapsulationProtocolSuccess;
       return_value              = kEipStatusOkSend;
       // most of these functions need a reply to be send
@@ -498,8 +502,7 @@ void DetermineDelayTime(
 
   if (0 == maximum_delay_time) {
     maximum_delay_time = kListIdentityDefaultDelayTime;
-  } else if (kListIdentityMinimumDelayTime >
-             maximum_delay_time) {
+  } else if (kListIdentityMinimumDelayTime > maximum_delay_time) {
     // if maximum_delay_time is between 1ms and 500ms set it to 500ms (minimum)
     maximum_delay_time = kListIdentityMinimumDelayTime;
   }
@@ -522,8 +525,8 @@ void EncapsulateRegisterSessionCommandResponseMessage(
                               encapsulation_protocol_status,
                               outgoing_message);
 
-  AddIntToMessage(1, outgoing_message); // protocol version
-  AddIntToMessage(0, outgoing_message); // Options flag, shall be set to zero
+  AddIntToMessage(1, outgoing_message);  // protocol version
+  AddIntToMessage(0, outgoing_message);  // Options flag, shall be set to zero
 }
 
 /* @brief Check supported protocol, generate session handle, send replay back to
@@ -552,16 +555,16 @@ void HandleReceivedRegisterSessionCommand(
    * option flag is zero*/
   // Option field should be zero
   if ((0 < protocol_version) &&
-      (protocol_version <= kSupportedProtocolVersion) &&
-      (0 == option_flag)) {
+      (protocol_version <= kSupportedProtocolVersion) && (0 == option_flag)) {
     // check if the socket has already a session open
     for (unsigned int i = 0; i < OPENER_NUMBER_OF_SUPPORTED_SESSIONS; ++i) {
       if (g_registered_sessions[i] == socket) {
         // the socket has already registered a session this is not allowed
         OPENER_TRACE_INFO(
           "Error: A session is already registered at socket %d\n", socket);
-        // return the already assigned session back, the cip spec is not clear about this needs to be tested
-        session_handle = i + 1;
+        // return the already assigned session back, the cip spec is not clear
+        // about this needs to be tested
+        session_handle                = i + 1;
         encapsulation_protocol_status = kEncapsulationProtocolInvalidCommand;
         session_index                 = kSessionStatusInvalid;
         break;

+ 4 - 4
source/src/ports/MINGW/main.c

@@ -8,15 +8,15 @@
 #include <stdlib.h>
 #include <time.h>
 
+#include "api/opener_api.h"
 #include "cip/cipconnectionobject.h"
 #include "cip/cipethernetlink.h"
 #include "cip/ciptcpipinterface.h"
-#include "utils/doublylinkedlist.h"
-#include "ports/generic_networkhandler.h"
+#include "core/trace.h"
 #include "ports/MINGW/networkconfig.h"
+#include "ports/generic_networkhandler.h"
 #include "ports/nvdata/nvdata.h"
-#include "api/opener_api.h"
-#include "core/trace.h"
+#include "utils/doublylinkedlist.h"
 #define BringupNetwork(if_name, method, if_cfg, hostname) (0)
 #define ShutdownNetwork(if_name) (0)
 

+ 2 - 2
source/src/ports/MINGW/networkconfig.c

@@ -18,11 +18,11 @@
 #include <winsock2.h>
 #include <ws2tcpip.h>
 
+#include "api/opener_api.h"
 #include "cip/cipcommon.h"
 #include "cip/cipstring.h"
-#include "api/opener_api.h"
-#include "ports/opener_error.h"
 #include "core/trace.h"
+#include "ports/opener_error.h"
 
 /* ---------- Macro definitions ------------------------ */
 #define MALLOC(x) malloc(x)

+ 2 - 2
source/src/ports/MINGW/sample_application/sampleapplication.c

@@ -7,12 +7,12 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "api/opener_api.h"
 #include "cip/appcontype.h"
 #include "cip/cipqos.h"
 #include "cip/ciptcpipinterface.h"
-#include "ports/nvdata/nvdata.h"
-#include "api/opener_api.h"
 #include "core/trace.h"
+#include "ports/nvdata/nvdata.h"
 #if defined(OPENER_ETHLINK_CNTRS_ENABLE) && 0 != OPENER_ETHLINK_CNTRS_ENABLE
 #include "cip/cipethernetlink.h"
 #include "ports/MINGW/sample_application/ethlinkcbs.h"

+ 4 - 4
source/src/ports/POSIX/main.c

@@ -16,15 +16,15 @@
 #include <sys/mman.h>
 #endif
 
+#include "api/opener_api.h"
 #include "cip/cipconnectionobject.h"
 #include "cip/cipethernetlink.h"
 #include "cip/ciptcpipinterface.h"
-#include "utils/doublylinkedlist.h"
-#include "ports/generic_networkhandler.h"
+#include "core/trace.h"
 #include "ports/POSIX/networkconfig.h"
+#include "ports/generic_networkhandler.h"
 #include "ports/nvdata/nvdata.h"
-#include "api/opener_api.h"
-#include "core/trace.h"
+#include "utils/doublylinkedlist.h"
 
 #define BringupNetwork(if_name, method, if_cfg, hostname) (0)
 #define ShutdownNetwork(if_name) (0)

+ 1 - 1
source/src/ports/POSIX/networkconfig.c

@@ -18,10 +18,10 @@
 #include <time.h>
 #include <unistd.h>
 
+#include "api/opener_api.h"
 #include "cip/cipcommon.h"
 #include "cip/ciperror.h"
 #include "cip/cipstring.h"
-#include "api/opener_api.h"
 #include "core/trace.h"
 
 EipStatus IfaceGetMacAddress(const char* iface,

+ 2 - 2
source/src/ports/POSIX/networkhandler.c

@@ -14,10 +14,10 @@
 #include <time.h>
 #include <unistd.h>
 
+#include "core/trace.h"
 #include "enet_encap/encap.h"
-#include "ports/opener_error.h"
 #include "opener_user_conf.h"
-#include "core/trace.h"
+#include "ports/opener_error.h"
 
 MicroSeconds GetMicroSeconds(void) {
   struct timespec now = { .tv_nsec = 0, .tv_sec = 0 };

+ 2 - 3
source/src/ports/POSIX/sample_application/sampleapplication.c

@@ -12,9 +12,9 @@
 #include "cip/cipidentity.h"
 #include "cip/cipqos.h"
 #include "cip/ciptcpipinterface.h"
-#include "ports/nvdata/nvdata.h"
-#include "opener_api.h"
 #include "core/trace.h"
+#include "opener_api.h"
+#include "ports/nvdata/nvdata.h"
 #if defined(OPENER_ETHLINK_CNTRS_ENABLE) && 0 != OPENER_ETHLINK_CNTRS_ENABLE
 #include "cip/cipethernetlink.h"
 #include "ports/POSIX/sample_application/ethlinkcbs.h"
@@ -209,5 +209,4 @@ void RunIdleChanged(EipUint32 run_idle_value) {
     CipIdentitySetExtendedDeviceStatus(
       kAtLeastOneIoConnectionEstablishedAllInIdleMode);
   }
-  (void)run_idle_value;
 }

+ 1 - 1
source/src/ports/STM32/networkconfig.c

@@ -13,9 +13,9 @@
 #include "cip/cipcommon.h"
 #include "cip/ciperror.h"
 #include "cip/cipstring.h"
+#include "core/trace.h"
 #include "lwip/netif.h"
 #include "opener_api.h"
-#include "core/trace.h"
 
 EipStatus IfaceGetMacAddress(TcpIpInterface* iface,
                              uint8_t* const physical_address) {

+ 2 - 2
source/src/ports/STM32/networkhandler.c

@@ -6,10 +6,10 @@
 
 #include "ports/networkhandler.h"
 
+#include "core/trace.h"
 #include "enet_encap/encap.h"
-#include "ports/opener_error.h"
 #include "opener_user_conf.h"
-#include "core/trace.h"
+#include "ports/opener_error.h"
 
 MilliSeconds GetMilliSeconds(void) {
   return osKernelSysTick();

+ 1 - 1
source/src/ports/STM32/sample_application/sampleapplication.c

@@ -8,11 +8,11 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "api/opener_api.h"
 #include "cip/appcontype.h"
 #include "cip/cipidentity.h"
 #include "cip/cipqos.h"
 #include "cip/ciptcpipinterface.h"
-#include "api/opener_api.h"
 #include "core/trace.h"
 
 #define DEMO_APP_INPUT_ASSEMBLY_NUM 100U                  // 0x064