Skip to content

Commit

Permalink
MT#60917 NGCP::Template::Object: Do not use sort on return
Browse files Browse the repository at this point in the history
The sort function is undefined in scalar context, which means a call
site that calls these functions in scalar context will trigger undefined
behavior.

Sort the result and return the list.

Fixes: Subroutines::ProhibitReturnSort
Warned-by: perlcritic
Change-Id: I355b5e3e412bc91c297a46a73bb6caba6e969f54
  • Loading branch information
guillemj committed Sep 16, 2024
1 parent fda5db9 commit d59b6c7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/NGCP/Template/Object.pm
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ sub get_sibnames
push @sibnames, $thishost;
}

return sort @sibnames;
my @res = sort @sibnames;
return @res;
}

sub get_firstname
Expand Down Expand Up @@ -259,7 +260,8 @@ sub get_hosts
push @hosts, $host;
}

return sort @hosts;
my @res = sort @hosts;
return @res;
}

sub get_instances
Expand Down

0 comments on commit d59b6c7

Please sign in to comment.