Bruno Haible wrote: > Hi Paul, Jim, > >> + errno = 0; /* Don't be misled if it doesn't set errno. >> */ >> + loads = getloadavg (avg, 3); >> + if (loads == -1) >> + { >> + perror ("Skipping test; load average not supported"); >> + return 77; >> + } > > This assignment to errno, followed by the use of errno when getloadavg() > failed, brings up a question: Is getloadavg() supposed to set errno when it > fails or not? > > The specification in lib/getloadavg.c indicates that "no": > > /* Put the 1 minute, 5 minute and 15 minute load averages > into the first NELEM elements of LOADAVG. > Return the number written (never more than 3, but may be less than > NELEM), > or -1 if an error occurred. */ > > In this case the test should use fputs, not perror. > > Or if the answer is "yes", then the specification should say so, and the > assignment to errno in the test should be removed.
Hi Bruno, Specifying that errno may be changed sounds better, even though coreutils' sole use in uptime.c does not use that. For example, if an open or read attempt fails with EIO, the caller should be able to report that (or at least to distinguish between that failure and lack of support), even if there is no way to include the name of the affected file.