|
From: | Ferry Huberts |
Subject: | Re: [gpsd-dev] [PATCH v3 1/1] gps2udp: reset errno after successful getaddrinfo call |
Date: | Fri, 03 Jan 2014 15:29:29 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
On 03/01/14 15:18, Mike Frysinger wrote:
On Friday 03 January 2014 08:33:47 Ferry Huberts wrote:It may return errno==2 ("No such file or directory") when the file /etc/gai.conf is not present. The observed effect was that the port number conversion considered a perfectly valid port number as invalid.you still haven't really explained why this is the way to go. functions do not "return errno". they return real values, and any code calling those functions need to first check the return value *before* ever looking at errno.
Which is exactly what happens here: the code bails out if the function call is not successful.
The function call may set errno even though it succeeds. How about if I rephrase like: It may set errno to 2 ("No such file or directory") when the file /etc/gai.conf is not present, even though it succeeds.
i.e. any code that does: socket_t foo = netlib_connectsock(...); if (errno) { ... do error stuff ... } is completely broken. resetting errno is the wrong way to fix this.
I did not write that code, I only fixed it. -- Ferry Huberts
[Prev in Thread] | Current Thread | [Next in Thread] |