summaryrefslogtreecommitdiff
path: root/plugins/wimaxasncp
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-04-30 15:21:00 -0700
committerGuy Harris <guy@alum.mit.edu>2015-04-30 22:22:59 +0000
commit9fba5f0764678cfed4b7ff2a41fdcb0babcdbf55 (patch)
tree0515e84e39049ba809ab2c1e8c1be4e6964a464a /plugins/wimaxasncp
parentd2b02eaf591145f40eaa65d6b50908e47d7c4484 (diff)
downloadwireshark-9fba5f0764678cfed4b7ff2a41fdcb0babcdbf55.tar.gz
Fix some cases where we're shifting a signed 1 left.
Shift 1U instead, to make sure it's unsigned; the result of, for example, the result of shifting a signed value left is undefined if the value times 2^{shift count} doesn't fit in the *signed* type of the shifted value. That means, in particular, that the result of shifting 1 left by {number of bits in an int - 1} is undefined. (In *practice*, it'll probably be -2^32, with the bit you want set, but that's not guaranteed, and GCC 5.1 seems not to like it.) Change-Id: I0d27565c382a04ceda9eec65f45a430ceb74cf53 Reviewed-on: https://code.wireshark.org/review/8255 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'plugins/wimaxasncp')
-rw-r--r--plugins/wimaxasncp/packet-wimaxasncp.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/plugins/wimaxasncp/packet-wimaxasncp.c b/plugins/wimaxasncp/packet-wimaxasncp.c
index 5bb42a0113..0d9e4db7ba 100644
--- a/plugins/wimaxasncp/packet-wimaxasncp.c
+++ b/plugins/wimaxasncp/packet-wimaxasncp.c
@@ -115,9 +115,9 @@ static expert_field ei_wimaxasncp_length_bad = EI_INIT;
/* Offset to end of the length field in the headder. */
#define WIMAXASNCP_HEADER_LENGTH_END 6
-#define WIMAXASNCP_BIT32(n) (1 << (31 - (n)))
-#define WIMAXASNCP_BIT16(n) (1 << (15 - (n)))
-#define WIMAXASNCP_BIT8(n) (1 << ( 7 - (n)))
+#define WIMAXASNCP_BIT32(n) (1U << (31 - (n)))
+#define WIMAXASNCP_BIT16(n) (1U << (15 - (n)))
+#define WIMAXASNCP_BIT8(n) (1U << ( 7 - (n)))
#define WIMAXASNCP_FLAGS_T WIMAXASNCP_BIT8(6)
#define WIMAXASNCP_FLAGS_R WIMAXASNCP_BIT8(7)
@@ -881,7 +881,7 @@ static void wimaxasncp_dissect_tlv_value(
for (i = 0; i < 8; ++i)
{
guint8 mask;
- mask = 1 << (7 - i);
+ mask = 1U << (7 - i);
if (value & mask)
{
@@ -936,7 +936,7 @@ static void wimaxasncp_dissect_tlv_value(
for (i = 0; i < 16; ++i)
{
guint16 mask;
- mask = 1 << (15 - i);
+ mask = 1U << (15 - i);
if (value & mask)
{
@@ -991,7 +991,7 @@ static void wimaxasncp_dissect_tlv_value(
for (i = 0; i < 32; ++i)
{
guint32 mask;
- mask = 1 << (31 - i);
+ mask = 1U << (31 - i);
if (value & mask)
{
@@ -2235,7 +2235,7 @@ dissect_wimaxasncp(
for (j = 0; j < 8; ++j)
{
guint8 mask;
- mask = 1 << (7 - j);
+ mask = 1U << (7 - j);
/* Only add flags that are set */
if (ui8 & mask)