> Date: Fri, 8 Nov 2019 15:03:21 +0100 > From: "Andries E. Brouwer" <andries.brou...@cwi.nl> > Cc: Francesco Turco <ftu...@fastmail.fm>, bug-wget@gnu.org, > "Andries E. Brouwer" <andries.brou...@cwi.nl> > > > Libc functions only touch errno if there *is* an error > > Libc functions are free to call other functions internally, > and such internal calls may fail where the outer level call > does not fail. So even if a libc function does not return > an error, errno can have changed.
That would be a bug in libc, I think. Its functions should save and restore errno if other functions they call error out without causing the calling function to fail. IOW, if a libc function succeed, it should whatever it takes to preserve errno.