qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v6 3/4] net/net: Convert parse_host_port() to Er


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v6 3/4] net/net: Convert parse_host_port() to Error
Date: Wed, 28 Jun 2017 09:24:58 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0

On 06/28/2017 08:23 AM, Daniel P. Berrange wrote:
> On Wed, Jun 28, 2017 at 09:08:49PM +0800, Mao Zhongyi wrote:
>> diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
>> index 5c326db..78e2b30 100644
>> --- a/include/qemu/sockets.h
>> +++ b/include/qemu/sockets.h
> 
>>          if (qemu_isdigit(buf[0])) {
>> -            if (!inet_aton(buf, &saddr->sin_addr))
>> +            if (!inet_aton(buf, &saddr->sin_addr)) {
>> +                error_setg(errp, "host address '%s' is not a valid "
>> +                           "IPv4 address", buf);
>>                  return -1;
>> +            }
>>          } else {
>> -            if ((he = gethostbyname(buf)) == NULL)
>> +            he = gethostbyname(buf);
>> +            if (he == NULL) {
>> +                error_setg(errp, "can't resolve host address '%s': "
>> +                           "unknown host", buf);
>>                  return - 1;
>> +            }
> 
> gethostbyname sets  'h_errno' on failure, so you should pass that
> into error_setg_errno, instead of hardcoding 'unknown host' as a
> message

'man gethostbyname' says it is deprecated, and that applications should
use getaddrinfo/getnameinfo instead.  What's our story here?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]