info-cvs
[Top][All Lists]
Advanced

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

Re: incorrect return code on vms...


From: David H. Thornley
Subject: Re: incorrect return code on vms...
Date: Fri, 01 Dec 2000 11:05:46 -0600

Donald Sharp wrote:
> 
> On Fri, Dec 01, 2000 at 09:47:52AM -0600, David H. Thornley wrote:
> >
> >
> > Donald Sharp wrote:
> > >
> > > If the return codes for a program are reversed on vms,
> > > such that success = 1 and failure = 0, then cvs would
> > > always exit with a failure on vms systems.  Attached
> > > is a patch to fix this problem.
> > >
> > Assuming that VMS has a conforming C compiler, this is not
> > a problem.  The C system interprets both 0 and EXIT_SUCCESS
> > as successful exits, and EXIT_FAILURE as a failure exit.
> > These are defined in <stdlib.h>.
> 
> You missunderstand what I did.  This has nothing to do
> with the c compiler.  It has everything to do with what
> cvs returned as a exit code.  The vms system( according to
> the ChangeLog ) interprets return codes from programs as follows:
> 0 - Program failed
> 1 - Program Succeeded.
> 
No, it has to do with what happens between the writing of the
C program and the status return to the operating system.  That
is where the C compiler comes in.

In Unix, for example, the null pointer value is all-bits-zero,
zero is a successful program exit code, and other values are
various sorts of errors.  Following this, in C, 0 (cast to
pointer type) is a null pointer value, and 0 is an exit code
that represents success.

On some platforms, all-bits-zero is a valid pointer, and there
is some other invalid pointer.  This does not break working
code, as the C system simply translates (void *)0 (or whatever)
to the appropriate pointer value.

Similarly, on some platforms, 0 is the failure exit, and the
C system simply translates appropriately.

> Original code did this:
> 
>         exit( err ? EXIT_FAILURE : 0 );
> 
> Within cvs err is set to 0 for program success and >0 for failure.
> 
In other words, the program is completely correct here.  That is
perfectly good code according to the standard.

> stdlib.h on vms should set EXIT_FAILURE to 0.  Therefore the
> above exit() code will always return 0 on vms.  I assumed that EXIT_SUCCESS
> would be set to the correct thing.  Hence:
> 
If stdlib.h on vms sets EXIT_FAILURE to 0, it is not a conforming
C compiler, and, as I said, you should find a better one or
gripe to your vendor if you run into this problem.  0 is, by
definition in the Standard, a successful value.  If the exit()
function has something like "return !exit_value" in it, it will
pass the correct value to the operating system.  (This is
platform-specific code, of course, which the standard libraries
pretty much have to be.)

EXIT_SUCCESS may be set to 0, or it may be set to some other
value the system finds convenient.  However, EXIT_FAILURE
may not be set to 0.

>         exit( err ? EXIT_FAILURE : EXIT_SUCCESS );
> 
> I #defined EXIT_SUCCESS in system.h ostensibly for old sun boxes
> see the comment above the EXIT_FAILURE line in system.h.
> 
If this is catering for pre-standard compilers, then my only
problem with it is that people should get standard C compilers
if they want to compile code on multiple platforms.

> If vms isn't setting EXIT_FAILURE or EXIT_SUCCESS then we
> need to fix the #defines in system.h to do the right thing
> on vms.
> 
If <stdlib.h> doesn't set EXIT_FAILURE or EXIT_SUCCESS, the C
compiler (with libraries) probably has other problems also.
I just don't see how, in December 2000, I can advise using
compilers that do not try to conform to an eleven-year-old
standard.

> Also we should not be returning 0, we should be using EXIT_SUCCESS
> in the code in main() in order for the right thing to be done...
> 
Returning 0 is the right thing.  So is returning EXIT_SUCCESS.
Returning anything else would be the wrong thing in a program
expected to run on several different platforms.  (It could be
the right thing to do for a platform-specific program, which
CVS is not.)

> Having said all that I bet this is a moot point in a lot of respects.
> Is anyone even using VMS?
> 
I heard that DEC has dumped all support for the Vaxen, but that
VMS still runs on Alphas.  Some people are still using it,
and are presumably happy with it.


-- 
David H. Thornley                          Software Engineer
at CES International, Inc.:  address@hidden or (763)-694-2556
at home: (612)-623-0552 or address@hidden or
http://www.visi.com/~thornley/david/



reply via email to

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