From b1c566e1ce4d8cc7ebf01274e6cbc4f7816a5c33 Mon Sep 17 00:00:00 2001 From: gavin Date: Mon, 28 Jun 2010 12:00:20 +0000 Subject: [PATCH] Make WARNS=6 safe, mainly by casting to intmax_t and printing with %ju where needed. Also, fix bad indentation on lines already affected by the above changes. Tested with: make universe --- usr.bin/tcopy/Makefile | 2 -- usr.bin/tcopy/tcopy.c | 31 +++++++++++++++++-------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/usr.bin/tcopy/Makefile b/usr.bin/tcopy/Makefile index feb57695c1ea..1bae0b229420 100644 --- a/usr.bin/tcopy/Makefile +++ b/usr.bin/tcopy/Makefile @@ -3,6 +3,4 @@ PROG= tcopy -WARNS?= 1 - .include diff --git a/usr.bin/tcopy/tcopy.c b/usr.bin/tcopy/tcopy.c index 4d9d516b08e9..07eb41268aba 100644 --- a/usr.bin/tcopy/tcopy.c +++ b/usr.bin/tcopy/tcopy.c @@ -87,6 +87,7 @@ main(int argc, char *argv[]) msg = stdout; guesslen = 1; + outp = -1; while ((ch = getopt(argc, argv, "cs:vx")) != -1) switch((char)ch) { case 'c': @@ -157,16 +158,16 @@ main(int argc, char *argv[]) if (nread >= 0) goto r1; } - err(1, "read error, file %d, record %qu", filen, record); + err(1, "read error, file %d, record %ju", filen, (intmax_t)record); } else if (nread != lastnread) { if (lastnread != 0 && lastnread != NOCOUNT) { if (lastrec == 0 && nread == 0) - fprintf(msg, "%qu records\n", record); + fprintf(msg, "%ju records\n", (intmax_t)record); else if (record - lastrec > 1) - fprintf(msg, "records %qu to %qu\n", - lastrec, record); + fprintf(msg, "records %ju to %ju\n", + (intmax_t)lastrec, (intmax_t)record); else - fprintf(msg, "record %qu\n", lastrec); + fprintf(msg, "record %ju\n", (intmax_t)lastrec); } if (nread != 0) fprintf(msg, "file %d: block size %d: ", @@ -184,10 +185,12 @@ r1: guesslen = 0; nw = write(outp, buff, nread); if (nw != nread) { if (nw == -1) { - warn("write error, file %d, record %qu", filen, record); + warn("write error, file %d, record %ju", filen, + (intmax_t)record); } else { - warnx("write error, file %d, record %qu", filen, record); - warnx("write (%d) != read (%d)", nw, nread); + warnx("write error, file %d, record %ju", filen, + (intmax_t)record); + warnx("write (%d) != read (%d)", nw, nread); } errx(5, "copy aborted"); } @@ -200,8 +203,8 @@ r1: guesslen = 0; break; } fprintf(msg, - "file %d: eof after %qu records: %qu bytes\n", - filen, record, size); + "file %d: eof after %ju records: %ju bytes\n", + filen, (intmax_t)record, (intmax_t)size); needeof = 1; filen++; tsize += size; @@ -210,7 +213,7 @@ r1: guesslen = 0; } lastnread = nread; } - fprintf(msg, "total length: %qu bytes\n", tsize); + fprintf(msg, "total length: %ju bytes\n", (intmax_t)tsize); (void)signal(SIGINT, oldsig); if (op == COPY || op == COPYVERIFY) { writeop(outp, MTWEOF); @@ -281,11 +284,11 @@ intr(int signo __unused) { if (record) { if (record - lastrec > 1) - fprintf(msg, "records %qu to %qu\n", lastrec, record); + fprintf(msg, "records %ju to %ju\n", (intmax_t)lastrec, (intmax_t)record); else - fprintf(msg, "record %qu\n", lastrec); + fprintf(msg, "record %ju\n", (intmax_t)lastrec); } - fprintf(msg, "interrupt at file %d: record %qu\n", filen, record); + fprintf(msg, "interrupt at file %d: record %ju\n", filen, (intmax_t)record); fprintf(msg, "total length: %ju bytes\n", (uintmax_t)(tsize + size)); exit(1); }