> On March 3, 2015, 6:39 p.m., Jie Yu wrote: > > 3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp, lines 115-126 > > <https://reviews.apache.org/r/31471/diff/4/?file=882869#file882869line115> > > > > I am wondering if this function is necessary given that we implemented > > `==` operator. For example: > > > > ``` > > IP ip1 = IP::parse("0.0.0.0"); > > if (ip1 == IP::ANY(AF_INET)) { > > // XXX > > } > > > > IP ip2 = IP::parse("127.0.0.1"); > > if (ip2 == IP::LOOPBACK(AF_INET)) { > > // XXX > > } > > ``` > > Evelina Dumitrescu wrote: > it's more clear to use isInaddrAny and isLoopback functions > > Jie Yu wrote: > Since you'll have IP::LOOPBACK(AF_INET) anyway, why add an additional > function?
It's only in IPNetwork, used to replace a variable in port_mapping. > On March 3, 2015, 6:39 p.m., Jie Yu wrote: > > 3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp, line 71 > > <https://reviews.apache.org/r/31471/diff/4/?file=882869#file882869line71> > > > > By convension, if you store an ipv4 address in uint32_t, it should be > > in host order. So the code here should be: > > ``` > > // Creates an IP from a 32 bit unsigned integer (in host order). > > explicit IP(uint32_t address) > > : family_(AF_INET) > > { > > clear(); > > storage_.in.s_addr = htonl(address); > > } > > ``` > > Evelina Dumitrescu wrote: > using a single constructor that expects the parameter to be in host order > will add too much confusion. > > Jie Yu wrote: > I insist on this. This is convension which every programmer should follow. Ok. I think we should add some explanations in comments about this fact. For newcomers this would not be so obvious and would lead to bugs. > On March 3, 2015, 6:39 p.m., Jie Yu wrote: > > 3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp, line 63 > > <https://reviews.apache.org/r/31471/diff/4/?file=882869#file882869line63> > > > > Please be consistent. You use `in_addr` here but you use `struct > > in_addr` for the field member. > > > > Please use `struct in_addr` consistently throughout the code base. > > Evelina Dumitrescu wrote: > ok, I actually wanted to stick to in_addr(without struct). > > Jie Yu wrote: > I prefer 'struct in_addr' for consistency reason because code elsewhere > uses things like: > struct sockaddr_in > struct sockaddr_ll > ... ok, I'll replace them. > On March 3, 2015, 6:39 p.m., Jie Yu wrote: > > 3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp, line 260 > > <https://reviews.apache.org/r/31471/diff/4/?file=882869#file882869line260> > > > > Why this function returns a Try? Seems to be uncessary because it > > shouldn't fail, right? How about making it like a constant: > > ``` > > static IPNetwork LOOPBACK(int family); > > ``` > > Evelina Dumitrescu wrote: > what if the family is not AF_INET or AF_INET6 ? > > Jie Yu wrote: > OK, how about LOOPBACK_V4() and LOOPBACK_V6 (same applied to IP). Previously I used loopbackIpv4Network/loopbackIpv6Network and I was requested to replace them with loopbackIPNetwork(int family). I'll switch back then. > On March 3, 2015, 6:39 p.m., Jie Yu wrote: > > 3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp, line 477 > > <https://reviews.apache.org/r/31471/diff/4/?file=882869#file882869line477> > > > > You made the same mistake again here. This could be a memory leak if > > the family is not supported, right? > > > > So I suggest you checking the family early (i.e., before `getifaddrs` > > is called) and use CHECK below. clumsy me, sorry for those :) > On March 3, 2015, 6:39 p.m., Jie Yu wrote: > > 3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp, lines 528-530 > > <https://reviews.apache.org/r/31471/diff/4/?file=882869#file882869line528> > > > > No need for this since we control the construction of an IP network. ok > On March 3, 2015, 6:39 p.m., Jie Yu wrote: > > 3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp, lines 76-78 > > <https://reviews.apache.org/r/31471/diff/4/?file=882870#file882870line76> > > > > Let's simply add a CHECK here and return a `struct sockaddr_storage` > > here (not `Try`). ok > On March 3, 2015, 6:39 p.m., Jie Yu wrote: > > 3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp, lines 239-242 > > <https://reviews.apache.org/r/31471/diff/4/?file=882870#file882870line239> > > > > Again, let's check if family is supported at the begining. ok > On March 3, 2015, 6:39 p.m., Jie Yu wrote: > > 3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp, line 189 > > <https://reviews.apache.org/r/31471/diff/4/?file=882870#file882870line189> > > > > We declare the variable the first time we use it. So please kill this. ok > On March 3, 2015, 6:39 p.m., Jie Yu wrote: > > 3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp, lines 154-155 > > <https://reviews.apache.org/r/31471/diff/4/?file=882870#file882870line154> > > > > Let's try to not sneaking in changes like this in patch that's already > > very big. i was requested to do so. > On March 3, 2015, 6:39 p.m., Jie Yu wrote: > > 3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp, lines 211-213 > > <https://reviews.apache.org/r/31471/diff/4/?file=882869#file882869line211> > > > > Fix the indent please > > Evelina Dumitrescu wrote: > I put the parameters on different lines each, I don't understand what's > wrong > > Jie Yu wrote: > Either > ``` > ABORT( > "xxx" + > stringify(xxx) + > stringify(xxx)); > ``` > > Or > ``` > ABORT("XXX" + > stringify(xxx) + > stringify(xxx)); > ``` > > see Case 2 in: > > https://github.com/apache/mesos/blob/master/docs/mesos-c%2B%2B-style-guide.md#function-definitioninvocation thanks ! - Evelina ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/31471/#review74987 ----------------------------------------------------------- On March 3, 2015, 11:27 a.m., Evelina Dumitrescu wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/31471/ > ----------------------------------------------------------- > > (Updated March 3, 2015, 11:27 a.m.) > > > Review request for mesos, Benjamin Hindman, Dominic Hamon, Jie Yu, Joris Van > Remoortere, and Niklas Nielsen. > > > Repository: mesos > > > Description > ------- > > see summary > > > Diffs > ----- > > 3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp > 0cd7cb526a3a2514b3b54552253dfa8919e948d0 > 3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp > 9635bbc6f7dae1d75a780069fcc60fb706221053 > 3rdparty/libprocess/3rdparty/stout/tests/ip_tests.cpp > fb98317a68986cb1228c584a8cd83b07737895a8 > > Diff: https://reviews.apache.org/r/31471/diff/ > > > Testing > ------- > > > Thanks, > > Evelina Dumitrescu > >