diff --git a/usr.sbin/fdcontrol/Makefile b/usr.sbin/fdcontrol/Makefile index 4696abda1754..e2b54aa06708 100644 --- a/usr.sbin/fdcontrol/Makefile +++ b/usr.sbin/fdcontrol/Makefile @@ -4,7 +4,7 @@ PROG= fdcontrol SRCS= fdcontrol.c fdutil.c -WARNS?= 2 +WARNS?= 6 CFLAGS+= -I${.CURDIR}/../fdread MAN= fdcontrol.8 diff --git a/usr.sbin/fdcontrol/fdcontrol.c b/usr.sbin/fdcontrol/fdcontrol.c index ff0f90bf36e8..559ce020891e 100644 --- a/usr.sbin/fdcontrol/fdcontrol.c +++ b/usr.sbin/fdcontrol/fdcontrol.c @@ -157,7 +157,7 @@ mode = O_RDONLY | O_NONBLOCK; if (showfmt) { if (verbose) { - char *s; + const char *s; printf("%s: %d KB media type\n", argv[0], (128 << ft.secsize) * ft.size / 1024); diff --git a/usr.sbin/fdformat/Makefile b/usr.sbin/fdformat/Makefile index 40ca9a707bcf..a172811ec055 100644 --- a/usr.sbin/fdformat/Makefile +++ b/usr.sbin/fdformat/Makefile @@ -5,7 +5,7 @@ PROG= fdformat SRCS= fdformat.c fdutil.c -WARNS?= 2 +WARNS?= 6 CFLAGS+= -I${.CURDIR}/../fdread .if ${MACHINE} == "pc98" diff --git a/usr.sbin/fdread/Makefile b/usr.sbin/fdread/Makefile index e99c6205c4c3..2868a3c38f03 100644 --- a/usr.sbin/fdread/Makefile +++ b/usr.sbin/fdread/Makefile @@ -3,6 +3,8 @@ PROG= fdread SRCS= fdread.c fdutil.c +WARNS?= 6 + .if ${MACHINE} == "pc98" CFLAGS+= -DPC98 .endif diff --git a/usr.sbin/fdread/fdread.c b/usr.sbin/fdread/fdread.c index 85336c272cfd..8aee99bd0c70 100644 --- a/usr.sbin/fdread/fdread.c +++ b/usr.sbin/fdread/fdread.c @@ -47,7 +47,7 @@ int quiet, recover; unsigned char fillbyte = 0xf0; /* "foo" */ -int doread(int fd, FILE *of, const char *devname); +int doread(int fd, FILE *of, const char *_devname); int doreadid(int fd, unsigned int numids, unsigned int trackno); void usage(void); @@ -66,7 +66,7 @@ main(int argc, char **argv) { int c, errs = 0; unsigned int numids = 0, trackno = 0; - const char *fname = 0, *devname = "/dev/fd0"; + const char *fname = 0, *_devname = "/dev/fd0"; char *cp; FILE *of = stdout; int fd; @@ -75,7 +75,7 @@ main(int argc, char **argv) while ((c = getopt(argc, argv, "d:f:I:o:qrt:")) != -1) switch (c) { case 'd': - devname = optarg; + _devname = optarg; break; case 'f': @@ -149,14 +149,14 @@ main(int argc, char **argv) err(EX_OSERR, "cannot create output file %s", fname); } - if ((fd = open(devname, O_RDONLY)) == -1) - err(EX_OSERR, "cannot open device %s", devname); + if ((fd = open(_devname, O_RDONLY)) == -1) + err(EX_OSERR, "cannot open device %s", _devname); - return (numids? doreadid(fd, numids, trackno): doread(fd, of, devname)); + return (numids? doreadid(fd, numids, trackno): doread(fd, of, _devname)); } int -doread(int fd, FILE *of, const char *devname) +doread(int fd, FILE *of, const char *_devname) { char *trackbuf; int rv, fdopts, recoverable, nerrs = 0; @@ -178,7 +178,7 @@ doread(int fd, FILE *of, const char *devname) if (!quiet) fprintf(stderr, "Reading %d * %d * %d * %d medium at %s\n", - fdt.tracks, fdt.heads, fdt.sectrac, secsize, devname); + fdt.tracks, fdt.heads, fdt.sectrac, secsize, _devname); for (nbytes = 0; nbytes < mediasize;) { if (lseek(fd, nbytes, SEEK_SET) != nbytes) @@ -189,7 +189,7 @@ doread(int fd, FILE *of, const char *devname) warnx("premature EOF after %u bytes", nbytes); return (EX_OK); } - if (rv == tracksize) { + if ((unsigned)rv == tracksize) { nbytes += rv; if (!quiet) fprintf(stderr, "%5d KB\r", nbytes / 1024); @@ -197,23 +197,13 @@ doread(int fd, FILE *of, const char *devname) fflush(of); continue; } - if (rv < tracksize) { - /* should not happen */ - nbytes += rv; - if (!quiet) - fprintf(stderr, "\nshort after %5d KB\r", - nbytes / 1024); - fwrite(trackbuf, sizeof(unsigned char), rv, of); - fflush(of); - continue; - } if (rv == -1) { /* fall back reading one sector at a time */ for (n = 0; n < tracksize; n += secsize) { if (lseek(fd, nbytes, SEEK_SET) != nbytes) err(EX_OSERR, "cannot lseek()"); rv = read(fd, trackbuf, secsize); - if (rv == secsize) { + if ((unsigned) rv == secsize) { nbytes += rv; if (!quiet) fprintf(stderr, "%5d KB\r", @@ -257,7 +247,7 @@ doread(int fd, FILE *of, const char *devname) "ioctl(fd, FD_SOPTS, FDOPT_NOERROR)"); rv = read(fd, trackbuf, secsize); - if (rv != secsize) + if ((unsigned)rv != secsize) err(EX_IOERR, "read() with FDOPT_NOERROR still fails"); fdopts &= ~FDOPT_NOERROR; @@ -286,6 +276,16 @@ doread(int fd, FILE *of, const char *devname) rv); } } + if ((unsigned)rv < tracksize) { + /* should not happen */ + nbytes += rv; + if (!quiet) + fprintf(stderr, "\nshort after %5d KB\r", + nbytes / 1024); + fwrite(trackbuf, sizeof(unsigned char), rv, of); + fflush(of); + continue; + } } if (!quiet) { putc('\n', stderr); diff --git a/usr.sbin/fdread/fdutil.c b/usr.sbin/fdread/fdutil.c index 1f6617fb9fcb..c1f4d8f18dfb 100644 --- a/usr.sbin/fdread/fdutil.c +++ b/usr.sbin/fdread/fdutil.c @@ -102,7 +102,7 @@ static struct fd_type fd_types_288m[] = { { FDF_3_820 }, { FDF_3_800 }, { FDF_3_720 }, - { 0 } + { 0,0,0,0,0,0,0,0,0,0,0,0 } }; static struct fd_type fd_types_144m[] = { @@ -126,7 +126,7 @@ static struct fd_type fd_types_144m[] = { { FDF_3_1480 }, { FDF_3_1640 }, #endif - { 0 } + { 0,0,0,0,0,0,0,0,0,0,0,0 } #else { FDF_3_1722 }, { FDF_3_1476 }, @@ -135,7 +135,7 @@ static struct fd_type fd_types_144m[] = { { FDF_3_820 }, { FDF_3_800 }, { FDF_3_720 }, - { 0 } + { 0,0,0,0,0,0,0,0,0,0,0,0 } #endif }; @@ -153,7 +153,7 @@ static struct fd_type fd_types_12m[] = { #if 0 { FDF_5_1280 }, #endif - { 0 } + { 0,0,0,0,0,0,0,0,0,0,0,0 } #else { FDF_5_1200 }, { FDF_5_1230 }, @@ -164,20 +164,20 @@ static struct fd_type fd_types_12m[] = { { FDF_5_720 }, { FDF_5_360 | FL_2STEP }, { FDF_5_640 }, - { 0 } + { 0,0,0,0,0,0,0,0,0,0,0,0 } #endif }; static struct fd_type fd_types_720k[] = { { FDF_3_720 }, - { 0 } + { 0,0,0,0,0,0,0,0,0,0,0,0 } }; static struct fd_type fd_types_360k[] = { { FDF_5_360 }, - { 0 } + { 0,0,0,0,0,0,0,0,0,0,0,0 } }; diff --git a/usr.sbin/fdwrite/Makefile b/usr.sbin/fdwrite/Makefile index b97bdd444821..ba6f047ff161 100644 --- a/usr.sbin/fdwrite/Makefile +++ b/usr.sbin/fdwrite/Makefile @@ -8,5 +8,6 @@ # $FreeBSD$ PROG= fdwrite +WARNS?= 6 .include diff --git a/usr.sbin/fdwrite/fdwrite.c b/usr.sbin/fdwrite/fdwrite.c index b3ffb6ea6a66..3c220916e84e 100644 --- a/usr.sbin/fdwrite/fdwrite.c +++ b/usr.sbin/fdwrite/fdwrite.c @@ -21,9 +21,9 @@ #include -int +static int format_track(int fd, int cyl, int secs, int head, int rate, - int gaplen, int secsize, int fill,int interleave) + int gaplen, int secsize, int fill, int interleave) { struct fd_formb f; register int i,j; @@ -55,7 +55,7 @@ format_track(int fd, int cyl, int secs, int head, int rate, } static void -usage() +usage(void) { fprintf(stderr, "usage: fdwrite [-v] [-y] [-f inputfile] [-d device]\n"); exit(2); @@ -67,7 +67,8 @@ main(int argc, char **argv) int inputfd = -1, c, fdn = 0, i,j,fd; int bpt, verbose=1, nbytes=0, track; int interactive = 1, fdopts; - char *device= "/dev/fd0", *trackbuf = 0,*vrfybuf = 0; + const char *device= "/dev/fd0"; + char *trackbuf = 0,*vrfybuf = 0; struct fd_type fdt; FILE *tty;