From 0b3e125fda2e386091985b4b57231dd19341f64e Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 8 Mar 2024 17:24:27 +0100 Subject: Revert "sys/linux: clone args before mutation" This reverts commit 4097c8d7a8596ddbc9a9db7b7f39c5cbdb1bd742. --- prog/clone.go | 4 ---- prog/prog.go | 3 --- sys/linux/init_iptables.go | 4 ++-- sys/linux/init_vusb.go | 4 ++-- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/prog/clone.go b/prog/clone.go index 4523be0eb..029cf94c4 100644 --- a/prog/clone.go +++ b/prog/clone.go @@ -39,10 +39,6 @@ func cloneCall(c *Call, newargs map[*ResultArg]*ResultArg) *Call { return c1 } -func CloneArg(arg Arg) Arg { - return clone(arg, nil) -} - func clone(arg Arg, newargs map[*ResultArg]*ResultArg) Arg { var arg1 Arg switch a := arg.(type) { diff --git a/prog/prog.go b/prog/prog.go index da6f158bc..f93293b64 100644 --- a/prog/prog.go +++ b/prog/prog.go @@ -354,9 +354,6 @@ func (p *Prog) insertBefore(c *Call, calls []*Call) { // replaceArg replaces arg with arg1 in a program. func replaceArg(arg, arg1 Arg) { - if arg == arg1 { - panic("replacing an argument with itself") - } switch a := arg.(type) { case *ConstArg: *a = *arg1.(*ConstArg) diff --git a/sys/linux/init_iptables.go b/sys/linux/init_iptables.go index 95825d33c..7e96662fb 100644 --- a/sys/linux/init_iptables.go +++ b/sys/linux/init_iptables.go @@ -31,7 +31,7 @@ func (arch *arch) generateNetfilterTable(g *prog.Gen, typ prog.Type, dir prog.Di } else { // TODO(dvyukov): try to restore original hook order after mutation // instead of assigning brand new offsets. - arg = prog.CloneArg(old) + arg = old calls = g.MutateArg(arg) } var tableArg *prog.GroupArg @@ -113,7 +113,7 @@ func (arch *arch) generateEbtables(g *prog.Gen, typ prog.Type, dir prog.Dir, old } else { // TODO(dvyukov): try to restore original hook order after mutation // instead of assigning brand new offsets. - arg = prog.CloneArg(old) + arg = old calls = g.MutateArg(arg) } if g.Target().ArgContainsAny(arg) { diff --git a/sys/linux/init_vusb.go b/sys/linux/init_vusb.go index ca645bf45..5e4244f6e 100644 --- a/sys/linux/init_vusb.go +++ b/sys/linux/init_vusb.go @@ -55,7 +55,7 @@ func (arch *arch) generateUsbDeviceDescriptor(g *prog.Gen, typ0 prog.Type, dir p if old == nil { arg = g.GenerateSpecialArg(typ0, dir, &calls) } else { - arg = prog.CloneArg(old) + arg = old calls = g.MutateArg(arg) } if g.Target().ArgContainsAny(arg) { @@ -144,7 +144,7 @@ func (arch *arch) generateUsbHidDeviceDescriptor(g *prog.Gen, typ0 prog.Type, di if old == nil { arg = g.GenerateSpecialArg(typ0, dir, &calls) } else { - arg = prog.CloneArg(old) + arg = old calls = g.MutateArg(arg) } if g.Target().ArgContainsAny(arg) { -- cgit mrf-deployment