Skip to content

Commit 622bc93

Browse files
artagnongitster
authored andcommitted
send-email: use "return;" not "return undef;" on error codepaths
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5e950c2 commit 622bc93

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

git-send-email.perl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ sub ask {
711711
}
712712
}
713713
}
714-
return undef;
714+
return;
715715
}
716716

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

839839
sub extract_valid_address_or_die {
@@ -1484,7 +1484,7 @@ sub validate_patch {
14841484
return "$.: patch contains a line longer than 998 characters";
14851485
}
14861486
}
1487-
return undef;
1487+
return;
14881488
}
14891489

14901490
sub file_has_nonascii {

0 commit comments

Comments
 (0)