Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Jan 2003 15:12:52 +0100 (CET)
From:      Stefan Farfeleder <stefan@fafoe.dyndns.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        stefan@fafoe.dyndns.org
Subject:   misc/47187: [patch] fix printf specifier in src/sys/boot/common/bcache.c
Message-ID:  <20030118141252.4575E7CE@frog.fafoe>

next in thread | raw e-mail | index | archive | help

>Number:         47187
>Category:       misc
>Synopsis:       [patch] fix printf specifier in src/sys/boot/common/bcache.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 18 06:20:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Stefan Farfeleder
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD frog.fafoe 5.0-CURRENT FreeBSD 5.0-CURRENT #11: Fri Jan 17 23:42:54 CET 2003 freebsd@frog.fafoe:/freebsd/current/obj/freebsd/current/src/sys/FROG i386


	
>Description:
The bc_blkno member of struct bcachectl which has type daddr_t
(a typedef for __int64_t from <sys/types.h>) is printed with %08x which
expects a value with type unsigned int to be passed.  The patch casts
the expression to uintmax_t and the specifier is changed to %08jx.

>How-To-Repeat:
A make buildworld gives this warning:

cc -O -pipe -mcpu=pentiumpro -ffreestanding -DLOADER_NFS_SUPPORT -DBOOT_FORTH -I/freebsd/current/src/sys/boot/i386/loader/../../ficl -I/freebsd/current/src/sys/boot/i386/loader/../../ficl/i386 -DLOADER_GZIP_SUPPORT -I/freebsd/current/src/sys/boot/i386/loader/../../common -I/freebsd/current/src/sys/boot/i386/loader/../../.. -I. -Wall -I/freebsd/current/src/sys/boot/i386/loader/.. -I/freebsd/current/src/sys/boot/i386/loader/../../../../lib/libstand/ -I/freebsd/current/src/sys/boot/i386/loader/../btx/lib -elf -ffreestanding -mpreferred-stack-boundary=2 -ffreestanding -mpreferred-stack-boundary=2    -c /freebsd/current/src/sys/boot/common/bcache.c
/freebsd/current/src/sys/boot/common/bcache.c: In function `command_bcache':
/freebsd/current/src/sys/boot/common/bcache.c:339: warning: unsigned int format, different type arg (arg 2)

>Fix:

--- bcache.c.diff begins here ---
Index: src/sys/boot/common/bcache.c
===================================================================
RCS file: /usr/home/ncvs/src/sys/boot/common/bcache.c,v
retrieving revision 1.11
diff -c -r1.11 bcache.c
*** src/sys/boot/common/bcache.c	25 Feb 2002 03:45:09 -0000	1.11
--- src/sys/boot/common/bcache.c	18 Jan 2003 14:03:59 -0000
***************
*** 30,35 ****
--- 30,36 ----
   * Simple LRU block cache
   */
  
+ #include <sys/stdint.h>
  #include <stand.h>
  #include <string.h>
  #include <bitstring.h>
***************
*** 336,342 ****
      u_int	i;
      
      for (i = 0; i < bcache_nblks; i++) {
! 	printf("%08x %04x %04x|", bcache_ctl[i].bc_blkno, (unsigned int)bcache_ctl[i].bc_stamp & 0xffff, bcache_ctl[i].bc_count & 0xffff);
  	if (((i + 1) % 4) == 0)
  	    printf("\n");
      }
--- 337,343 ----
      u_int	i;
      
      for (i = 0; i < bcache_nblks; i++) {
! 	printf("%08jx %04x %04x|", (uintmax_t)bcache_ctl[i].bc_blkno, (unsigned int)bcache_ctl[i].bc_stamp & 0xffff, bcache_ctl[i].bc_count & 0xffff);
  	if (((i + 1) % 4) == 0)
  	    printf("\n");
      }
--- bcache.c.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




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