Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Apr 2010 07:09:13 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r207426 - head/sys/netgraph
Message-ID:  <201004300709.o3U79DE4093151@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Fri Apr 30 07:09:13 2010
New Revision: 207426
URL: http://svn.freebsd.org/changeset/base/207426

Log:
  Avoid undefined behaviour.
  
  Reviewed by:	zec@

Modified:
  head/sys/netgraph/ng_pipe.c

Modified: head/sys/netgraph/ng_pipe.c
==============================================================================
--- head/sys/netgraph/ng_pipe.c	Fri Apr 30 06:43:35 2010	(r207425)
+++ head/sys/netgraph/ng_pipe.c	Fri Apr 30 07:09:13 2010	(r207426)
@@ -816,14 +816,17 @@ pipe_dequeue(struct hookinfo *hinfo, str
 		}
 
 		/* 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 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004300709.o3U79DE4093151>