Thread (11 messages) flat view 11 messages, 4 authors, 2016-06-15

Re: [PATCH 1/3] send-email: use "return;" not "return undef;" on error codepaths

From: Eric Sunshine <hidden>
Date: 2016-06-15 22:56:35

Possibly related (same subject, not in this thread)

On Sun, Mar 31, 2013 at 9:40 PM, Junio C Hamano [off-list ref] wrote:
All the callers of "ask", "extract_valid_address", and "validate_patch"
subroutines assign the return values from them to a single scaler:
s/scaler/scalar/g

(note the /g)
        $var = subr(...);

and "return undef;" in these subroutine can safely be turned into a
simpler "return;".  Doing so will also future-proof a new caller that
mistakenly does this:

    @foo = ask(...);
    if (@foo) { ... we got an answer ... } else { ... we did not ... }

Note that we leave "return undef;" in validate_address on purpose,
even though Perlcritic may complain.  The primary "return" site of
the function returns whatever is in the scaler variable $address, so
it is pointless to change only the other "return undef;" to "return".
The caller must be prepared to see an array with a single undef as
the return value from this subroutine anyway.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help