IMAO, putting an unnecessary return at the end of a function is just
waffling, and from a purely style point of view, I would always eliminate
such a return. It's just noise.
O boy a style war!
It's not just noise. Consider what happens if the function
undergoes multiple changes. The first change comes in response to
a bug where the program mysteriously crashes. Turns our that b_init()
will
crash if a_init fails. So the first change is
void init_function(void)
{
if(!a_init())
return;
b_init();
c_init();
}
things are OK for a while (no bugs have to be fixed), but a change in
OS means
that it is no longer easy to tell if a_init() failed or not. So a
change is
made so init_function returns SUCCESS or FAILURE
int init_function(void)
{
if(!a_init())
return FAILURE;
b_init();
c_init();
}
(Whoops, didn't catch the implicit return, the change should not
have been done by someone who assumed all returns were explicit.
Don't use that
contractor again.). Falling off now causes undefined
behaviour, which in this case is to return the value of a register,
which
happens to be non-zero, and tests false when compared to failure.
Things look fine. Until the next release of the compiler, when the
register now contains 0.
The fact that four programmers are involved does not help.
- William Hughes