Date: Wed, 27 Apr 2005 11:39:54 -0500 (EST) From: Steve Ames <steve@virtual-voodoo.com> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/80411: bin/df/df.c sign errors in calls to getbsize Message-ID: <200504271639.j3RGdslv082937@basement.virtual-voodoo.com> Resent-Message-ID: <200504271640.j3RGeAUO024519@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 80411 >Category: bin >Synopsis: bin/df/df.c sign errors in calls to getbsize >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: Wed Apr 27 16:40:10 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Steve Ames >Release: FreeBSD 6.0-CURRENT i386 >Organization: >Environment: System: FreeBSD basement.virtual-voodoo.com 6.0-CURRENT FreeBSD 6.0-CURRENT #48: Sun Apr 24 13:04:02 EST 2005 steve@basement.virtual-voodoo.com:/usr/obj/usr/src/sys/SB i386 >Description: in bin/df/df.c calls are made getbsize(3) using a variable of type u_long when the prototype specifically requests long: char *getbsize(int *headerlenp, long *blocksizep); The solution is to fix the calls to send signed long instead of u_long. I'm fairly sure that a negative value will never be placed in blocksizep so u_long seems to be appropriate but until (and unless) the prototype and library are changed to unsigned then calls to getbsize should use signed variables to avoid confusion. This becomes more true with gcc4.0 and higher where sign warnings are flagged a little heavier. >How-To-Repeat: Not Applicable >Fix: --- df.c.old Wed Apr 27 11:28:11 2005 +++ df.c Wed Apr 27 11:29:32 2005 @@ -372,7 +372,7 @@ static void prtstat(struct statfs *sfsp, struct maxwidths *mwp) { - static u_long blocksize; + static long blocksize; static int headerlen, timesthrough = 0; static const char *header; int64_t used, availblks, inodes; @@ -449,7 +449,7 @@ static void update_maxwidths(struct maxwidths *mwp, const struct statfs *sfsp) { - static u_long blocksize = 0; + static long blocksize = 0; int dummy; if (blocksize == 0) >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200504271639.j3RGdslv082937>