aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-02-19 21:27:03 -0800
committerGuy Harris <guy@alum.mit.edu>2018-02-20 05:27:38 +0000
commitdc6b9dfcd635a1ca97a218bcdaf16a2ee5f7b693 (patch)
tree49ce29aca0c5cce7f14b06b7bd89d7a1a35614b4 /epan
parente4787a9190c82dadae7e57c0847e2529bb2a9bbf (diff)
Define macros to calculate (2^N)^M, and use them in more places.
Change-Id: I4df1b35d8d2233c301f0ba9e119d012aebe9cd17 Reviewed-on: https://code.wireshark.org/review/25913 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-icmpv6.c4
-rw-r--r--epan/dissectors/packet-iso14443.c9
-rw-r--r--epan/dissectors/packet-nas_eps.c18
-rw-r--r--epan/dissectors/packet-sigcomp.c6
4 files changed, 20 insertions, 17 deletions
diff --git a/epan/dissectors/packet-icmpv6.c b/epan/dissectors/packet-icmpv6.c
index b4d570e13f..56633a6ee3 100644
--- a/epan/dissectors/packet-icmpv6.c
+++ b/epan/dissectors/packet-icmpv6.c
@@ -34,6 +34,8 @@
#include <epan/proto_data.h>
#include <epan/strutil.h>
+#include <wsutil/pow2.h>
+
#include "packet-ber.h"
#include "packet-dns.h"
#include "packet-x509af.h"
@@ -2995,7 +2997,7 @@ dissect_icmpv6_rpl_opt(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree
}
}
- proto_item_append_text(ti_opt_lifetime, " (%u sec)", 1U << ((lt_mr_nh & RPL_OPT_ROUTE_DISCOVERY_L) >> 6)*2);
+ proto_item_append_text(ti_opt_lifetime, " (%u sec)", pow4(guint32, (lt_mr_nh & RPL_OPT_ROUTE_DISCOVERY_L) >> 6));
if (!(lt_mr_nh & RPL_OPT_ROUTE_DISCOVERY_MR_NH)) {
proto_item_append_text(ti_opt_mr_nh, " (Infinity)");
diff --git a/epan/dissectors/packet-iso14443.c b/epan/dissectors/packet-iso14443.c
index 76050832c9..4e2b3e5536 100644
--- a/epan/dissectors/packet-iso14443.c
+++ b/epan/dissectors/packet-iso14443.c
@@ -25,15 +25,16 @@
#include "config.h"
-#include <math.h>
#include <epan/packet.h>
#include <epan/expert.h>
#include <epan/conversation.h>
#include <epan/tfs.h>
#include <epan/reassemble.h>
-#include <wiretap/wtap.h>
#include <epan/crc16-tvb.h>
+#include <wiretap/wtap.h>
+
+#include <wsutil/pow2.h>
/* Proximity Integrated Circuit Card, i.e. the smartcard */
#define ADDR_PICC "PICC"
@@ -541,8 +542,8 @@ dissect_iso14443_cmd_type_wupb(tvbuff_t *tvb, packet_info *pinfo,
col_set_str(pinfo->cinfo, COL_INFO, msg_type);
proto_item_append_text(ti, ": %s", msg_type);
proto_tree_add_uint_bits_format_value(tree, hf_iso14443_n,
- tvb, offset*8+5, 3, (guint8)pow(2, param&0x07),
- "%d", (guint8)pow(2, param&0x07));
+ tvb, offset*8+5, 3, pow2(guint32, param&0x07),
+ "%u", pow2(guint32, param&0x07));
offset++;
if (!crc_dropped) {
diff --git a/epan/dissectors/packet-nas_eps.c b/epan/dissectors/packet-nas_eps.c
index 980779a421..63018053d4 100644
--- a/epan/dissectors/packet-nas_eps.c
+++ b/epan/dissectors/packet-nas_eps.c
@@ -14,13 +14,13 @@
#include "config.h"
-#include <math.h>
#include <epan/packet.h>
#include <epan/asn1.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <epan/exceptions.h>
#include <epan/show_exception.h>
+#include <wsutil/pow2.h>
#include "packet-gsm_map.h"
#include "packet-gsm_a_common.h"
#include "packet-e212.h"
@@ -3538,16 +3538,16 @@ get_ext_ambr_unit(guint32 byte, const char **unit_str)
mult = 0;
*unit_str = "";
} else if (byte <= 0x06) {
- mult = (guint32)pow(4, byte-0x02);
+ mult = pow4(guint32, byte-0x02);
*unit_str = "Mbps";
} else if (byte <= 0x0b) {
- mult = (guint32)pow(4, byte-0x07);
+ mult = pow4(guint32, byte-0x07);
*unit_str = "Gbps";
} else if (byte <= 0x10) {
- mult = (guint32)pow(4, byte-0x0c);
+ mult = pow4(guint32, byte-0x0c);
*unit_str = "Tbps";
} else if (byte <= 0x15) {
- mult = (guint32)pow(4, byte-0x11);
+ mult = pow4(guint32, byte-0x11);
*unit_str = "Pbps";
} else {
mult = 256;
@@ -3622,16 +3622,16 @@ get_ext_eps_qos_unit(guint32 byte, const char **unit_str)
mult = 200;
*unit_str = "kbps";
} else if (byte <= 0x06) {
- mult = (guint32)pow(4, byte-0x02);
+ mult = pow4(guint32, byte-0x02);
*unit_str = "Mbps";
} else if (byte <= 0x0b) {
- mult = (guint32)pow(4, byte-0x07);
+ mult = pow4(guint32, byte-0x07);
*unit_str = "Gbps";
} else if (byte <= 0x10) {
- mult = (guint32)pow(4, byte-0x0c);
+ mult = pow4(guint32, byte-0x0c);
*unit_str = "Tbps";
} else if (byte <= 0x15) {
- mult = (guint32)pow(4, byte-0x11);
+ mult = pow4(guint32, byte-0x11);
*unit_str = "Pbps";
} else {
mult = 256;
diff --git a/epan/dissectors/packet-sigcomp.c b/epan/dissectors/packet-sigcomp.c
index 5c9f1adf18..cbd3eaf626 100644
--- a/epan/dissectors/packet-sigcomp.c
+++ b/epan/dissectors/packet-sigcomp.c
@@ -18,7 +18,6 @@
#include "config.h"
-#include <math.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
@@ -28,6 +27,7 @@
#include <wsutil/wsgcrypt.h>
#include <wsutil/crc16.h>
+#include <wsutil/pow2.h>
void proto_register_sigcomp(void);
void proto_reg_handoff_sigcomp(void);
@@ -6340,7 +6340,7 @@ dissect_udvm_multitype_operand(tvbuff_t *udvm_tvb, proto_tree *sigcomp_udvm_tree
if ( display_udvm_bytecode )
proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_multitype_bytecode,
udvm_tvb, offset, 1, display_bytecode);
- result = (guint32)pow(2,( bytecode & 0x07) + 8);
+ result = pow2(guint32, (bytecode & 0x07) + 8);
operand = result & 0xffff;
*start_offset = offset;
*value = operand;
@@ -6355,7 +6355,7 @@ dissect_udvm_multitype_operand(tvbuff_t *udvm_tvb, proto_tree *sigcomp_udvm_tree
if ( display_udvm_bytecode )
proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_multitype_bytecode,
udvm_tvb, offset, 1, display_bytecode);
- result = (guint32)pow(2,( bytecode & 0x01) + 6);
+ result = pow2(guint32, (bytecode & 0x01) + 6);
operand = result & 0xffff;
*start_offset = offset;
*value = operand;