Subject: kern/4692: fd.c w/FD_DEBUG doesn't compile
To: None <gnats-bugs@gnats.netbsd.org>
From: None <erh@uaccess.net>
List: netbsd-bugs
Date: 12/15/1997 15:02:39
>Number:         4692
>Category:       kern
>Synopsis:       Compiling a kernel with FD_DEBUG fails on the file fd.c
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 15 13:05:01 1997
>Last-Modified:
>Originator:     Eric Haszlakiewicz
>Organization:
>Release:        971215
>Environment:
	i386
System: NetBSD realms.isdn.uiuc.edu 1.3_BETA NetBSD 1.3_BETA (REALMS) #25: Mon Dec 8 12:47:53 CST 1997 root@realms.isdn.uiuc.edu:/usr/src/sys/arch/i386/compile/REALMS i386


>Description:
	A printf within an #ifdef FD_DEBUG uses the wrong format for
several of it's arguments, thus causing the compile to fail.  
>How-To-Repeat:
	add "options FD_DEBUG" to kernel config, build it.
>Fix:
	Here's a patch which fixes this problem.  This patch also gets rid
    of the "#define b_cylin b_resid" in fd.c which is already defined
    (although as b_cylinder) in sys/buf.h.


*** fd.c	Mon Dec 15 14:53:30 1997
--- fd.new	Mon Dec 15 14:50:12 1997
***************
*** 99,106 ****
  /* XXX misuse a flag to identify format operation */
  #define B_FORMAT B_XXX
  
- #define b_cylin b_resid
- 
  enum fdc_state {
  	DEVIDLE = 0,
  	MOTORWAIT,
--- 99,104 ----
***************
*** 602,612 ****
  		bp->b_bcount = sz << DEV_BSHIFT;
  	}
  
!  	bp->b_cylin = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE) / fd->sc_type->seccyl;
  
  #ifdef FD_DEBUG
! 	printf("fdstrategy: b_blkno %d b_bcount %d blkno %d cylin %d sz %d\n",
! 	    bp->b_blkno, bp->b_bcount, fd->sc_blkno, bp->b_cylin, sz);
  #endif
  
  	/* Queue transfer on drive, activate drive and controller if idle. */
--- 600,610 ----
  		bp->b_bcount = sz << DEV_BSHIFT;
  	}
  
!  	bp->b_cylinder = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE) / fd->sc_type->seccyl;
  
  #ifdef FD_DEBUG
! 	printf("fdstrategy: b_blkno 0x%x b_bcount %ld blkno 0x%x cylin %ld sz %d\n",
! 	    bp->b_blkno, bp->b_bcount, fd->sc_blkno, bp->b_cylinder, sz);
  #endif
  
  	/* Queue transfer on drive, activate drive and controller if idle. */
***************
*** 1010,1016 ****
  		/* fall through */
  	case DOSEEK:
  	doseek:
! 		if (fd->sc_cylin == bp->b_cylin)
  			goto doio;
  
  		out_fdc(iot, ioh, NE7CMD_SPECIFY);/* specify command */
--- 1008,1014 ----
  		/* fall through */
  	case DOSEEK:
  	doseek:
! 		if (fd->sc_cylin == bp->b_cylinder)
  			goto doio;
  
  		out_fdc(iot, ioh, NE7CMD_SPECIFY);/* specify command */
***************
*** 1019,1025 ****
  
  		out_fdc(iot, ioh, NE7CMD_SEEK);	/* seek function */
  		out_fdc(iot, ioh, fd->sc_drive);	/* drive number */
! 		out_fdc(iot, ioh, bp->b_cylin * fd->sc_type->step);
  
  		fd->sc_cylin = -1;
  		fdc->sc_state = SEEKWAIT;
--- 1017,1023 ----
  
  		out_fdc(iot, ioh, NE7CMD_SEEK);	/* seek function */
  		out_fdc(iot, ioh, fd->sc_drive);	/* drive number */
! 		out_fdc(iot, ioh, bp->b_cylinder * fd->sc_type->step);
  
  		fd->sc_cylin = -1;
  		fdc->sc_state = SEEKWAIT;
***************
*** 1112,1125 ****
  		/* Make sure seek really happened. */
  		out_fdc(iot, ioh, NE7CMD_SENSEI);
  		if (fdcresult(fdc) != 2 || (st0 & 0xf8) != 0x20 ||
! 		    cyl != bp->b_cylin * fd->sc_type->step) {
  #ifdef FD_DEBUG
  			fdcstatus(&fd->sc_dev, 2, "seek failed");
  #endif
  			fdcretry(fdc);
  			goto loop;
  		}
! 		fd->sc_cylin = bp->b_cylin;
  		goto doio;
  
  	case IOTIMEDOUT:
--- 1110,1123 ----
  		/* Make sure seek really happened. */
  		out_fdc(iot, ioh, NE7CMD_SENSEI);
  		if (fdcresult(fdc) != 2 || (st0 & 0xf8) != 0x20 ||
! 		    cyl != bp->b_cylinder * fd->sc_type->step) {
  #ifdef FD_DEBUG
  			fdcstatus(&fd->sc_dev, 2, "seek failed");
  #endif
  			fdcretry(fdc);
  			goto loop;
  		}
! 		fd->sc_cylin = bp->b_cylinder;
  		goto doio;
  
  	case IOTIMEDOUT:
***************
*** 1157,1163 ****
  		fd->sc_skip += fd->sc_nbytes;
  		fd->sc_bcount -= fd->sc_nbytes;
  		if (!finfo && fd->sc_bcount > 0) {
! 			bp->b_cylin = fd->sc_blkno / fd->sc_type->seccyl;
  			goto doseek;
  		}
  		fdfinish(fd, bp);
--- 1155,1161 ----
  		fd->sc_skip += fd->sc_nbytes;
  		fd->sc_bcount -= fd->sc_nbytes;
  		if (!finfo && fd->sc_bcount > 0) {
! 			bp->b_cylinder = fd->sc_blkno / fd->sc_type->seccyl;
  			goto doseek;
  		}
  		fdfinish(fd, bp);
>Audit-Trail:
>Unformatted: