Author: zec
Date: Tue Nov 23 13:26:59 2010
New Revision: 215744
URL: http://svn.freebsd.org/changeset/base/215744

Log:
  MFC 207426:
  
     Avoid undefined behaviour.

Modified:
  stable/8/sys/netgraph/ng_pipe.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/netgraph/ng_pipe.c
==============================================================================
--- stable/8/sys/netgraph/ng_pipe.c     Tue Nov 23 13:25:27 2010        
(r215743)
+++ stable/8/sys/netgraph/ng_pipe.c     Tue Nov 23 13:26:59 2010        
(r215744)
@@ -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 */
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to