Re: [libvirt] [PATCHv2] addrToString: give better error message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/22/2010 02:33 PM, Matthias Bolte wrote:
>> +        char ip[INET6_ADDRSTRLEN];
>> +
>> +        if (inet_ntop(sa->sa_family,
>> +                      (sa->sa_family == AF_INET
>> +                       ? (void *)&((struct sockaddr_in *)sa)->sin_addr
>> +                       : (void *)&((struct sockaddr_in6 *)sa)->sin6_addr),
> 
> Could we avoid this void * cast? The same cast is in
> src/remote/remote_driver.c too.

Yeah, I thought it was pretty ugly; gcc is (rightfully) complaining
(which in turn failed with -Werror) that sin_addr and sin6_addr are
different types, and therefore warned that the ?: had issues without at
least one of the two casts to void*.  I pushed, after dropping ?: and
instead using:

        void *rawaddr;

        if (sa->sa_family == AF_INET)
            rawaddr = &((struct sockaddr_in *)sa)->sin_addr;
        else
            rawaddr = &((struct sockaddr_in6 *)sa)->sin6_addr;

        if (inet_ntop(sa->sa_family, rawaddr, ip, sizeof ip)) {

> ACK.

Thanks.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]