>>>>> Anton D Kachalov writes:

[…]

 > @@ -117,10 +118,14 @@ static int numeric_resolv ( struct interface *resolv,

 >      /* Attempt to resolve name */
 >      sin = ( ( struct sockaddr_in * ) &numeric->sa );
 > -    if ( inet_aton ( name, &sin->sin_addr ) != 0 ) {
 > -            sin->sin_family = AF_INET;
 > +    if ( inet_aton ( name, &sin->sin_addr ) == 0 ) {
 > +            sin6 = ( ( struct sockaddr_in6 * ) &numeric->sa );
 > +            sin6->sin_family = AF_INET6;
 > +            if ( inet6_aton ( name, &sin6->sin6_addr ) == 0 ) {
 > +                    numeric->rc = -EINVAL;
 > +            }
 >      } else {
 > -            numeric->rc = -EINVAL;
 > +            sin->sin_family = AF_INET;
 >      }

 >      /* Attach to parent interface, mortalise self, and return */

        BTW, I wonder if the above could be something like the following
        instead:

@@ -117,10 +118,13 @@ static int numeric_resolv ( struct interface *resolv,
 
        /* Attempt to resolve name */
        sin = ( ( struct sockaddr_in * ) &numeric->sa );
+       sin6 = ( ( struct sockaddr_in6 * ) &numeric->sa );
        if ( inet_aton ( name, &sin->sin_addr ) != 0 ) {
                sin->sin_family = AF_INET;
+       } else if ( inet6_aton ( name, &sin6->sin6_addr ) == 0 ) {
+               sin6->sin_family = AF_INET6;
        } else {
                numeric->rc = -EINVAL;
        }
 
        /* Attach to parent interface, mortalise self, and return */

        (AIUI, the added sin6 assignment above shouldn't add any actualy
        code, other than those that will be optimized away anyway.)

        I believe that there're a few more places in the patch where the
        use of an appropriate ‘else if’ construct would save a few lines
        in the resulting diff.

        TIA.

-- 
FSF associate member #7257      http://sf-day.org/

_______________________________________________
ipxe-devel mailing list
[email protected]
https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel

Reply via email to