[Top][All Lists]
[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.
- Re: Openat without die, (continued)
- Re: Openat without die, Paul Eggert, 2011/01/11
- Re: Openat without die, Eric Blake, 2011/01/11
- Re: Openat without die, Eric Blake, 2011/01/11
- Re: Openat without die, Paul Eggert, 2011/01/11
- Re: Openat without die, Eric Blake, 2011/01/11
- Re: Openat without die, Jim Meyering, 2011/01/11
- Re: Openat without die, Paul Eggert, 2011/01/11
- Re: Openat without die, Jim Meyering, 2011/01/11
- Re: Openat without die, Paul Eggert, 2011/01/11
- Re: Openat without die, Jim Meyering, 2011/01/11
- Re: Openat without die,
Jim Meyering <=
- Message not available
- ChangeLog fix for openat-die fix, Paul Eggert, 2011/01/12
- Re: Openat without die, Bastien ROUCARIES, 2011/01/12
- Re: Openat without die, Eric Blake, 2011/01/12
- Re: Openat without die, Bruno Haible, 2011/01/11
- Re: Openat without die, Jim Meyering, 2011/01/13
Re: Openat without die, Jim Meyering, 2011/01/11