diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2020-10-23 11:41:55 +0200 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2020-10-23 11:41:55 +0200 |
commit | cb540dc166c12180adba024d5b8fd463d2582928 (patch) | |
tree | ac013d263d73fa772e26c13b8e1bc429210a358b | |
parent | 9ea1f778fb1458ce6b2265941885eab0b34b33d7 (diff) |
Fix panic for Retval fields with uint kinds
Change-Id: I5e588d48461a0cf551552a5068218a58920e52aa
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
-rw-r--r-- | core/channel.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/core/channel.go b/core/channel.go index 1b5e77e..28d0710 100644 --- a/core/channel.go +++ b/core/channel.go @@ -350,7 +350,15 @@ func (ch *Channel) processReply(reply *vppReply, expSeqNum uint16, msg api.Messa if strings.HasSuffix(msg.GetMessageName(), "_reply") { // TODO: use categories for messages to avoid checking message name if f := reflect.Indirect(reflect.ValueOf(msg)).FieldByName("Retval"); f.IsValid() { - retval := int32(f.Int()) + var retval int32 + switch f.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + retval = int32(f.Int()) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + retval = int32(f.Uint()) + default: + logrus.Warnf("invalid kind (%v) for Retval field of message %v", f.Kind(), msg.GetMessageName()) + } err = api.RetvalToVPPApiError(retval) } } |