diff options
author | dimeg <dimeg@f5534014-38df-0310-8fa8-9805f1628bb7> | 2010-01-24 12:08:14 +0000 |
---|---|---|
committer | dimeg <dimeg@f5534014-38df-0310-8fa8-9805f1628bb7> | 2010-01-24 12:08:14 +0000 |
commit | fff5f8fca14d297a187dcf59927fbbe29f4c6801 (patch) | |
tree | 88209b616c84a9a65bb8bb66c3ee47856c29fa95 /epan/proto.c | |
parent | 7d47bd7c7d18701452b029717ce65e92bf6dcf1d (diff) |
Minor simplification in length calculation of proto_tree_add_bits
and _format_value
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@31640 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/proto.c')
-rw-r--r-- | epan/proto.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/epan/proto.c b/epan/proto.c index 78173779af..96cbdbcb19 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -6437,7 +6437,6 @@ proto_tree_add_bits_ret_val(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint gint offset; guint length; guint8 tot_no_bits; - guint8 remaining_bits; char *str; header_field_info *hf_field; guint64 value = 0; @@ -6462,8 +6461,8 @@ proto_tree_add_bits_ret_val(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint */ tot_no_bits = ((bit_offset&0x7)+no_of_bits); length = tot_no_bits>>3; - remaining_bits = tot_no_bits % 8; - if ((remaining_bits)!=0) + /* If we are using part of the next octet, increase length by 1 */ + if (tot_no_bits & 0x07) length++; if (no_of_bits < 9){ @@ -6553,7 +6552,6 @@ proto_tree_add_bits_format_value(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint offset; guint length; guint8 tot_no_bits; - guint8 remaining_bits; char *str; header_field_info *hf_field; guint64 value = 0; @@ -6577,8 +6575,8 @@ proto_tree_add_bits_format_value(proto_tree *tree, int hf_index, tvbuff_t *tvb, */ tot_no_bits = ((bit_offset&0x7)+no_of_bits); length = tot_no_bits>>3; - remaining_bits = tot_no_bits % 8; - if ((remaining_bits)!=0) + /* If we are using part of the next octet, increase length by 1 */ + if (tot_no_bits & 0x07) length++; if (no_of_bits < 9){ |