Skip to content

Commit

Permalink
headerdep: perlcritic warning
Browse files Browse the repository at this point in the history
Minor perlcritic warning:
headerdep.pl: "return" statement with explicit "undef" at line 84, column 2.  See page 199 of PBP.  (Severity: 5)

The rationale according to PBP is that an explicit return of undef
(contrary to most people's expectations) doesn't
always evaluate as false. It has to with the fact that perl return value
depends on context the function is called. If function is used in
list context, the appropriate return value for false is an empty list;
whereas in scalar context the return value for false is undefined.
By just using a "return" both cases are handled.

In the context of a trivial script this doesn't matter. But one script
may be cut-paste into later code (most people like me only know 50%
of perl), that is why perlcritic always complains

Signed-off-by: Stephen Hemminger <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
Stephen Hemminger authored and michal42 committed Mar 23, 2010
1 parent 2d74b2c commit 1dcd810
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions scripts/headerdep.pl
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ sub search {
my $path = "$i/$filename";
return $path if -f $path;
}

return undef;
return;
}

sub parse_all {
Expand Down

0 comments on commit 1dcd810

Please sign in to comment.