From 983508d80442a85b78118e6c6a03d5ae4897e4df Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 4 Jan 2022 10:35:26 +0100 Subject: prog: pass ctx by pointer to ForeachType callback This will allow callbacks to stop iteration early by setting ctx.Stop flag (as it works for ForeachArg). --- pkg/compiler/gen.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pkg/compiler') diff --git a/pkg/compiler/gen.go b/pkg/compiler/gen.go index 3d5517ae8..c4909b853 100644 --- a/pkg/compiler/gen.go +++ b/pkg/compiler/gen.go @@ -147,7 +147,7 @@ func (comp *compiler) generateTypes(syscalls []*prog.Syscall) []prog.Type { // Replace all Type's in the descriptions with Ref's // and prepare a sorted array of corresponding real types. proxies := make(map[string]*typeProxy) - prog.ForeachTypePost(syscalls, func(typ prog.Type, ctx prog.TypeCtx) { + prog.ForeachTypePost(syscalls, func(typ prog.Type, ctx *prog.TypeCtx) { if _, ok := typ.(prog.Ref); ok { return } @@ -195,7 +195,7 @@ func (comp *compiler) generateTypes(syscalls []*prog.Syscall) []prog.Type { func (comp *compiler) layoutTypes(syscalls []*prog.Syscall) { // Calculate struct/union/array sizes, add padding to structs, mark bitfields. padded := make(map[prog.Type]bool) - prog.ForeachTypePost(syscalls, func(typ prog.Type, _ prog.TypeCtx) { + prog.ForeachTypePost(syscalls, func(typ prog.Type, _ *prog.TypeCtx) { comp.layoutType(typ, padded) }) } -- cgit mrf-deployment