bug-gnulib
[Top][All Lists]
Advanced

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

Re: getloadavg and errno


From: Bruno Haible
Subject: Re: getloadavg and errno
Date: Tue, 15 Feb 2011 11:51:57 +0100
User-agent: KMail/1.9.9

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.

Bruno
-- 
In memoriam Matija Gubec <http://en.wikipedia.org/wiki/Matija_Gubec>



reply via email to

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