From d59b6c7cd8893ca076cacf1798b340f8fe54a19d Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 16 Sep 2024 19:45:15 +0200 Subject: [PATCH] MT#60917 NGCP::Template::Object: Do not use sort on return 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 --- lib/NGCP/Template/Object.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/NGCP/Template/Object.pm b/lib/NGCP/Template/Object.pm index e72f5886..8cd09395 100644 --- a/lib/NGCP/Template/Object.pm +++ b/lib/NGCP/Template/Object.pm @@ -182,7 +182,8 @@ sub get_sibnames push @sibnames, $thishost; } - return sort @sibnames; + my @res = sort @sibnames; + return @res; } sub get_firstname @@ -259,7 +260,8 @@ sub get_hosts push @hosts, $host; } - return sort @hosts; + my @res = sort @hosts; + return @res; } sub get_instances