• Home
  • Raw
  • Download

Lines Matching refs:arg

54 	for i, arg := range c.Args {
55 if err := ctx.validateArg(arg, c.Meta.Args[i]); err != nil {
81 func (ctx *validCtx) validateArg(arg Arg, typ Type) error {
82 if arg == nil {
85 if ctx.args[arg] {
86 return fmt.Errorf("arg %#v is referenced several times in the tree", arg)
88 if arg.Type() == nil {
91 if !ctx.target.isAnyPtr(arg.Type()) && arg.Type() != typ {
92 return fmt.Errorf("bad arg type %#v, expect %#v", arg.Type(), typ)
94 ctx.args[arg] = true
95 return arg.validate(ctx)
98 func (arg *ConstArg) validate(ctx *validCtx) error {
99 switch typ := arg.Type().(type) {
101 if typ.Dir() == DirOut && !isDefault(arg) {
102 return fmt.Errorf("out int arg '%v' has bad const value %v", typ.Name(), arg.Val)
105 if arg.Val >= typ.ValuesPerProc && !isDefault(arg) {
106 return fmt.Errorf("per proc arg '%v' has bad value %v", typ.Name(), arg.Val)
109 if arg.Val != 0 {
110 return fmt.Errorf("csum arg '%v' has nonzero value %v", typ.Name(), arg.Val)
114 return fmt.Errorf("const arg %v has bad type %v", arg, typ.Name())
116 if typ := arg.Type(); typ.Dir() == DirOut {
120 if !typ.isDefaultArg(arg) {
122 typ.FieldName(), typ.Name(), arg)
129 func (arg *ResultArg) validate(ctx *validCtx) error {
130 typ, ok := arg.Type().(*ResourceType)
132 return fmt.Errorf("result arg %v has bad type %v", arg, arg.Type().Name())
134 for u := range arg.uses {
136 return fmt.Errorf("nil reference in uses for arg %+v", arg)
138 if u.Res != arg {
139 return fmt.Errorf("result arg '%v' has broken uses link to (%+v)", arg, u)
141 ctx.uses[u] = arg
143 if typ.Dir() == DirOut && arg.Val != 0 && arg.Val != typ.Default() {
144 return fmt.Errorf("out resource arg '%v' has bad const value %v", typ.Name(), arg.Val)
146 if arg.Res != nil {
147 if !ctx.args[arg.Res] {
149 typ.Name(), arg, arg.Res)
151 if !arg.Res.uses[arg] {
152 return fmt.Errorf("result arg '%v' has broken link (%+v)", typ.Name(), arg.Res.uses)
158 func (arg *DataArg) validate(ctx *validCtx) error {
159 typ, ok := arg.Type().(*BufferType)
161 return fmt.Errorf("data arg %v has bad type %v", arg, arg.Type().Name())
163 if typ.Dir() == DirOut && len(arg.data) != 0 {
166 if !typ.Varlen() && typ.Size() != arg.Size() {
168 typ.Name(), arg.Size(), typ.Size())
172 if typ.TypeSize != 0 && arg.Size() != typ.TypeSize {
174 typ.Name(), arg.Size(), typ.TypeSize)
177 file := string(arg.data)
184 return fmt.Errorf("sandbox escaping file name %q", string(arg.data))
190 func (arg *GroupArg) validate(ctx *validCtx) error {
191 switch typ := arg.Type().(type) {
193 if len(arg.Inner) != len(typ.Fields) {
195 typ.Name(), len(typ.Fields), len(arg.Inner))
197 for i, field := range arg.Inner {
204 uint64(len(arg.Inner)) != typ.RangeBegin {
206 typ.Name(), len(arg.Inner), typ.RangeBegin)
208 for _, elem := range arg.Inner {
214 return fmt.Errorf("group arg %v has bad type %v", arg, typ.Name())
219 func (arg *UnionArg) validate(ctx *validCtx) error {
220 typ, ok := arg.Type().(*UnionType)
222 return fmt.Errorf("union arg %v has bad type %v", arg, arg.Type().Name())
226 if arg.Option.Type().FieldName() == typ1.FieldName() {
234 return ctx.validateArg(arg.Option, optType)
237 func (arg *PointerArg) validate(ctx *validCtx) error {
238 switch typ := arg.Type().(type) {
240 if arg.Res != nil {
244 if arg.Res == nil && !arg.Type().Optional() {
247 if arg.Res != nil {
248 if err := ctx.validateArg(arg.Res, typ.Type); err != nil {
252 if arg.VmaSize != 0 {
259 return fmt.Errorf("ptr arg %v has bad type %v", arg, typ.Name())
262 size := arg.VmaSize
263 if size == 0 && arg.Res != nil {
264 size = arg.Res.Size()
266 if arg.Address >= maxMem || arg.Address+size > maxMem {
268 arg.Type().Name(), arg.Address, arg.VmaSize, size)