From 5d8a2199b6c8dc5f75b529a39d196c6cb14c98c2 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Thu, 21 Aug 2025 00:18:50 +0900 Subject: container/init: op interface valid method Check ops early and eliminate duplicate checks. Signed-off-by: Ophestra --- container/init.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'container/init.go') diff --git a/container/init.go b/container/init.go index d516a3c2..663bbc83 100644 --- a/container/init.go +++ b/container/init.go @@ -52,6 +52,7 @@ type ( prefix() string Is(op Op) bool + Valid() bool fmt.Stringer } @@ -167,8 +168,8 @@ func Init(prepare func(prefix string), setVerbose func(verbose bool)) { via library functions after pivot_root, and implementations are expected to avoid changing the state of the mount namespace */ for i, op := range *params.Ops { - if op == nil { - log.Fatalf("invalid op %d", i) + if op == nil || !op.Valid() { + log.Fatalf("invalid op at index %d", i) } if err := op.early(state); err != nil { -- cgit v1.3.1