diff mbox series

[OSSTEST,33/82] plan search: Move $share_compat_ok further up the file

Message ID 20201007180024.7932-34-iwj@xenproject.org (mailing list archive)
State New, archived
Headers show
Series Reuse test hosts | expand

Commit Message

Ian Jackson Oct. 7, 2020, 5:59 p.m. UTC
From: Ian Jackson <ian.jackson@eu.citrix.com>

We are going to want to use this outside the loop.

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index e17b6503..4083ae6b 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -684,6 +684,23 @@  sub plan_search ($$$$) {
 
         $events ||= [ ];
 
+	my $share_compat_ok = sub {
+	    my ($eshare) = @_;
+	    $dbgprint->("PLAN LOOP   SHARE-COMPAT-OK ".
+		"type $eshare->{Type} vs. ".
+		    ($req->{Shared} // '<undef>')." ".
+		"wear $eshare->{Wear} ".
+		"shares $eshare->{Shares} vs. ".
+		    ($req->{SharedMaxTasks}//'<undef>'));
+	    return 0 unless defined $req->{Shared};
+	    return 0 unless $req->{Shared} eq $eshare->{Type};
+	    my $wear= $eshare->{Wear}+1;
+	    return 0 if $wear > $req->{SharedMaxWear};
+	    return 0 if $eshare->{Shares} != $req->{SharedMaxTasks};
+	    $dbgprint->("PLAN LOOP   SHARE-COMPAT-OK Y");
+	    return 1;
+	};
+
 	# can we do $req at $try_time ?  If not, when later can we ?
       PERIOD:
 	foreach (my $ix=0; $ix<@$events; $ix++) {
@@ -698,23 +715,6 @@  sub plan_search ($$$$) {
             # this period is entirely after the proposed slot;
             # so no need to check this or any later periods
 
-	    my $share_compat_ok = sub {
-		my ($eshare) = @_;
-		$dbgprint->("PLAN LOOP   SHARE-COMPAT-OK ".
-		    "type $eshare->{Type} vs. ".
-			($req->{Shared} // '<undef>')." ".
-		    "wear $eshare->{Wear} ".
-		    "shares $eshare->{Shares} vs. ".
-			($req->{SharedMaxTasks}//'<undef>'));
-		return 0 unless defined $req->{Shared};
-		return 0 unless $req->{Shared} eq $eshare->{Type};
-		my $wear= $eshare->{Wear}+1;
-		return 0 if $wear > $req->{SharedMaxWear};
-		return 0 if $eshare->{Shares} != $req->{SharedMaxTasks};
-		$dbgprint->("PLAN LOOP   SHARE-COMPAT-OK Y");
-		return 1;
-	    };
-
 	    next PERIOD if $endevt->{Time} <= $try_time;
             # this period is entirely before the proposed slot;
             # it doesn't overlap, but must check subsequent periods