You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "SolidWallOfCode (via GitHub)" <gi...@apache.org> on 2023/03/18 14:23:35 UTC

[GitHub] [trafficserver] SolidWallOfCode commented on a diff in pull request #9530: libswoc: Update to 1.4.6

SolidWallOfCode commented on code in PR #9530:
URL: https://github.com/apache/trafficserver/pull/9530#discussion_r1141026664


##########
lib/swoc/src/swoc_ip.cc:
##########
@@ -1055,11 +1055,9 @@ IP6Range::load(std::string_view text) {
 
 IPRange::IPRange(IPAddr const &min, IPAddr const &max) {
   if (min.is_ip4() && max.is_ip4()) {
-    _range._ip4.assign(min.ip4(), max.ip4());
-    _family = AF_INET;
+    this->assign(min.ip4(), max.ip4());
   } else if (min.is_ip6() && max.is_ip6()) {
-    _range._ip6.assign(min.ip6(), max.ip6());
-    _family = AF_INET6;
+    this->assign(min.ip6(), max.ip6());
   }

Review Comment:
   I don't like constructors which throw, particularly inside ATS. Instead the object should be constructed to some default / non-valid state. If this is a concern, then you should use methods (which have return values indicating what happened. A constructor like this is intended for use in situations where there's no concern about data integrity, e.g. loading predefined values.



-- 
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: github-unsubscribe@trafficserver.apache.org

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