aboutsummaryrefslogtreecommitdiffstats
path: root/mkcap.c
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 /mkcap.c
parentd2b02eaf591145f40eaa65d6b50908e47d7c4484 (diff)
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 'mkcap.c')
-rw-r--r--mkcap.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mkcap.c b/mkcap.c
index a7cefdf92e..0f0a7a58ee 100644
--- a/mkcap.c
+++ b/mkcap.c
@@ -153,7 +153,7 @@ int next_ack_due()
int ack_lost = 0, seg_lost = 0;
if (next_slot == first_slot)
- return (((unsigned int)(1<<31)) - 1);
+ return ((1U<<31) - 1);
/*
* Figure out if we need to issue an ACK. We skip all outstanding packets
@@ -178,7 +178,7 @@ int next_ack_due()
}
if (slot == next_slot)
- return (((unsigned int)(1<<31)) - 1);
+ return ((1U<<31) - 1);
/*
* If there is only one slot occupied, or a segment was lost then
@@ -206,7 +206,7 @@ int next_ack_due()
if (((first_slot + 1 + 2 * ack_lost) % SEG_HIST_SIZE) >= next_slot)
/* XXX: FIXME, what about when the window is closed */
/* XXX: FIXME, use the correct value for this */
- return (((unsigned int)(1<<31)) - 1);
+ return ((1U<<31) - 1);
else
return seg_hist[(first_slot + 1 + 2 * ack_lost) % SEG_HIST_SIZE].ts +
ack_delay + jitter;