From owner-svn-src-all@FreeBSD.ORG Fri Apr 30 07:09:13 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 86949106566B; Fri, 30 Apr 2010 07:09:13 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 75B408FC14; Fri, 30 Apr 2010 07:09:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3U79DXS093153; Fri, 30 Apr 2010 07:09:13 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3U79DE4093151; Fri, 30 Apr 2010 07:09:13 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201004300709.o3U79DE4093151@svn.freebsd.org> From: Edward Tomasz Napierala Date: Fri, 30 Apr 2010 07:09:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r207426 - head/sys/netgraph X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Apr 2010 07:09:13 -0000 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 */