diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-05-01 17:19:27 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-05-02 12:16:06 +0200 |
| commit | 58da4c35b15200b7279f18ea15bc8644618aae78 (patch) | |
| tree | 412d59572c980c4eb582d6d0e187eb6ec32345c9 /sys/linux/init_vusb.go | |
| parent | bc734e7ada413654f1b7d948b2a857260a52dd9c (diff) | |
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
Diffstat (limited to 'sys/linux/init_vusb.go')
| -rw-r--r-- | sys/linux/init_vusb.go | 9 |
1 files changed, 5 insertions, 4 deletions
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 } |
