arpadboda commented on a change in pull request #557: MINIFICPP-850: Add 
operating system to c2 response
URL: https://github.com/apache/nifi-minifi-cpp/pull/557#discussion_r285491068
 
 

 ##########
 File path: libminifi/include/core/state/nodes/DeviceInformation.h
 ##########
 @@ -279,46 +278,46 @@ class Device {
     return macstr.length() > 0 ? std::to_string(hash_fn(macstr)) : "8675309";
   }
 #else
-std::string getDeviceId() {
-       PIP_ADAPTER_INFO adapterPtr;
-       PIP_ADAPTER_INFO adapter = NULL;
-
-       DWORD dwRetVal = 0;
-
-       std::hash<std::string> hash_fn;
-       std::set<std::string> macs;
-       
-       ULONG adapterLen = sizeof(IP_ADAPTER_INFO);
-       adapterPtr = (IP_ADAPTER_INFO *)malloc(sizeof(IP_ADAPTER_INFO));
-       if (adapterPtr == NULL) {
-               return "";
-       }
-       if (GetAdaptersInfo(adapterPtr, &adapterLen) == ERROR_BUFFER_OVERFLOW) {
-               free(adapterPtr);
-               adapterPtr = (IP_ADAPTER_INFO *)malloc(adapterLen);
-               if (adapterPtr == NULL) {
-                       return "";
-               }
-       }
-
-       if ((dwRetVal = GetAdaptersInfo(adapterPtr, &adapterLen)) == NO_ERROR) {
-               adapter = adapterPtr;
-               while (adapter) {
-                       char mac_add[13];
-                       snprintf(mac_add, 13, "%02X%02X%02X%02X%02X%02X", 
adapter->Address[0], adapter->Address[1], adapter->Address[2], 
adapter->Address[3], adapter->Address[4], adapter->Address[5]);
-                       macs.insert(mac_add);
-                       adapter = adapter->Next;
-               }
-       }
-       
-       if (adapterPtr)
-               free(adapterPtr);
-        std::string macstr;
+  std::string getDeviceId() {
+    PIP_ADAPTER_INFO adapterPtr;
+    PIP_ADAPTER_INFO adapter = NULL;
+
+    DWORD dwRetVal = 0;
+
+    std::hash<std::string> hash_fn;
+    std::set<std::string> macs;
+
+    ULONG adapterLen = sizeof(IP_ADAPTER_INFO);
+    adapterPtr = (IP_ADAPTER_INFO *)malloc(sizeof(IP_ADAPTER_INFO));
+    if (adapterPtr == NULL) {
+      return "";
+    }
+    if (GetAdaptersInfo(adapterPtr, &adapterLen) == ERROR_BUFFER_OVERFLOW) {
+      free(adapterPtr);
+      adapterPtr = (IP_ADAPTER_INFO *)malloc(adapterLen);
+      if (adapterPtr == NULL) {
+        return "";
+      }
+    }
+
+    if ((dwRetVal = GetAdaptersInfo(adapterPtr, &adapterLen)) == NO_ERROR) {
+      adapter = adapterPtr;
+      while (adapter) {
+        char mac_add[13];
+        snprintf(mac_add, 13, "%02X%02X%02X%02X%02X%02X", adapter->Address[0], 
adapter->Address[1], adapter->Address[2], adapter->Address[3], 
adapter->Address[4], adapter->Address[5]);
+        macs.insert(mac_add);
+        adapter = adapter->Next;
+      }
+    }
+
+    if (adapterPtr)
+    free(adapterPtr);
+    std::string macstr;
     for (auto &mac : macs) {
       macstr += mac;
     }
-       return macstr.length() > 0 ? std::to_string(hash_fn(macstr)) : 
"8675309";
-}
+    return macstr.length() > 0 ? std::to_string(hash_fn(macstr)) : "8675309";
 
 Review comment:
   What's that magic number here? :) 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to