From 58da4c35b15200b7279f18ea15bc8644618aae78 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 1 May 2020 17:19:27 +0200 Subject: prog: introduce Field type Remvoe FieldName from Type and add a separate Field type that holds field name. Use Field for struct fields, union options and syscalls arguments, only these really have names. Reduces size of sys/linux/gen/amd64.go from 5665583 to 5201321 (-8.2%). Allows to not create new type for squashed any pointer. But main advantages will follow, e.g. removing StructDesc, using TypeRef in Arg, etc. Update #1580 --- sys/linux/init_vusb.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sys/linux/init_vusb.go') diff --git a/sys/linux/init_vusb.go b/sys/linux/init_vusb.go index fc847be41..e5b67b835 100644 --- a/sys/linux/init_vusb.go +++ b/sys/linux/init_vusb.go @@ -171,9 +171,10 @@ func (arch *arch) generateUsbHidDeviceDescriptor(g *prog.Gen, typ0 prog.Type, di } func patchGroupArg(arg prog.Arg, index int, field string, value uint64) { - fieldArg := arg.(*prog.GroupArg).Inner[index].(*prog.ConstArg) - if fieldArg.Type().FieldName() != field { - panic(fmt.Sprintf("bad field, expected %v, found %v", field, fieldArg.Type().FieldName())) + a := arg.(*prog.GroupArg) + typ := a.Type().(*prog.StructType) + if field != typ.Fields[index].Name { + panic(fmt.Sprintf("bad field, expected %v, found %v", field, typ.Fields[index].Name)) } - fieldArg.Val = value + a.Inner[index].(*prog.ConstArg).Val = value } -- cgit mrf-deployment