From 8b5eac6623e02ad6cd336c710113b5664c5c7886 Mon Sep 17 00:00:00 2001
From: Daniel Czerwonk <daniel@dan-nrw.de>
Date: Sat, 12 May 2018 23:42:09 +0200
Subject: [PATCH] refactoring of return values

---
 routingtable/filter/actions/accept_action.go | 4 ++--
 routingtable/filter/actions/reject_action.go | 4 ++--
 routingtable/filter/term.go                  | 6 ++----
 routingtable/filter/term_test.go             | 4 ++--
 routingtable/filter/then.go                  | 2 +-
 5 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/routingtable/filter/actions/accept_action.go b/routingtable/filter/actions/accept_action.go
index 301592a4..6c0cc2ac 100644
--- a/routingtable/filter/actions/accept_action.go
+++ b/routingtable/filter/actions/accept_action.go
@@ -8,6 +8,6 @@ import (
 type AcceptAction struct {
 }
 
-func (*AcceptAction) Do(p net.Prefix, pa *route.Path) (bool, *route.Path) {
-	return true, pa
+func (*AcceptAction) Do(p net.Prefix, pa *route.Path) (modPath *route.Path, reject bool) {
+	return pa, false
 }
diff --git a/routingtable/filter/actions/reject_action.go b/routingtable/filter/actions/reject_action.go
index 1fc7316a..d7401396 100644
--- a/routingtable/filter/actions/reject_action.go
+++ b/routingtable/filter/actions/reject_action.go
@@ -8,6 +8,6 @@ import (
 type RejectAction struct {
 }
 
-func (*RejectAction) Do(p net.Prefix, pa *route.Path) (bool, *route.Path) {
-	return false, pa
+func (*RejectAction) Do(p net.Prefix, pa *route.Path) (modPath *route.Path, reject bool) {
+	return pa, true
 }
diff --git a/routingtable/filter/term.go b/routingtable/filter/term.go
index 1ca09d10..85a88eb8 100644
--- a/routingtable/filter/term.go
+++ b/routingtable/filter/term.go
@@ -39,13 +39,11 @@ func (t *Term) Process(p net.Prefix, pa *route.Path) (modPath *route.Path, rejec
 }
 
 func (t *Term) processActions(p net.Prefix, pa *route.Path) (modPath *route.Path, reject bool) {
-	var result bool
 	modPath = pa
 
 	for _, action := range t.then {
-		result, modPath = action.Do(p, modPath)
-		if !result {
-			reject = true
+		modPath, reject = action.Do(p, modPath)
+		if reject {
 			continue
 		}
 	}
diff --git a/routingtable/filter/term_test.go b/routingtable/filter/term_test.go
index 6ff40c80..ee55c712 100644
--- a/routingtable/filter/term_test.go
+++ b/routingtable/filter/term_test.go
@@ -12,11 +12,11 @@ import (
 type mockAction struct {
 }
 
-func (*mockAction) Do(p net.Prefix, pa *route.Path) (bool, *route.Path) {
+func (*mockAction) Do(p net.Prefix, pa *route.Path) (*route.Path, bool) {
 	cp := *pa
 	cp.Type = route.OSPFPathType
 
-	return true, &cp
+	return &cp, false
 }
 
 func TestProcess(t *testing.T) {
diff --git a/routingtable/filter/then.go b/routingtable/filter/then.go
index b16aed48..920daf43 100644
--- a/routingtable/filter/then.go
+++ b/routingtable/filter/then.go
@@ -6,5 +6,5 @@ import (
 )
 
 type Then interface {
-	Do(p net.Prefix, pa *route.Path) (bool, *route.Path)
+	Do(p net.Prefix, pa *route.Path) (modPath *route.Path, reject bool)
 }
-- 
GitLab