Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Commit

Permalink
Ensure we set parameter type correctly
Browse files Browse the repository at this point in the history
When allocating a new virTypedParameter array we were forgetting
to initialize the parameter type, causing non-deterministic
failures

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
  • Loading branch information
berrange committed Dec 20, 2016
1 parent d22f04f commit 1dfd583
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions typedparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,27 @@ func typedParamsPackNew(infomap map[string]typedParamsFieldInfo) (*[]C.virTypedP
if value.sl != nil {
for i := 0; i < len(*value.sl); i++ {
cparam := &cparams[nparams]
cparam._type = C.VIR_TYPED_PARAM_STRING
C.memcpy(unsafe.Pointer(&cparam.field[0]), unsafe.Pointer(cfield), C.size_t(clen))
nparams++
}
} else {
cparam := &cparams[nparams]
if value.i != nil {
cparam._type = C.VIR_TYPED_PARAM_INT
} else if value.ui != nil {
cparam._type = C.VIR_TYPED_PARAM_UINT
} else if value.l != nil {
cparam._type = C.VIR_TYPED_PARAM_LLONG
} else if value.ul != nil {
cparam._type = C.VIR_TYPED_PARAM_ULLONG
} else if value.b != nil {
cparam._type = C.VIR_TYPED_PARAM_BOOLEAN
} else if value.d != nil {
cparam._type = C.VIR_TYPED_PARAM_DOUBLE
} else if value.s != nil {
cparam._type = C.VIR_TYPED_PARAM_STRING
}
C.memcpy(unsafe.Pointer(&cparam.field[0]), unsafe.Pointer(cfield), C.size_t(clen))
nparams++
}
Expand Down

0 comments on commit 1dfd583

Please sign in to comment.