On 11/8/19 12:03 AM, Andries E. Brouwer wrote:
> On Thu, Nov 07, 2019 at 09:43:00PM +0100, Tim Rühsen wrote:
> 
>> This commit should have fixed it:
>>
>> commit 3056617e9cf9a2c68989a2ff4e4266f6e7a4de45
>> Author: Tim Rühsen <[email protected]>
>> Date:   Wed Feb 10 15:23:13 2016 +0100
>>
>>     Retain value of errno in logprintf()
>>
>>     * src/log.c (logprintf): Save&Restore value of errno
> 
> Usually it is inconvenient to save and restore errno all the time.
> I read
> 
>       err = gethttp (u, original_url, &hstat, dt, proxy, iri, count);
>       tms = datetime_str (time (NULL));
>       if (hstat.newloc)
>         *newloc = xstrdup (hstat.newloc);
>       switch (err) {
>       ... use errno ...
> 
> The hope is probably that errno is the errno from gethttp.
> But does time() preserve errno?
> And does datetime_str() preserve errno?
> It calls fmttime() which calls localtime() and strftime().

Libc functions only touch errno if there *is* an error (else it's very
likely a bug in libc).

So the question is: who is setting errno explicitly to 0 (between the
error and the the usage of errno).

The code works here with glibc 2.29. I need more info on which
OS/system/environment it doesn't work to reproduce and to track it down.
Until then I can't do much but guess.

Regards, Tim

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to