bug-gnulib
[Top][All Lists]
Advanced

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

Re: Openat without die


From: Jim Meyering
Subject: Re: Openat without die
Date: Tue, 11 Jan 2011 20:58:51 +0100

Paul Eggert wrote:
> I also don't see the need for all those checks for
> empty strings and the like.  Nor do I see the need
> for carefully setting errno = ENOMEM, as the calling
> code will try something else if malloc fails and maybe
> the something else will work and maybe it won't, but
> the calling code should set errno appropriately for
> whatever it tried.
>
> I noticed that the existing code is slightly too pessimistic
> about OPENAT_BUFFER_SIZE, which means an unnecessary
> call to malloc in some cases.
>
> One other thing; there should be no need to test
> whether buf == NULL; the caller is supposed to pass
> a nonnull buf.
>
> So I propose the following patch instead, which I came up
> with before reading Eric's nice review, but which I
> think agrees with his ideas, and adds the abovementioned
> tweaks.
>
> I haven't pushed this.
>
>>From 0c03ad4d899710d851135e1e72f1821e72fffe7e Mon Sep 17 00:00:00 2001
> From: Paul Eggert <address@hidden>
> Date: Tue, 11 Jan 2011 10:42:55 -0800
> Subject: [PATCH] openat: avoid xmalloc
>
> This removes a dependency on openat-die.  This change causes the
> openat substitute to fall back on savedir when memory is tight,

I suppose you mean save-cwd (the module name), not savedir.
Or maybe save_cwd/fchdir?

> but that's good enough.
> * lib/openat-proc.c: Include stdlib.h (for malloc), not
> xalloc.h (for xmalloc).
> (openat_proc_name): Check for malloc failure.
> ---
>  ChangeLog         |    8 ++++++++
>  lib/openat-proc.c |   13 ++++++++++---
>  2 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index f8cd305..06ee9db 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,5 +1,13 @@
>  2011-01-11  Paul Eggert  <address@hidden>
>
> +     openat: avoid xmalloc
> +     This removes a dependency on openat-die.  This change causes the
> +     openat substitute to fall back on savedir when memory is tight,

Same here, of course.

> +     but that's good enough.
> +     * lib/openat-proc.c: Include stdlib.h (for malloc), not
> +     xalloc.h (for xmalloc).
> +     (openat_proc_name): Check for malloc failure.



reply via email to

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