qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] qio_dns_resolver_lookup_sync() and SOCKET_ADDRESS_KIND_FD?
@ 2017-03-23 16:30 Markus Armbruster
  2017-04-03 11:29 ` Daniel P. Berrange
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Armbruster @ 2017-03-23 16:30 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel

Ignorant question: does qio_dns_resolver_lookup_sync() do the right
thing for SOCKET_ADDRESS_KIND_FD?  The switch doesn't have a case for
it, and it's unclear whether the default case is really meant for
SOCKET_ADDRESS_KIND_FD in addition to impossible enumeration values.

Aside: impossible value means your program state is fatally
compromised.  I'd rather assert then.


int qio_dns_resolver_lookup_sync(QIODNSResolver *resolver,
                                 SocketAddress *addr,
                                 size_t *naddrs,
                                 SocketAddress ***addrs,
                                 Error **errp)
{
    switch (addr->type) {
    case SOCKET_ADDRESS_KIND_INET:
        return qio_dns_resolver_lookup_sync_inet(resolver,
                                                 addr,
                                                 naddrs,
                                                 addrs,
                                                 errp);

    case SOCKET_ADDRESS_KIND_UNIX:
    case SOCKET_ADDRESS_KIND_VSOCK:
        return qio_dns_resolver_lookup_sync_nop(resolver,
                                                addr,
                                                naddrs,
                                                addrs,
                                                errp);

    default:
        error_setg(errp, "Unknown socket address kind");
        return -1;
    }
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] qio_dns_resolver_lookup_sync() and SOCKET_ADDRESS_KIND_FD?
  2017-03-23 16:30 [Qemu-devel] qio_dns_resolver_lookup_sync() and SOCKET_ADDRESS_KIND_FD? Markus Armbruster
@ 2017-04-03 11:29 ` Daniel P. Berrange
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel P. Berrange @ 2017-04-03 11:29 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel

On Thu, Mar 23, 2017 at 05:30:07PM +0100, Markus Armbruster wrote:
> Ignorant question: does qio_dns_resolver_lookup_sync() do the right
> thing for SOCKET_ADDRESS_KIND_FD?  The switch doesn't have a case for
> it, and it's unclear whether the default case is really meant for
> SOCKET_ADDRESS_KIND_FD in addition to impossible enumeration values.

No, it is wrong - it should do a 'no op' resolution, not return an
error - ie KIND_FD handling should match KIND_UNIX/KIND_VSOCK.

> Aside: impossible value means your program state is fatally
> compromised.  I'd rather assert then.

Sure.

> 
> 
> int qio_dns_resolver_lookup_sync(QIODNSResolver *resolver,
>                                  SocketAddress *addr,
>                                  size_t *naddrs,
>                                  SocketAddress ***addrs,
>                                  Error **errp)
> {
>     switch (addr->type) {
>     case SOCKET_ADDRESS_KIND_INET:
>         return qio_dns_resolver_lookup_sync_inet(resolver,
>                                                  addr,
>                                                  naddrs,
>                                                  addrs,
>                                                  errp);
> 
>     case SOCKET_ADDRESS_KIND_UNIX:
>     case SOCKET_ADDRESS_KIND_VSOCK:
>         return qio_dns_resolver_lookup_sync_nop(resolver,
>                                                 addr,
>                                                 naddrs,
>                                                 addrs,
>                                                 errp);
> 
>     default:
>         error_setg(errp, "Unknown socket address kind");
>         return -1;
>     }
> }

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-03 11:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-23 16:30 [Qemu-devel] qio_dns_resolver_lookup_sync() and SOCKET_ADDRESS_KIND_FD? Markus Armbruster
2017-04-03 11:29 ` Daniel P. Berrange

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).