aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2021-12-23 14:27:30 +0000
committerJaap Keuter <jaap.keuter@xs4all.nl>2021-12-23 14:27:30 +0000
commitf151e1b0c2521ce838cdee6f32014296185e7dc9 (patch)
treeb1ea38cb8edfeaf422e93e4326af86fcd15b49ff /epan/tvbuff.c
parent54e9c99041701f544e5ea58fb484414d5c0bc90a (diff)
Refactor VARINT handling
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 26f69cf473..9c411fdad3 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -4486,7 +4486,9 @@ tvb_get_varint(tvbuff_t *tvb, guint offset, guint maxlen, guint64 *value, const
{
*value = 0;
- if (encoding & ENC_VARINT_PROTOBUF) {
+ switch (encoding & ENC_VARINT_MASK) {
+ case ENC_VARINT_PROTOBUF:
+ {
guint i;
guint64 b; /* current byte */
@@ -4499,7 +4501,11 @@ tvb_get_varint(tvbuff_t *tvb, guint offset, guint maxlen, guint64 *value, const
return i + 1;
}
}
- } else if (encoding & ENC_VARINT_ZIGZAG) {
+ break;
+ }
+
+ case ENC_VARINT_ZIGZAG:
+ {
guint i;
guint64 b; /* current byte */
@@ -4513,9 +4519,11 @@ tvb_get_varint(tvbuff_t *tvb, guint offset, guint maxlen, guint64 *value, const
return i + 1;
}
}
+ break;
}
- else if (encoding & ENC_VARINT_QUIC) {
+ case ENC_VARINT_QUIC:
+ {
/* calculate variable length */
*value = tvb_get_guint8(tvb, offset);
switch((*value) >> 6) {
@@ -4535,7 +4543,11 @@ tvb_get_varint(tvbuff_t *tvb, guint offset, guint maxlen, guint64 *value, const
ws_assert_not_reached();
break;
}
+ break;
+ }
+ default:
+ DISSECTOR_ASSERT_NOT_REACHED();
}
return 0; /* 10 bytes scanned, but no bytes' msb is zero */