Skip to content

Commit

Permalink
send-email: use "return;" not "return undef;" on error codepaths
Browse files Browse the repository at this point in the history
All the callers of "ask", "extract_valid_address", and "validate_patch"
subroutines assign the return values from them to a single scalar:

	$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 scalar 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.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Ramkumar Ramachandra authored and Junio C Hamano committed Apr 1, 2013
1 parent 5e950c2 commit 622bc93
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ sub ask {
}
}
}
return undef;
return;
}

my %broken_encoding;
Expand Down Expand Up @@ -833,7 +833,7 @@ sub extract_valid_address {
# less robust/correct than the monster regexp in Email::Valid,
# but still does a 99% job, and one less dependency
return $1 if $address =~ /($local_part_regexp\@$domain_regexp)/;
return undef;
return;
}

sub extract_valid_address_or_die {
Expand Down Expand Up @@ -1484,7 +1484,7 @@ sub validate_patch {
return "$.: patch contains a line longer than 998 characters";
}
}
return undef;
return;
}

sub file_has_nonascii {
Expand Down

0 comments on commit 622bc93

Please sign in to comment.