Avoid undefined behaviour.

Reviewed by:	zec@
This commit is contained in:
Edward Tomasz Napierala 2010-04-30 07:09:13 +00:00
parent a6e09ef1c2
commit 8016863c91
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=207426

View File

@ -816,14 +816,17 @@ pipe_dequeue(struct hookinfo *hinfo, struct timeval *now) {
}
/* Randomly discard the frame, according to BER setting */
if (hinfo->cfg.ber &&
((oldrand = rand) ^ (rand = random())<<17) >=
hinfo->ber_p[priv->overhead + m->m_pkthdr.len] ) {
hinfo->stats.out_disc_frames++;
hinfo->stats.out_disc_octets += m->m_pkthdr.len;
uma_zfree(ngp_zone, ngp_h);
m_freem(m);
continue;
if (hinfo->cfg.ber) {
oldrand = rand;
rand = random();
if (((oldrand ^ rand) << 17) >=
hinfo->ber_p[priv->overhead + m->m_pkthdr.len]) {
hinfo->stats.out_disc_frames++;
hinfo->stats.out_disc_octets += m->m_pkthdr.len;
uma_zfree(ngp_zone, ngp_h);
m_freem(m);
continue;
}
}
/* Discard frame if outbound queue size limit exceeded */