summaryrefslogtreecommitdiff
path: root/epan/dissectors/packet-asterix.c
diff options
context:
space:
mode:
authorMarko Hrastovec <marko.hrastovec@gmail.com>2014-05-08 15:23:48 +0200
committerEvan Huus <eapache@gmail.com>2014-05-11 03:17:29 +0000
commit43bb76a720656a9d06a5b6ee7ad68f7692d91d2b (patch)
tree4f3253e23655f12665cc211605ac6d79c7480bbe /epan/dissectors/packet-asterix.c
parentdac0a0c9a3c2add2f2709c47f121f6e19025d267 (diff)
downloadwireshark-43bb76a720656a9d06a5b6ee7ad68f7692d91d2b.tar.gz
Function to calculate twos complement is quicker and hopefully better understandable.
Change-Id: I1948eeaf5fa5aa4a5ccd0f81be894f655907a4dc Reviewed-on: https://code.wireshark.org/review/1570 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-asterix.c')
-rw-r--r--epan/dissectors/packet-asterix.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/epan/dissectors/packet-asterix.c b/epan/dissectors/packet-asterix.c
index ca6722c9ce..759e0f0b76 100644
--- a/epan/dissectors/packet-asterix.c
+++ b/epan/dissectors/packet-asterix.c
@@ -7170,17 +7170,14 @@ static guint8 asterix_bit (guint8 b, guint8 bitNo)
/* Function makes gint64 two's complement.
* Only the bit_len bit are set in gint64. All more significant
- * bits need to be set to to have proper two's complement.
+ * bits need to be set to have proper two's complement.
* If the number is negative, all other bits must be set to 1.
* If the number is positive, all other bits must remain 0. */
static void twos_complement (gint64 *v, guint8 bit_len)
{
- guint64 i, to_stuff;
- i = (G_GUINT64_CONSTANT(1) << (bit_len - 1));
- to_stuff = *v & i;
- i = 0;
- if (to_stuff) i = G_GINT64_CONSTANT(0xffffffffffffffff) << bit_len;
- *v = *v | i;
+ if (*v & (G_GUINT64_CONSTANT(1) << (bit_len - 1))) {
+ *v |= (G_GUINT64_CONSTANT(0xffffffffffffffff) << bit_len);
+ }
}
static guint8 asterix_fspec_len (tvbuff_t *tvb, guint offset)