From f717c07c8ab962df0e0a56b28e7f917c1b89dd1a Mon Sep 17 00:00:00 2001 From: charnier Date: Sun, 26 Mar 2000 14:21:57 +0000 Subject: Use warnx(), -Wall cleaning and remove unused #include Better use of .Nm and .Ar --- usr.bin/du/du.1 | 10 +++++----- usr.bin/du/du.c | 17 ++++++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'usr.bin/du') diff --git a/usr.bin/du/du.1 b/usr.bin/du/du.1 index fedd012..1eb3fd0 100644 --- a/usr.bin/du/du.1 +++ b/usr.bin/du/du.1 @@ -45,10 +45,10 @@ .Op Fl c .Op Fl h | k .Op Fl x -.Op Ar file ... +.Op Ar .Sh DESCRIPTION The -.Nm du +.Nm utility displays the file system block usage for each file argument and for each directory in the file hierarchy rooted in each directory argument. @@ -63,7 +63,7 @@ is used to determine the preferred block size. Partial numbers of blocks are rounded up. .Pp The options are as follows: -.Bl -tag -width Ds +.Bl -tag -width indent .It Fl P No symbolic links are followed. (default) @@ -115,7 +115,7 @@ followed is not counted or displayed. .Pp Files having multiple hard links are counted (and displayed) a single time per -.Nm du +.Nm execution. .Sh ENVIRONMENT .Bl -tag -width BLOCKSIZE @@ -138,6 +138,6 @@ option is not specified, the block counts will be displayed in 512-byte blocks. .Xr quot 8 .Sh HISTORY A -.Nm du +.Nm command appeared in .At v1 . diff --git a/usr.bin/du/du.c b/usr.bin/du/du.c index 9500a1b..f2f7ad4 100644 --- a/usr.bin/du/du.c +++ b/usr.bin/du/du.c @@ -44,14 +44,14 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)du.c 8.5 (Berkeley) 5/4/95"; #endif -static const char rcsid[] = "$FreeBSD$"; +static const char rcsid[] = + "$FreeBSD$"; #endif /* not lint */ #include #include -#include #include #include #include @@ -139,7 +139,7 @@ main(argc, argv) errno = 0; depth = atoi(optarg); if (errno == ERANGE || depth < 0) { - (void) fprintf(stderr, "Invalid argument to option d: %s\n", optarg); + warnx("invalid argument to option d: %s", optarg); usage(); } break; @@ -229,7 +229,7 @@ main(argc, argv) p->fts_parent->fts_number += p->fts_number += p->fts_statp->st_blocks; - if (p->fts_level <= depth) + if (p->fts_level <= depth) { if (hflag) { (void) prthumanval(howmany(p->fts_number, blocksize)); (void) printf("\t%s\n", p->fts_path); @@ -238,6 +238,7 @@ main(argc, argv) howmany(p->fts_number, blocksize), p->fts_path); } + } break; case FTS_DC: /* Ignore. */ break; @@ -251,7 +252,7 @@ main(argc, argv) if (p->fts_statp->st_nlink > 1 && linkchk(p)) break; - if (listall || p->fts_level == 0) + if (listall || p->fts_level == 0) { if (hflag) { (void) prthumanval(howmany(p->fts_statp->st_blocks, blocksize)); @@ -261,6 +262,7 @@ main(argc, argv) howmany(p->fts_statp->st_blocks, blocksize), p->fts_path); } + } p->fts_parent->fts_number += p->fts_statp->st_blocks; } @@ -270,13 +272,14 @@ main(argc, argv) if (errno) err(1, "fts_read"); - if (cflag) + if (cflag) { if (hflag) { (void) prthumanval(howmany(savednumber, blocksize)); (void) printf("\ttotal\n"); } else { (void) printf("%ld\ttotal\n", howmany(savednumber, blocksize)); } + } exit(rval); } @@ -307,7 +310,7 @@ linkchk(p) if (nfiles == maxfiles && (files = realloc((char *)files, (u_int)(sizeof(ID) * (maxfiles += 128)))) == NULL) - err(1, "can't allocate memory"); + errx(1, "can't allocate memory"); files[nfiles].inode = ino; files[nfiles].dev = dev; ++nfiles; -- cgit v1.1