You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/09/29 15:59:38 UTC

[GitHub] [nifi-minifi-cpp] szaszm commented on a diff in pull request #1425: MINIFICPP-1943 Fixing memory leak in NetworkInterfaceInfo

szaszm commented on code in PR #1425:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1425#discussion_r983731331


##########
libminifi/include/utils/NetworkInterfaceInfo.h:
##########
@@ -49,17 +44,18 @@ class NetworkInterfaceInfo {
   explicit NetworkInterfaceInfo(const struct ifaddrs* ifa);
 #endif
   NetworkInterfaceInfo& operator=(NetworkInterfaceInfo&& other) noexcept = default;
-  const std::string& getName() const noexcept { return name_; }
-  bool hasIpV4Address() const noexcept { return !ip_v4_addresses_.empty(); }
-  bool hasIpV6Address() const noexcept { return !ip_v6_addresses_.empty(); }
-  bool isRunning() const noexcept { return running_; }
-  bool isLoopback() const noexcept { return loopback_; }
-  const std::vector<std::string>& getIpV4Addresses() const noexcept { return ip_v4_addresses_; }
-  const std::vector<std::string>& getIpV6Addresses() const noexcept { return ip_v6_addresses_; }
+  [[nodiscard]] const std::string& getName() const noexcept { return name_; }
+  [[nodiscard]] bool hasIpV4Address() const noexcept { return !ip_v4_addresses_.empty(); }
+  [[nodiscard]] bool hasIpV6Address() const noexcept { return !ip_v6_addresses_.empty(); }
+  [[nodiscard]] bool isRunning() const noexcept { return running_; }
+  [[nodiscard]] bool isLoopback() const noexcept { return loopback_; }
+  [[nodiscard]] const std::vector<std::string>& getIpV4Addresses() const noexcept { return ip_v4_addresses_; }
+  [[nodiscard]] const std::vector<std::string>& getIpV6Addresses() const noexcept { return ip_v6_addresses_; }
 
   // Traverses the ip addresses and merges them together based on the interface name
-  static std::vector<NetworkInterfaceInfo> getNetworkInterfaceInfos(std::function<bool(const NetworkInterfaceInfo&)> filter = { [](const NetworkInterfaceInfo&) { return true; } },
-      const std::optional<uint32_t> max_interfaces = std::nullopt);
+  static std::vector<NetworkInterfaceInfo> getNetworkInterfaceInfos(
+      const std::function<bool(const NetworkInterfaceInfo&)>& filter = { [](const NetworkInterfaceInfo&) { return true; } },
+      std::optional<uint32_t> max_interfaces = std::nullopt);

Review Comment:
   Why did you change the filter function to be passed by const ref? I think it will not make a difference, since a temporary std::function wrapper is created for any passed-in function anyway.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org