aboutsummaryrefslogtreecommitdiffstats
path: root/prog/validation.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-12-14 17:05:33 +0100
committerDmitry Vyukov <dvyukov@google.com>2017-12-17 11:39:14 +0100
commitdcfdc02b77d45a5cdf12273fb6cb0227e5cc6e4c (patch)
tree3c8057bd67b947ccdaf6c9d239cdf68b4c7304be /prog/validation.go
parent9c21f3116fc2059a66c2cff309a303933daf8934 (diff)
prog: minor refactoring around arguments
Introduce isUsed(arg) helper, use it in several places. Move method definitions closer to their types. Simplify presence check for ArgUsed.Used() in several places.
Diffstat (limited to 'prog/validation.go')
-rw-r--r--prog/validation.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/prog/validation.go b/prog/validation.go
index d0f6d0bd2..288a8172b 100644
--- a/prog/validation.go
+++ b/prog/validation.go
@@ -48,7 +48,8 @@ func (c *Call) validate(ctx *validCtx) error {
if used, ok := arg.(ArgUsed); ok {
for u := range *used.Used() {
if u == nil {
- return fmt.Errorf("syscall %v: nil reference in uses for arg %+v", c.Meta.Name, arg)
+ return fmt.Errorf("syscall %v: nil reference in uses for arg %+v",
+ c.Meta.Name, arg)
}
ctx.uses[u] = arg
}
@@ -246,8 +247,9 @@ func (c *Call) validate(ctx *validCtx) error {
return fmt.Errorf("syscall %v: result arg '%v' references out-of-tree result: %p%+v -> %p%+v",
c.Meta.Name, a.Type().Name(), arg, arg, a.Res, a.Res)
}
- if _, ok := (*a.Res.(ArgUsed).Used())[arg]; !ok {
- return fmt.Errorf("syscall %v: result arg '%v' has broken link (%+v)", c.Meta.Name, a.Type().Name(), *a.Res.(ArgUsed).Used())
+ if !(*a.Res.(ArgUsed).Used())[arg] {
+ return fmt.Errorf("syscall %v: result arg '%v' has broken link (%+v)",
+ c.Meta.Name, a.Type().Name(), *a.Res.(ArgUsed).Used())
}
case *ReturnArg:
switch a.Type().(type) {