Re: PATCH: Do not call xmalloc_failed in expandargv

Mark Mitchell
2005-09-27T15:46:06Z

DJ Delorie wrote:

> I seem to recall a general policy (before my time) that libiberty
> functions shouldn't ever exit on error; the proper response is to
> return some error condition to the application. Since expandargv()
> doesn't have an error response, IMHO the right thing to do is treat
> @foo as if it weren't a file and just return the original argv[n].
> The application will hopefully discover the out of memory condition
> itself and use its own handlers to deal with it.

xmalloc is in libiberty, and it calls xmalloc_failed when it fails,
which itself calls xexit. That's the source of the idiom; I was just
trying to be consistent.

I can make the change that you suggest, if you think it's important, but
it seems more friendly to the user to just tell them early that there
was a problem; the application won't know if "@foo" remains in the
argument list because there was no such file "foo" or because it
happened to be too big. In the latter case, the program should exit; in
the former, we've agreed that "@foo" should be treated as a literal
command-line argument.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304