From fpm@n2.net  Mon Aug  4 02:43:04 1997
Received: from jsbach.n2.net (jsbach.n2.net [207.113.132.22])
          by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id CAA24291
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 4 Aug 1997 02:43:03 -0700 (PDT)
Received: (from fpm@localhost) by jsbach.n2.net (8.8.5/8.6.12) id CAA17905; Mon, 4 Aug 1997 02:42:05 -0700 (PDT)
Message-Id: <199708040942.CAA17905@jsbach.n2.net>
Date: Mon, 4 Aug 1997 02:42:05 -0700 (PDT)
From: fpm@n2.net
Reply-To: fpm@n2.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: Missing parentheses in /usr/src/sys/i386/isa/isa.c
X-Send-Pr-Version: 3.2

>Number:         4225
>Category:       i386
>Synopsis:       Missing parentheses in /usr/src/sys/i386/isa/isa.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    steve
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug  4 02:50:01 PDT 1997
>Closed-Date:    Tue Aug 12 19:40:25 PDT 1997
>Last-Modified:  Tue Aug 12 19:46:09 PDT 1997
>Originator:     Frank MacLachlan
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
N2 Networking
>Environment:

	
	3.0-CURRENT CVsup'ed 3 Aug 97 at 23:30 PDT.
	Relevent file is /usr/src/sys/i386/isa/isa.c.
	File's id is:

	$Id: isa.c,v 1.99 1997/07/29 05:24:36 msmith Exp $

>Description:

	
	A number of if statements in this file assume that the
	precedence of the '&' operator is higher than the '=='
	operator and are incorrectly evaluated.  The resulting
	tests are totally useless.

>How-To-Repeat:

	
	Problem was found while inspecting the code.

>Fix:
	
	
	Apply the following patch:

*** isa.c.ORIG	Sun Aug  3 23:37:00 1997
--- isa.c	Mon Aug  4 00:58:06 1997
***************
*** 648,654 ****
  	if (chan & ~VALID_DMA_MASK)
  		panic("isa_dma_release: channel out of range");
  
! 	if (dma_inuse & (1 << chan) == 0)
  		printf("isa_dma_release: channel %d not in use\n", chan);
  #endif
  
--- 648,654 ----
  	if (chan & ~VALID_DMA_MASK)
  		panic("isa_dma_release: channel out of range");
  
! 	if ((dma_inuse & (1 << chan)) == 0)
  		printf("isa_dma_release: channel %d not in use\n", chan);
  #endif
  
***************
*** 705,711 ****
  	    || (chan >= 4 && (nbytes > (1<<17) || (u_int)addr & 1)))
  		panic("isa_dmastart: impossible request");
  
! 	if (dma_inuse & (1 << chan) == 0)
  		printf("isa_dmastart: channel %d not acquired\n", chan);
  #endif
  
--- 705,711 ----
  	    || (chan >= 4 && (nbytes > (1<<17) || (u_int)addr & 1)))
  		panic("isa_dmastart: impossible request");
  
! 	if ((dma_inuse & (1 << chan)) == 0)
  		printf("isa_dmastart: channel %d not acquired\n", chan);
  #endif
  
***************
*** 813,819 ****
  	if (chan & ~VALID_DMA_MASK)
  		panic("isa_dmadone: channel out of range");
  
! 	if (dma_inuse & (1 << chan) == 0)
  		printf("isa_dmadone: channel %d not acquired\n", chan);
  #endif
  
--- 813,819 ----
  	if (chan & ~VALID_DMA_MASK)
  		panic("isa_dmadone: channel out of range");
  
! 	if ((dma_inuse & (1 << chan)) == 0)
  		printf("isa_dmadone: channel %d not acquired\n", chan);
  #endif
  
***************
*** 823,829 ****
  	 * isa_dmastart() once because they use Auto DMA mode.  If we
  	 * leave this in, drivers that do this will print this continuously.
  	 */
! 	if (dma_busy & (1 << chan) == 0)
  		printf("isa_dmadone: channel %d not busy\n", chan);
  #endif
  
--- 823,829 ----
  	 * isa_dmastart() once because they use Auto DMA mode.  If we
  	 * leave this in, drivers that do this will print this continuously.
  	 */
! 	if ((dma_busy & (1 << chan)) == 0)
  		printf("isa_dmadone: channel %d not busy\n", chan);
  #endif
  
***************
*** 910,922 ****
  	u_long	ef;
  
  	/* channel active? */
! 	if (dma_inuse & (1 << chan) == 0) {
  		printf("isa_dmastatus: channel %d not active\n", chan);
  		return(-1);
  	}
  
  	/* still busy? */
! 	if (dma_busy & (1 << chan) == 0) {
  		return(0);
  	}
  	
--- 910,922 ----
  	u_long	ef;
  
  	/* channel active? */
! 	if ((dma_inuse & (1 << chan)) == 0) {
  		printf("isa_dmastatus: channel %d not active\n", chan);
  		return(-1);
  	}
  
  	/* still busy? */
! 	if ((dma_busy & (1 << chan)) == 0) {
  		return(0);
  	}
  	
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: steve 
State-Changed-When: Tue Aug 12 19:40:25 PDT 1997 
State-Changed-Why:  
Slightly modified patch applied to revision of 1.100 of isa.c. 
>Unformatted:
