[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: getloadavg: check for c_strtod errors
From: |
Jim Meyering |
Subject: |
Re: getloadavg: check for c_strtod errors |
Date: |
Wed, 21 Jan 2009 14:01:02 +0100 |
Bruno Haible <address@hidden> wrote:
> getloadavg uses c_strtod, but does not completely chcek against all error
> conditions (such as EINVAL or ENOMEM). Here's a proposed patch to that effect.
>
> The strtod documentation in POSIX says:
> "Since 0 is returned on error and is also a valid return on success, an
> application wishing to check for error situations should set errno to 0,
> then call strtod(), strtof(), or strtold(), then check errno."
> This applies also to c_strtod, since it call strtod().
>
> The test for 'ptr == endptr' is still necessary, though, since at least
> on glibc systems, strtod ("foo", &endptr) returns 0 with errno = 0.
>
> OK to commit?
>
> 2009-01-21 Bruno Haible <address@hidden>
>
> * lib/getloadavg.c (getloadavg): Check c_strtod result against error
> conditions other than overflow.
Fine change. Thanks.
Go ahead.