[patch] save ~600B
walter harms
wharms at bfs.de
Mon Jun 5 14:44:07 UTC 2006
Paul Fox wrote:
> wharm wrote:
> > Bernhard Fischer wrote:
> > > On Mon, Jun 05, 2006 at 01:04:06PM +0200, walter harms wrote:
> > >> hi bernhard,
> > >> just a minor question.
> > >> Does exit(-1) make sense ? so far i remember the shell expects 0-255.
> > >
> > > IMO it does make sense. It it a means to make sure to return ~0, no
> > > matter what return type the shell happens to use.
> > > So, for "the shell" -- which likely happens to use unsigned char -- we
> > > return 255, while we wouldn't have to change all explicit calls to
> > > {_,}exit(255) iff the type would change, for whatever reason.
> > > Makes sense?
>
> only if that's what the programmer intended. in my experience,
> people that write "exit(-1)" usually are confusing the exit
> status or the program with the return code from a C function, and
> are forgetting that the traditional error exit status for a
> program is "1", or some other small non-zero integer.
>
> > personally i am the fan of
> > exit( EXIT_FAILURE ) ;
>
> and "EXIT_FAILURE" is cleverly defined as "1", right? why
> not just "exit(1)"? this keeps it simple, concise, and transparent.
>
> > we should define a way in the style guide.
> > and get rid of stuff like:
> > exit(ERROR);
>
> i agree. but "s/ERROR/EXIT_FAILURE/" accomplishes nothing.
>
you are right about the actual result (but i read somewhere some smart
system defined exit_* to something wired, never mind).
personaly (read: what i actualy trying to do) i want to conform with
posix since this is common ground. we both know what EXIT_FAILURE means
even if we do not know the aktual number.
But was does ERROR mean ? -1, 99, 255 ?
I thing we agree that the exit status should be compareable between the
bb programs not sometime -1 sometimes 1 or what ever.
That is the reason why i said i should belong to the style guide. It is
not a matter of live-or-death but readability is not bad after all.
re,
wh
/*
i know i does not matter in thins case but:
#ifdef vax11c
#define EXIT_SUCCESS 1
#define EXIT_FAILURE 2
#endif
*/
More information about the busybox
mailing list