[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] Re: Bug in getloadavg
From: |
Bruno Haible |
Subject: |
Re: [Bug-gnulib] Re: Bug in getloadavg |
Date: |
Tue, 30 Mar 2004 12:20:01 +0200 |
User-agent: |
KMail/1.5 |
Paul Eggert wrote:
> + old_locale = xstrdup (setlocale (LC_NUMERIC, NULL));
Since setlocale can return NULL (or, at least, the replacement stub for
absent setlocale is NULL) and xstrdup (NULL) is invalid, I would rewrite
this as
old_locale = setlocale (LC_NUMERIC, NULL);
if (old_locale != NULL)
old_locale = xstrdup (old_locale);
> /* Set the `FD_CLOEXEC' flag of DESC if VALUE is true,
> or clear the flag if VALUE is false.
> Return true on success, or false on error with `errno' set. */
>
> bool
> set_cloexec_flag (int desc, bool value)
Maybe I'm the only one, but I have a problem with functions returning
'bool' and errno. Namely, the calling convention is just the opposite
of so many Unix functions, like close(), shmdt() etc. For all these
functions 0 means success and -1 means failure. I would find a calling
convention
/* Set the `FD_CLOEXEC' flag of DESC if VALUE is true,
or clear the flag if VALUE is false.
Return 0 on success, or -1 on error with `errno' set. */
int
set_cloexec_flag (int desc, bool value)
much easier to remember.
Bruno